STM32N6 – USB Mass Storage over SDMMC2: Drive appears in Windows but cannot be opened
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.
