cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C5 USBX Middleware

jarink
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

5 REPLIES 5
jarink
Associate II

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.

jarink_0-1777142770940.png

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!

 

Pavel A.
Super User

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.

 

PavelA_0-1777154741102.png

 However, I am still getting compilation errors. 

Have you tried to build the example as is, without any changes? In which IDE?

 

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).

jarink_0-1777216169025.png

 


@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.

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.

Saket_Om
ST Employee

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.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om