AnsweredAssumed Answered

STM32F411RE stm32cube fatfs sdio sdcard always returns FR_DISK_ERR

Question asked by Jakub Lasinski on Mar 3, 2018
Latest reply on Mar 11, 2018 by Jakub Lasinski


I've tried to test sdcard with fatfs on STM32F411RE on NUCLEO-F411RE board.


I don't have a compleat 100% sure hardware or software, so I'm struggling to debug if its a software or hardware issue.

I've read trough some topics hear, one with issue with sd initialization (but it seams that in my version this issue is already resolved).


I've tripple cheked all the connections and when the card is not in the socket I get fast resposne.


I've generated the code from stm32cubemx, and added a custom code:

  /* Initialize all configured peripherals */

  FRESULT res;
  FATFS SDFatFs;  /* File system object for SD disk logical drive */
  FIL MyFile;     /* File object */
  res =  f_mount(&SDFatFs, (TCHAR const*)SDPath, 0);
  if (res != FR_OK)

  res=  f_open(&MyFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE);
  if (res != FR_OK)

  /* USER CODE END 2 */


f_mount is ok, but f_open after around 30s gives back an FR_DISK_ERR . When there is no card in the socket I'm getting fast FR_NOT_READY return.


When exacuting f_open the funcion stucks on line 3050 from ff.c  

fmt = check_fs(fs, bsect);            /* Load sector 0 and check if it is an FAT-VBR as SFD */

It check_fs returns 4 code back and then f_open returns with FR_DISK_ERR


The only thing I did is change some SDIO pins to other options, and setup the clock. I'v tried with SDIO divider up to 96 and it didn't resolve my issue.


Am i forgetting about something? I know that the socket is on jumper wires, but at 250khz clock it should work... Of course tried few cards, tried to use f_mkfs to format card....



I'm software I'm using:

Attolic True studio v9.0

STM32Cube FW_F4 V1.19.0
FatFs R0.12c
STM32Cube 4.24