2019-04-12 02:33 AM
Hello,
i have a strange problem when i try to work with a FatFS on SD cards with SDIO.
MCU is a STM32F439ZI, SDIO 4 wire for SD cards, FatFS for SD cards (used CubeMX 5.1.0 to create the base code, working with Atollic TrueSTUDIO 9.0.1)
I have working code for a 4 GB microSD card, initialisation, mount, open, read/write, all works fine.
If i use a 2 GB or 8 GB microSD card i can initialize and mount (FR_OK), but when i try to open a file i get FR_NO_FILESYSTEM as result. So i implemented a check for FR_NO_FILESYSTEM and call f_mkfs, this runs fine (FR_OK), i mount the card (FR_OK) and when i try to open a file -> FR_NO_FILESYSTEM (when one operation before the f_mkfs gave FR_OK back).
When i format the card at the PC in different ways and format types (SD card formater, Windows formater, EaseUS Partition Master /// FAT, FAT32, exFAT) i still get the same FR_NO_FILESYSTEM error for the 2 GB and 8 GB microSD, while the 4 GB microSD works perfectly fine with the exact same code.
Has anyone a clue what could be the problem here?
Best regards,
Florian
2019-04-12 05:18 AM
There are very few occasions where f_mkfs() is appropriate.
FR_NO_FILESYSTEM is usually an issue with reading the media properly. FATFS comes up with this after reading one or two sectors, nominally MBR and BPB.
I would tend to instrument DISKIO layer so that it dumps the initial sectors, prints the blocks/counts for read/write requests and reports read/write disk errors.