cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX - USBX - Broken user code blocks and missing enum definitions

Despair1337
Associate III

STM32CubeIDE, Version: 1.13.1, Build: 17479_20230728_0839 (UTC)
STM32Cube MCU Package for STM32U5 Series, Version: 1.3.0

I am using USBX with enabled USB Device FS and AUDIO Device Class FS.

I found following problems and issues:

  1. USBX/App/ux_device_descriptors.h: Even when AUDIO Device Class is enabled, the CLASS_TYPE_AUDIO enum entry is not added into USBD_CompositeClassTypeDef enum definition. Since there are not USER CODE blocks, I cannot add this enum entry, without it being removed every IOC regeneration.
  2. USBX/App/ux_device_descriptors.c: Even when AUDIO Device Class is enabled, the CLASS_TYPE_AUDIO enum entry is not added into UserClassInstance array. Since there are not USER CODE blocks, I cannot add this enum entry, without it being removed every IOC regeneration.
  3. USBX/App/ux_device_descriptors.c: The user code block USER CODE FrameWork_AddToConfDesc_1 doesn't work properly (during IOC regeneration, the code inside of this block is always removed). This happens probably because the closing comment miss END keyword
    Despair1337_0-1691478830881.png
  4. USBX/App/app_usbx_device.c: There is missing USER CODE block in function MX_USBX_Device_Init, before tx_thread_create call. Thus, when I register other class via ux_device_stack_class_register before creating the final usb device thread (in my case, registering audio class), my changes are always erased during IOC regeneration, as user code block is missing there.

Thanks

5 REPLIES 5
mohamed.ayed
ST Employee

Hi @Despair1337 , Audio class 1.0 and 2.0 is supported by USBX stack but Code generation and Code init of those are not yet implemented in CubeMx you can refer to Microsoft AzureRTOS documentation to develop your Owen application : https://learn.microsoft.com/en-us/azure/rtos/usbx/usbx-device-stack-supplemental-2#usb-device-audio-class

Despair1337
Associate III

Dear @mohamed.ayed , thank you for fast reply.
Yes, I am aware that the code generation for Audio is not implemented in STM32CubeMX, I integrated it by myself successfully.
Although even it is not officially implemented, I think that CubeMX should generate at least enum entries, so I can use it to provide own implementation. Also please note, that point (3) and (4) is general bug in USBX file templates, and they should be fixed, as user code are lost.

Thanks!

Dear @mohamed.ayed ,

please, would it be possible to report those bugs (mainly 3. and 4.) to CubeMX team, so user code areas can be fixed? Because of reported issues, CubeMX always clears our code, which we need to manually restore via git.

Thanks

grahamm
Associate II

I also had your problem (3).  I fixed it by modifying ux_device_descriptors_c.ftl, adding the 'BEGIN' and 'END' keywords to the USER CODE blocks that I care about.  That fixed my problem, and I noticed there were several other blocks with the same error that I don't care about (yet):

Device_Framework1

String_Framework0

String_Framework1

HidReportDesc0

... and probably more.  Can't be bothered searching.  A smart person at ST should go through the template and fix it up.

rainbow
Associate

The issue is still present (STM32CubeIDE 1.15.1) and the latest STM32 platform.