Skip to main content
chrkaras
Associate II
July 17, 2026
Question

STM32H755 + SDMMC + USB MSC

  • July 17, 2026
  • 2 replies
  • 28 views

Hi everyone,

 

I have developed a custom pcb board and I want to use the usb and a uSD card. I am not really familiar with pcb designing.

 

My guidance was some youtube videos in general, like the Phil’s Lab for the USB + SD MSC (The link, so there is some understanding on the code I have added to the usb app).

 

The USB works. The SD only worked once somehow, while I was stepping the code in the debugging process. I could not do it again. I have tried every possible configuration.

 

The only thing I get is the following from the terminal:

 

[28067.786253] usb 3-4: new full-speed USB device number 86 using xhci_hcd
[28067.913272] usb 3-4: New USB device found, idVendor=0483, idProduct=572a, bcdDevice= 2.00
[28067.913281] usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[28067.913283] usb 3-4: Product: STM32 Mass Storage
[28067.913286] usb 3-4: Manufacturer: STMicroelectronics
[28067.913288] usb 3-4: SerialNumber: 395834673434
[28067.916167] usb-storage 3-4:1.0: USB Mass Storage device detected
[28067.916903] scsi host1: usb-storage 3-4:1.0
[28068.979800] scsi 1:0:0:0: Direct-Access STM Product 0.01 PQ: 0 ANSI: 2
[28068.980445] sd 1:0:0:0: Attached scsi generic sg1 type 0
[28068.982327] sd 1:0:0:0: [sdb] 30965759 512-byte logical blocks: (15.9 GB/14.8 GiB)
[28068.982530] sd 1:0:0:0: [sdb] Write Protect is off
[28068.982535] sd 1:0:0:0: [sdb] Mode Sense: 03 00 00 00
[28068.982700] sd 1:0:0:0: [sdb] No Caching mode page found
[28068.982703] sd 1:0:0:0: [sdb] Assuming drive cache: write through
[28068.997679] sd 1:0:0:0: [sdb] Attached SCSI removable disk

 

while the computer Identifies the sd card through the USB, I can not open the SD card to read or write. The clock frequency so the sd card gets identified is from 10MHz to 20MHz in either 1 or 4 bit mode. The sd card was already formatted with the default FAT32. I have validated with my oscilloscope that the ESD protection allows the signals for the protocol.

 

Can someone please check the design and the configuration file and help me out understand what’s wrong?

I have attached the design and the .ioc file.

 

Thanks in advance!

2 replies

ST Technical Moderator
July 20, 2026

Hello ​@chrkaras 
-The purpose of USB MSC device class is to make the host (which is in your case your PC) reads the STM32 products as MSC device
-The purpose of SDMMC is to make STM32 product able to interface with the SD card
>while the computer Identifies the SD card through the USB, I cannot open the SD card to read or write.
so based on your observations, I reckon that your issues are caused from SDMMC (maybe bad clock configuration or wrong parameters)
to be sure, I recommend you create a new project that have only SDMMC configuration with maybe FATFS and make the project create a .txt file and write something on it and close it.
and see if you encounter any issues,
just to know, to verify that your code worked great you need to insert your SD card in your phone or PC to see if the file see created or not
BR
Gyessine 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
ST Technical Moderator
July 22, 2026

Hello ​@chrkaras 
I’am coming back with more help

Here is piece of code from one of my projects that uses SDMMC and FATFS to access an SD card create a txt file and write on it
you can use it as reference to test this functionality to verify if it is really an SDMMC config issue or not
 

char SDPath[4]; /* SD card logical drive path */
static uint8_t Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint32_t BufferLength);
static uint8_t isInitialized = 0;
uint8_t workBuffer[4096];
char phrase[80] = " Technology is advancing at an unprecedented pace\n"


int main(void)
{
int32_t timeout;
MPU_Config();
/* Enable the CPU Cache */
CPU_CACHE_Enable();
MX_GPIO_Init();
/* Wait until CPU2 boots and enters in stop mode or timeout*/


/* stm32h7xx HAL library initialization:
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();

/* Configure the system clock to 400 MHz */
SystemClock_Config();


/* When system initialization is finished, Cortex-M7 will release Cortex-M4 by means of
HSEM notification */

/*HW semaphore Clock enable*/

/*----------------------------------------*/
/* Configure LED1 and LED3 */
BSP_LED_Init(LED_GREEN);
BSP_LED_Init(LED_RED);

/*##-1- Link the micro SD disk I/O driver ##################################*/
FATFS_LinkDriver(&SD_Driver, SDPath) == 0;

/*##-2- Init the SD Card #################################################*/

SD_Initialize();

/* Create FAT volume */

BSP_SD_IsDetected(0);

FRESULT res;

res = f_mkfs(SDPath, FM_ANY, 0, workBuffer, sizeof(workBuffer));

if (res != FR_OK)
{
Error_Handler();
}

/* Infinite loop */

/* Mass Storage Application State Machine */

BSP_LED_Off(LED_RED);
SD_Initialize();
/* FatFs function common result code */

uint32_t byteswritten, bytesread; /* File write/read counts */
//uint8_t wtext[] = "[STM32H747_Eval/CORE_CM7]:This is STM32 working with FatFs + DMA"; /* File write buffer */
uint8_t wtext[] = "This is STM33 working with FatFs + DMA example on sdcard with sdmmc interface";
/* Register the file system object to the FatFs module */
if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) == FR_OK)
{
/* Create and Open a new text file object with write access */
if(f_open(&MyFile, "STM33.TXT", FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)
{
/* Write data to the text file */
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, GPIO_PIN_SET);

res = f_write(&MyFile,phrase, sizeof(phrase), (void *)&byteswritten);
HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, GPIO_PIN_RESET);
if((byteswritten > 0) && (res == FR_OK))
{
/* Close the open text file */
f_close(&MyFile);

/* Open the text file object with read access */
if(f_open(&MyFile, "STM33.TXT", FA_READ) == FR_OK)
{
/* Read data from the text file */
res = f_read(&MyFile, rtext, sizeof(rtext), (void *)&bytesread);

if((bytesread > 0) && (res == FR_OK))
{
/* Close the open text file */
f_close(&MyFile);

/* Compare read data with the expected data */
if(Buffercmp(rtext, wtext, byteswritten) == 0)
{
/* Success of the demo: no error occurrence */
BSP_LED_On(LED_GREEN);//if file was created and filled successfully
return;
}
BSP_LED_On(LED_GREEN);//in case of any error
}
}
}
}
}
/* Cannot link diskio driver */
while (1){


}
}

BR
Gyessine

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.