2026-05-24 7:29 PM
We are developing a product based on the STM32F469 with Azure RTOS / USBX.
The system requires both USB CDC and MSC device functionality:
Both operate as USB device classes.
We found that getting CDC and MSC working together on STM32F4 + USBX is difficult, and we have not found any official example demonstrating this.
The STM32F4 Azure RTOS package provides separate examples for CDC and MSC:
By following those examples, we can get either:
However, we need both classes in the same product.
We investigated two possible approaches:
Unfortunately, we have not been able to make either approach work reliably.
For the composite-device approach, we managed to get both classes successfully registered using:
_ux_device_stack_class_register()
Windows Device Manager correctly detects:
However:
Our suspicion is that the issue may be related to the USB FIFO configuration (HAL_PCDEx_SetRxFiFo() / HAL_PCDEx_SetTxFiFo()).
The STM32 examples only provide FIFO configurations for:
There is no example showing how FIFO sizes should be configured for CDC + MSC together.
We tried multiple FIFO combinations without success.
If anyone has a working FIFO configuration for STM32F469 + USBX CDC/MSC composite device, that would be very helpful.
As an alternative, we tried dynamically switching between CDC and MSC modes.
The idea was:
Simplified code:
void USBX_Start_CDC(void)
{
ux_system_initialize(...);
_ux_device_stack_initialize(...);
_ux_device_stack_class_register(
_ux_system_slave_class_cdc_acm_name,
_ux_device_class_cdc_acm_entry,
...);
HAL_PCD_Start(&hpcd_USB_OTG_FS);
}
void USBX_Start_MSC(void)
{
ux_system_initialize(...);
_ux_device_stack_initialize(...);
_ux_device_stack_class_register(
_ux_system_slave_class_storage_name,
_ux_device_class_storage_entry,
...);
HAL_PCD_Start(&hpcd_USB_OTG_FS);
}
void USBX_Switch_Mode(uint8_t new_mode)
{
HAL_PCD_Stop(&hpcd_USB_OTG_FS);
_ux_device_stack_disconnect();
_ux_device_stack_uninitialize();
ux_system_uninitialize();
HAL_Delay(200);
if (new_mode == USB_MODE_CDC)
USBX_Start_CDC();
else
USBX_Start_MSC();
}
However, this approach also fails.
It appears that the initialization sequence creates various RTOS objects and allocations:
During teardown, many (possibly all) of these resources do not appear to be fully deleted or released.
As a result:
Our current conclusion is that:
USBX device stack initialization is effectively “one-time only” on STM32F4, and full teardown/reinitialization is not supported.
2026-05-25 3:18 AM - edited 2026-06-01 8:58 AM
Hello @jason_gu
>Is there an official example of STM32F4 + USBX supporting CDC + MSC composite device?
For now, I think there is no official example that establishes your requirements. However, there are several articles that may be helpful for your use case, whether you continue using USBX or ST classic middleware. See article1, article2 and article3 .
Since you are using USBX MSC+CDC: you should ensure that you dedicated at least 11KB of memory for USBX
>If not, what is the recommended approach for products needing both CDC and MSC functionality?
I recommend using the first method, which is building a composite project. This approach is usually simpler than switching between classes at runtime, as switching often causes memory management issues.
If you still want to try switching classes, you can refer to the attached project.
The attached project is based on STM32U585. It starts as an HID device and then switches to a CDC device after five seconds. You can use the switch logic in app_usbx_device.c and ThreadX memory management in app_azure.c to create your application.
I hope my answer helps you and meets your expectations.
BR
Gyessine
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.
2026-05-26 4:33 AM
Just to avoid confusion between FIFO configuration and USBX memory pool allocation, you can refer to this article and practical use cases here for fifo sizing.
You can start with article as mentioned @Gyessine , if you have issues integrating both classes feel free to mention the error and attach your project.
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.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.