2025-12-15 9:21 PM - edited 2025-12-15 9:23 PM
Hello ST Community,
I am working on an STM32N6-based board and trying to expose an onboard SD card (SDMMC2) as a USB Mass Storage (MSC) device using FileX and ThreadX.
The intended behavior is:
When a USB Type-C cable is connected to a Windows PC, the SD card should appear as a USB removable drive with full read/write access.
Hardware / Software Setup
MCU: STM32N6
SD interface: SDMMC2 (4-bit, polling mode)
USB: USB OTG HS (Device mode, MSC class)
RTOS: Azure RTOS ThreadX
File system: FileX
Toolchain: STM32CubeIDE
OS on host: Windows 10/11
#if (FX_STM32_SD_DMA_API == 1)
/* the SD DMA requires a 4-byte aligned buffers */
unaligned_buffer = (UINT)(media_ptr->fx_media_driver_buffer) & 0x3;
#endif
unaligned_buffer always evaluates to 0 because the buffer is aligned, but this does not resolve the issue.
Specific Debug Observation (FX_DRIVER_BOOT_READ)
During debugging, I observed that FileX always enters FX_DRIVER_BOOT_READ, and the following code path is always executed:
case FX_DRIVER_BOOT_READ:
{ /* the boot sector is the sector zero */
status = sd_read_data(media_ptr, 0, media_ptr->fx_media_driver_sectors, unaligned_buffer);
if (status != FX_SUCCESS)
{
media_ptr->fx_media_driver_status = status; break;
}
This condition is always satisfied, and FileX does not appear to progress normally to other filesystem states.
Even though the SD read function is called, Windows is still unable to open or read the filesystem.
2025-12-16 12:46 AM
hello @Grace_04
For your STM32N6 USB MSC with SD card project, please refer to the official STM32CubeN6 example here: Ux_Device_MSC_STM32CUBEN6 .
This example fully demonstrates SDMMC, FileX, and USB MSC integration and is a reliable reference to resolve your issue.
2025-12-16 12:50 AM
Thank you for sharing the reference example.
We have already gone through the Ux_Device_MSC_STM32CUBEN6 example in detail and are following the same approach for SDMMC + FileX + USB MSC integration. Our implementation is largely based on this example code.
However, even after aligning our code with the reference project, we are still facing the issue where the USB drive is detected by Windows but cannot be opened. The drive appears correctly, but access (open/copy/paste) fails.