cancel
Showing results for 
Search instead for 
Did you mean: 

Specific SD card returning error with FatFS

Pushkar Limaye
Associate
Posted on April 01, 2017 at 11:37

I am trying to read and write to a class 10 - 2GB SD card from STM32 with the help of FATFS R0.11, but

f_mount()

function is returning

FR_NO_FILESYSTEM

error code. I have tested the same code on a class 4 - 2GB and class 10 - 16GB SD card, and it worked perfectly. What am I doing wrong here for this specific SD card?

Code:

FIL filTest;FATFS fs; FRESULT initSD(){ disk_initialize(0); FRESULT res; res = f_mount(&fs, '', 1); if(res != FR_OK) { return res; } res = f_open(&filTest, 'test.txt', FA_OPEN_ALWAYS | FA_WRITE | FA_READ); return res;}

#stm32f103 #sdcard #fat-fs #f_mount-sdcard
4 REPLIES 4
Posted on April 01, 2017 at 17:26

Like it isn't formatted...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sumit kale
Associate III
Posted on April 03, 2017 at 09:35

Check your Card detect Pin. You have to assign Card detect Pin (Example: PE15 in my case for STM32F205).

In Addition to this you have to initialise Clock for the SD Card by command:

RCC->APB2ENR |= RCC_APB2ENR_SDIOEN; // for SDIO Mode.

Usually error will be with Card detect Pin. So check if your pin is not assigned to any other Tasks like Timer or UART etc.

Formatiing SD Card also works some time.

antonius
Senior
Posted on April 03, 2017 at 11:28

Can you read that SD card in your computer ? and check your Card Detect port also SDIO speed ?

Daniel Koster
Associate II
Posted on May 09, 2018 at 18:45

I had the problem that 1 of my 4 SD Cards lying arround was working. On the others i got FR_NO_FILESYSTEM when mounting with f_mount. If you check your card with HxD in sector 0 the last 2 bytes should be 0x55 and 0xAA when FAT formatted.

My cards where correctly formatted but were not recognized as FAT Format and the bug was actually in the low level implementation.

On STM32 (with spi HAL library) when reading from the SD Card a 0xFF has to be sent (MOSI has to be HIGH for every bit) and so i had to use the HAL_SPI_TransmitReceive() function to send a 0xFF while receiving.

After that the other cards worked without problem.

I guess some cards can live without it.