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.