2017-04-01 02:37 AM
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
2017-04-01 08:26 AM
Like it isn't formatted...
2017-04-03 12:35 AM
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.
2017-04-03 02:28 AM
Can you read that SD card in your computer ? and check your Card Detect port also SDIO speed ?
2018-05-09 09:45 AM
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.