Skip to main content
Durmil Makwana
Associate
June 14, 2018
Question

Issue of mounting 256MB SD Card in STM32F411 Discovery kit using SDIO interface

  • June 14, 2018
  • 12 replies
  • 5136 views
Posted on June 14, 2018 at 09:48

I am using stm32F411RE discovery kit. i generate a code with the cubeMX4.25, the 4GB SDHC card is working fine but when i tried with the 256MB SD Card it was not working. I am getting error 'FR_NOT_READY' in f_mount function.

Other SD Cards (4GB and 16GB) are successfully mounted and file can be written/read.

#fatfs-sdio #sd-card #fr_not_ready #f_mount-sdcard #sdio-fatfs #stm32f4-sdio #stm32f411e-disco #f_mount
This topic has been closed for replies.

12 replies

ST Technical Moderator
June 26, 2018
Posted on June 26, 2018 at 15:12

Hello

durmil

,

I recommend you to follow these documents:

https://community.st.com/0D50X00009bMM7JSAW

https://community.st.com/0D50X00009bMM8bSAG

With Regards,

Imen.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Durmil Makwana
Associate
June 26, 2018
Posted on June 26, 2018 at 15:32

Dear Imen,

   Thank you for the prompted response.

   We also need the USB feature so the USB + (SDIO + DMA) are conflicting to each other. so, Can it possible this without DMA.

   We have configured with 4bit SDIO + FatFs R0.12.

   While the cubeMx generated code showing some errors so the _FFCONF is changed with 32020.

Regards,

Durmil Makwana

ST Technical Moderator
June 26, 2018
Posted on June 26, 2018 at 16:17

Dear

durmil

,

Getting the “FR_NOT_READY�? error means that the SD_initialize() call failed for some reason.

It is done in the ‘sd_diskio.c’ file.

How is you doing the test?, As far as I know, the STM32411-Disco board doesn’t have any uSD port.

C

an you please attache your ioc file, I

will check your issue and come back to you.

With Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Durmil Makwana
Associate
June 27, 2018
Posted on June 27, 2018 at 07:27

Hello

‌,

Please find the attachment for .ioc file of my project.

Because of USB module we don't want to use DMA in my code so we have configured the project without DMA.

my basic requirementis256MB SD Card using 4bit SDIO.

0690X0000060PH9QAM.jpg

Regards,

Durmil Makwana

________________

Attachments :

CubeMxSDIOInterface.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxTM&d=%2Fa%2F0X0000000ayU%2FrYjglQX91MYCtnE1NRKbrrFNoZojDFz7cwO4BWWdC5I&asPdf=false
Durmil Makwana
Associate
June 30, 2018
Posted on June 30, 2018 at 12:34

Hello, 

We Found a problem with SD Card Socket there is all data pins are shorted in the module. now we can read write in 4GB and 16GB card with DMA and Without DMA using 4bit and 1bit modes. 4GB(SDHC class-4) Card is working at 2MHz frequecy and the 16GB(class-10) Card is working at 500KHz.

In the Hardware we have pulled up the lines with the 47K resistors.

But still the problem is same that the 256MB Card is not working at any frequencies - (from 300KHz to 8MHz).

Is there any changes required specific for 256MB Memory Card.

0690X0000060LVDQA2.png

We are using this memory card to store the data.

Tesla DeLorean
Guru
June 30, 2018
204196CGIL2
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
AShar.8
Associate
July 23, 2018

Hello,

I am following up on this question as it is still not solved.

We are not able to support 256MB SD CARD. Please see below.

We are using stm32F411RE discovery kit. The code was generated with the cubeMX4.25. This code is supporting 4GB and 16GB SDHC card but 256MB SD Card does't work. We are getting error 'FR_NOT_READY' in f_mount function.

Please suggest if there is a patch or old revision of code that can support 256MB card?

Durmil Makwana
Associate
August 1, 2018

Hello,

I would like to update the current status of the issue. We have three 256MB cards and out of three cards one card is working perfectly with the firmware. One card gives an error FR_NO_FILESYSTEM and another one gives an error FR_DISK_ERR.

We check into the lower level functions of FatFs and it gets error from below function.

File Name : ff.c

Function Name: FRESULT find_volume

bsect = 0;

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

if (fmt == 2 || (fmt < 2 && LD2PT(vol) != 0)) { /* Not an FAT-VBR or forced partition number */

for (i = 0; i < 4; i++) { /* Get partition offset */

pt = fs->win + (MBR_Table + i * SZ_PTE);

br[i] = pt[PTE_System] ? ld_dword(pt + PTE_StLba) : 0;

}

i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */

if (i) i--;

do { /* Find an FAT volume */

bsect = br[i];

fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */

} while (LD2PT(vol) == 0 && fmt >= 2 && ++i < 4);

}

if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */

if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */

The values in br[] array in working 256MB Card is {0x65, 0x00, 0x00, 0x00}

The values in br[] array in non-working 256MB Card is {0x3F, 0x00, 0x00, 0x00}

So, We searched and found that these numbers are indicating the number of hidden sectors of the SD Card.

after executing the do_While loop the fmt was fed with 4 and 3 in non-working cards.

Should we Check for any other possible area? Can 0x65 and 0x3f make a difference?

Tesla DeLorean
Guru
August 1, 2018

The cards I got needed some more CMD55 requests to come up.

The code shown is reading values from the MBR partition table, it uses these to find the BPB of the FAT volumes. The FR_NO_FILESYSTEM is indicative that it can't find a FAT volume at a specified location, the locations might be different depending on how they were formatted, and still be valid.

Are these cards readable elsewhere? ie from a PC based card reader.

A dump of the content of the MBR, and BPB might be more instructive about the issues with the card than the code that processes the data.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Durmil Makwana
Associate
August 2, 2018

Hello,

We gave it the CMD55 until it did not return HAL_SD_ERROR_NONE So it give HAL_SD_ERROR_NONE after 3 or 4 tries.

all three cards are working in the PC. But only one card is work with the Discovery kit. all the cards are of KODAK brand.

All three cards are formatted with the FAT16 file system with the 16k and 4k Allocation unit size.

Please find attachment for the MBR Register values of all three cards.

P D Chauhan
Visitor II
August 9, 2018

Hello All,

I am working with Durmil,

To summarize again: we have three 256 MB SD Card of Kodak brand. Out of these three, only one 256 MB SD Card is working with 4-bit SDIO.

We found that using 4-bit SDIO, MBR sector is not read correctly from one SD Card. Till now it is observed that while reading MBR (located at sector # 0x3F) in this SD Card, 21st Byte's LSB 4-bits of are missed and replaced by next byte's MSB 4-bits. So, it affected bits of all next bytes to be shifted ahead. After some bytes, it again misses 4bits LSB. This happened almost 3-4 times for reading 512 bytes of MBR sector. Hence, CRC is not matching. So, it is giving FR_NO_FILESYSTEM as it has not found valid MBR.

We have tried using 1-bit SDIO with this non-working SD Card and it works fine! Now all three 256 MB SD Cards are mounted, opened and file can be created with with some text using 1-bit SDIO.

So, now question comes - cannot all 256 MB SD card work via 4-bit SDIO? Should we use only 1-bit SDIO for 256 MB SD Card to make sure that our firmware will communicate successfully with all 256 MB SD Card?

FYI: 16 GB is working via 1-bit SDIO and 4-bit SDIO.

We still prefer to use 4-bit SDIO, if we can found reason and solution. If not, we have option of 1-bit SDIO.

Thanks and Regards.

Tesla DeLorean
Guru
August 9, 2018

Dump CID, CSD and SCR for the various cards.

SCR should flag available bus widths.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..