cancel
Showing results for 
Search instead for 
Did you mean: 

How to make SDMMC & eMMC FatFs Work with STM32H723?

Mcherif
Associate II

 

Hello,

I am utilizing the following components:

  • Nucleo-H723ZH (STM32H723)
  • eMMC: 4GB

I have already created the following files:

  • user_discio.c
  • user_discio.h
  • eMMC_Driver.c
  • eMMC_Driver.h

After connecting an SD card reader to the CN8 connector on the Nucleo STM32H723 board and using an eMMC card reader, the FATFs system is reporting that the eMMC is not ready. I am encountering problems when performing operations like f_mkfs or f_mount, receiving a "Not ready" error. Despite numerous checks of the configurations and parameters, I have not been able to resolve this issue.

Mcherif_1-1712146882250.png

Mcherif_2-1712146918406.png

Mcherif_3-1712146935967.png

Mcherif_4-1712146958787.png

 

Mcherif_5-1712146989922.pngMcherif_6-1712147032484.png

 

Mcherif_7-1712147050669.pngMcherif_8-1712147190270.jpeg

 

Mcherif_0-1712146707075.png

 

3 REPLIES 3
MNapi
Senior III

try first SD 1 it first and see if it works

there was problem with CubeMX

 

the reason CubeMX code generation cannot configure SDMMC and the FatFS at the same time. 

this is why it did not work but worked on 1 PIN (SD 1 bit)

if this is the case you can try to work around first initializing 1 bit (in user code) then 4

 

 

static void MX_SDMMC2_SD_Init(void)
{

/* USER CODE BEGIN SDMMC2_Init 0 */
hsd2.Instance = SDMMC2;
hsd2.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd2.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd2.Init.BusWide = SDMMC_BUS_WIDE_1B;

/* USER CODE END SDMMC2_Init 0 */

/* USER CODE BEGIN SDMMC2_Init 1 */

/* USER CODE END SDMMC2_Init 1 */
hsd2.Instance = SDMMC2;
hsd2.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd2.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd2.Init.BusWide = SDMMC_BUS_WIDE_4B;
hsd2.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hsd2.Init.ClockDiv = 0;
/* USER CODE BEGIN SDMMC2_Init 2 */

/* USER CODE END SDMMC2_Init 2 */

}

Mcherif
Associate II

Hello,

I have tried all your recommendations for the Nucleo-H723ZH (STM32H723), but the FATFs system consistently reports that the eMMC is not ready. I also purchased the Discovery board STM32H735IGK6. When I use the provided examples for a micro SD card, it works, but when I reconfigure it with Cube-MX for an eMMC and follow all the recommendations you mentioned, I encounter a new issue: the FATFs system reports that the FR_INVALID_DRIVE.

go with SD not MMC

 

probably something wrong with your settings, some SD cards will not work

I have the same setting on a few boards, all is working

what is your clock in CubeMX for SD ? on my cards it works up to 48 MHz, stops above

 

1.png

2.png

3.png

here is my test code

 

/* USER CODE BEGIN Includes */
#include "string.h"
/* USER CODE END Includes */

 

/* USER CODE BEGIN 0 */
FRESULT res; /* FatFs function common result code */
uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "testing SD card"; /* File write buffer */
uint8_t rtext[_MAX_SS];/* File read buffer */

uint16_t sd_error;
/* USER CODE END 0 */

 

/* USER CODE BEGIN 2 */

if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0) != FR_OK)
{
sd_error = 1;
Error_Handler();
}
else
{
if(f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, rtext, sizeof(rtext)) != FR_OK)
{
sd_error = 2;
Error_Handler();
}
else
{
//Open file for writing (Create)
if(f_open(&SDFile, "ZK0001.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
sd_error = 3;
Error_Handler();
}
else
{

//Write to the text file
res = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
sd_error = 4;
Error_Handler();
}
else
{

f_close(&SDFile);
}
}
}
}
f_mount(&SDFatFS, (TCHAR const*)NULL, 0);
/* USER CODE END 2 */