How to port USBX on RTOS ¶
This page summarizes the RTOS-related expectations for USBX and highlights the FreeRTOS-specific constraints already enforced by the STM32Cube USBX configuration flow.
Supported operating-system model ¶
The current STM32Cube USBX configuration model exposes two execution modes:
-
No OSfor standalone integration -
FreeRTOSfor threaded integration
FreeRTOS prerequisites ¶
When USBX is configured in
FreeRTOS
mode, STM32CubeMX checks that RTOS
support is enabled in the project. It also warns when the following
FreeRTOS advanced APIs are not enabled:
-
xEventGroupSetBitFromISR -
xTimerPendFunctionCall
These features are required by the current USBX integration model and should be enabled before validating the generated project.
RTOS glue responsibilities ¶
The RTOS adaptation layer must provide consistent handling for:
-
Thread creation and scheduling
-
Synchronization and event propagation
-
Timing and timeout management
-
Memory allocation and alignment
-
ISR-to-thread handoff
Priority and stack relationships ¶
The configuration flow captures several priority dependencies that should be preserved in manual integrations as well.
|
Setting |
Relation |
Meaning |
|---|---|---|
|
Enumeration thread priority |
Must stay lower than or equal to DCD/HCD priorities |
Bus monitoring cannot preempt the controller layer indefinitely |
|
Class thread priority |
Must stay lower than or equal to DCD/HCD priorities |
Class processing must remain below controller servicing |
|
DCD thread priority |
Must stay greater than or equal to enum/class priorities |
Device events must be serviced promptly |
|
HCD thread priority |
Must stay greater than or equal to enum/class/keyboard priorities |
Host events and transfers remain responsive |
Porting example focus ¶
For STM32Cube USBX, FreeRTOS is the reference RTOS integration. A new RTOS port should first demonstrate:
-
Correct USBX core startup
-
Reliable controller interrupt handoff
-
Stable enumeration in both device and host use cases
-
Correct timeout behavior for control and non-control transfers
RTOS reference view ¶
STM32CubeMX core-system view when USBX is configured in
FreeRTOS
mode.
¶
-
-
confirm that
FreeRTOSis selected before reviewing -
thread priorities, stack sizes, and advanced API dependencies. This is the quickest way to verify that the RTOS-specific USBX path is really active.
-
confirm that
Links ¶
-
How to initialize USBX How to initialize USBX
-
USBX STM32Cube integration USBX STM32Cube integration
-
How to debug USBX-based examples How to debug USBX-based examples