cancel
Showing results for 
Search instead for 
Did you mean: 

Fatfs + SD Card and f_mount return FR_NOT_READY

VÜnal.1
Associate II

Hi, i have stm32f446ze on my custom pcb.

Pin details :

PC8 SDIO_D0

PC9 SDIO_D1

PC10 SDIO_D2

PC11 SDIO_D3

PC12 SDIO_CK

PD2 SDIO_CMD

Global interrupts enabled and no DMA. i tried with Cubemx version 6.0.1, 4.25.0, 4.26.0. but whole the time , f_mount gave fr_not_ready.

What i tried to achieve this problem ?

Increase stack size

i tried to different versions of cubemx

Pull-up configuration

Different sd card

Another teammate of me who work same hardware last year. it worked but he took the fatfs by generated different version of cubemx and migrate to project which generated different version of cubemx. This is why no hardware related problem.

Now, how can i handle the problem ?

Best Regards

6 REPLIES 6

Dig into the DISKIO code, instrument if necessary. Not ready suggests it might be looking at the state of a card present pin flagging if a card is in the socket.

SDIO on the F4 needs the PLL running​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
VÜnal.1
Associate II

PG5 is the Detect_SDIO pin and i configured as input from Fatfs Configuration window.

Also PLL enabled.

it returns from here :

stat = disk_initialize(fs->drv);	/* Initialize the physical drive */
	if (stat & STA_NOINIT) { 			/* Check if the initialization succeeded */
		return FR_NOT_READY;			/* Failed to initialize due to no medium or hard error */
	}

Yeah, so you're going to need to descend into DISKIO layer to see why the initialization failed, or if it determined the card was missing.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Did you find the source of the problem? I have same issue. I tried your solvings that you tried. It did not work.

If you have a pin committed to the CARD DETECT or similar pin, the pin needs to be wired, the pin needs properly initialized.

The DISKIO code layer is where it's checking the pin and setting the STA_NOINIT flag, search in the sd_diskio.c (or equivalent file) for that text. Typically where it checks for a pin, or fails to initialize.

Like Here https://github.com/MaJerle/stm32f429/blob/main/00-STM32F429_LIBRARIES/fatfs/drivers/fatfs_sd_sdio.c#L306

And Here https://github.com/MaJerle/stm32f429/blob/main/00-STM32F429_LIBRARIES/fatfs/drivers/fatfs_sd_sdio.c#L322

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ramprakash13
Associate II

The FR_NOT_READY error typically indicates that the physical drive cannot be initialized due to no medium or a hard error. This could be due to a variety of reasons such as incorrect wiring, incorrect SDIO configuration, or an issue with the SD card itself.

 

Based on the information provided, it seems that you have already checked the wiring and tried different SD cards, which is a good start. Here are a few additional steps you could take:

 

  • Check the return value of disk_initialize() function. This function is responsible for initializing the physical drive and it should return 0 if the initialization was successful. If it's not 0, it could give you a clue about what's going wrong.

 

  • Make sure that the SDIO interface is correctly configured. The STM32F446ZE microcontroller supports 4-bit SDIO interface, so you should configure your SDIO pins (PC8, PC9, PC10, PC11, PC12, PD2) accordingly. Also, ensure that the clock settings for the SDIO peripheral are correct.

 

  • Try to initialize the SD card with a simple test program, without the FatFS layer. This could help you determine if the issue is with the SDIO interface or the FatFS layer.
  1. Ensure that the SD card is correctly formatted. The FatFS module supports FAT12, FAT16, FAT32 and exFAT file systems. If your SD card is formatted with a different file system, it might not be recognized.

Here is a code snippet that might be helpful:

 

 FATFS SDFatFs;  /* File system object for SD card logical drive */ FIL MyFile;     /* File object */ char SDPath[4]; /* SD card logical drive path */
...
/* Register the file system object to the FatFs module */ if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) != FR_OK) { /* FatFs Initialization Error */ Error_Handler(); } else { /* FatFs Initialization successful */ ... }

 

This code snippet attempts to mount the SD card and checks if the operation was successful. If not, it calls an error handler function.