2026-04-24 9:23 PM - last edited on 2026-04-25 1:14 PM by mƎALLEm
Hi all!
Thank you for taking time to assist me. I am attempting to make a composite USB Device on the NUCLEO-C562RE. I found the Middleware USBX examples and the core drivers exist in my toolchain at:
STM32CubeC5/middleware/usbx
However, I cannot seem to find the middleware configuration for USBX in STM32CubeMX2.
My pack manager in the STM32CubeMX2 is set to this default value:
"cube.packManager.cmsisPackRepositories": ["https://developer.st.com/st-pack-server/api/v1/pidx/STMicroelectronics.pidx"]
Please let me know if I have missed anything or if you need further information from me to figure out the root issue. The examples, linked above, clearly auto generated the USBX files using the MX2 software, but I could not find the documentation that allowed me to generate those files.
I would greatly appreciate it if someone could assist me with this.
EDIT: I saw this forum that says support isn't out until Q3. Does that mean I have to write the generated code myself?
EDIT: I found examples that are completely standalone, but I cannot download the device_cdc_acm_uart_freertos example. It gives a forbidden 403 error.
Thanks again,
Jarin
Solved! Go to Solution.
2026-04-26 9:17 AM - edited 2026-04-26 9:18 AM
I got it! A couple hidden items that required searching through the drivers:
1. generated/middleware/usbx/ux_stm32_device_descriptors.h
#ifdef USBD_INCLUDE_USER_DESC_CONFIG_FILE
#include "ux_stm32_device_descriptors_config.h"
#endif /* USBD_INCLUDE_USER_DESC_CONFIG_FILE */You MUST define this in a build argument somewhere such that it will include your device descriptors. (I added it to my top level CMakeLists.txt file
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC
# Add additional defined symbols here
USBD_INCLUDE_USER_DESC_CONFIG_FILE
)2. generated/hal/mx_usb_drd_fs.c
HAL_CORTEX_NVIC_SetPriority(USB_DRD_FS_IRQn, HAL_CORTEX_NVIC_PREEMP_PRIORITY_6, HAL_CORTEX_NVIC_SUB_PRIORITY_0);You MUST define the priority of USB to be lower than 0. The example sets it at 6. This allows FreeRTOS to have higher priority interrupts in the NVIC so that the scheduler is happy.
2026-04-25 11:49 AM
Based on this example and this example I added the generated files and the middleware files to the project to test copying over in the same way the MX2 would.
I then edited the components.cmake file to add the CMSIS for the USBX middleware. However, I am still getting compilation errors. Working through them now, but I would appreciate it if someone would give me some pointers.
Thanks!
2026-04-25 3:10 PM
> EDIT: I found examples that are completely standalone, but I cannot download the device_cdc_acm_uart_freertos example. It gives a forbidden 403 error.
From your previous message - you have resolved this issue? To get to the example on github, click on the left row (under "Name"), this will open the project page on github, where it can be downloaded.
> However, I am still getting compilation errors.
Have you tried to build the example as is, without any changes? In which IDE?
2026-04-26 8:06 AM - edited 2026-04-26 8:09 AM
Hi Pavel!
@Pavel A. wrote:From your previous message - you have resolved this issue? To get to the example on github, click on the left row (under "Name"), this will open the project page on github, where it can be downloaded.
No, the GitHub does not have the full build with all source code. It only has the relevant example files. Please compare the files for any of the examples when the .zip is downloaded versus the files present in the GitHub.
More specifically. The Github contains the app code and generated directories, but lacks the following directories (as pointed to in the screenshot).
@Pavel A. wrote:Have you tried to build the example as is, without any changes? In which IDE?
Yes, I was able to successfully run the usbx_device_hid_mouse_freertos_cmake example. The mouse mounts to my Ubuntu laptop and I see the mouse mouse when hitting the user button on the devkit.
I am running the STM32CubeIDE.
2026-04-26 9:17 AM - edited 2026-04-26 9:18 AM
I got it! A couple hidden items that required searching through the drivers:
1. generated/middleware/usbx/ux_stm32_device_descriptors.h
#ifdef USBD_INCLUDE_USER_DESC_CONFIG_FILE
#include "ux_stm32_device_descriptors_config.h"
#endif /* USBD_INCLUDE_USER_DESC_CONFIG_FILE */You MUST define this in a build argument somewhere such that it will include your device descriptors. (I added it to my top level CMakeLists.txt file
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC
# Add additional defined symbols here
USBD_INCLUDE_USER_DESC_CONFIG_FILE
)2. generated/hal/mx_usb_drd_fs.c
HAL_CORTEX_NVIC_SetPriority(USB_DRD_FS_IRQn, HAL_CORTEX_NVIC_PREEMP_PRIORITY_6, HAL_CORTEX_NVIC_SUB_PRIORITY_0);You MUST define the priority of USB to be lower than 0. The example sets it at 6. This allows FreeRTOS to have higher priority interrupts in the NVIC so that the scheduler is happy.
2026-04-30 1:29 AM - edited 2026-04-30 1:29 AM
Hello @jarink
We are aware of this limitation. The configuration of the USBX software component is not supported in the current version of STM32CubeMX2. Please refer to the STM32CubeMX2 Configuration Limitations documentation for more details.
This limitation will be addressed in a future release.