f_mkfs returns FR_DISK_ERROR

ankushextc@gmail.com gravatar image

asked 2017-03-20 14:12:45 +0200

Hi all,

I my application I am interfacing SD card with nrf52 using FATFS file system. I am observing some weird behavior while doing this. I have two SD cards, one of 2GB sandisk and another of 8 GB Transcend. While using 2GB card all operations are happening properly like formatting card and writing to SD card. But when I am using 8 GB card and trying to format it I am unable to perform the operation. Following is my formatting function

  void sd_format()
  BYTE work[_MAX_SS]; /* Work area (larger is better for processing time) */

  /* Create FAT volume */
  ff_result = f_mkfs("", FM_FAT32, 0, work, sizeof work);
  if (ff_result != FR_OK)
      printf("Unable to format Disk\r\n");
  if (ff_result == FR_OK)
      printf("Format Complete...\r\n");


I am getting FR_DISK_ERROR while executing f_mkfs function. What could be the possible reason for this.

edit retag flag offensive close delete report spam



One more thing I observed is that, after formatting with SD formatter, when I am trying to write onto the card it is working properly. It means format function has some issue. But I don't know why it happening...

Ankush ( 2017-03-21 06:50:32 +0200 )editconvert to answer

Do you have the same problem if you try to format as FM_EXFAT ?

Sigurd ( 2017-03-21 09:06:00 +0200 )editconvert to answer

Hi Sigurd,

Thanks for the response. I tried it now its giving FR_INVALID_PARAMETER as error from f_mkfs () function. I modified statement as follows,

ff_result = f_mkfs("", FM_EXFAT, 0, work, sizeof work);
Ankush ( 2017-03-21 10:09:37 +0200 )editconvert to answer