cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f4 discorvery, fatfs, SD card problem

JOK K
Associate
Posted on March 29, 2018 at 15:54

Hi all,

I'm working on getting a discovery board working with an SD card. I'm using CubeMx v4.25.0 with package v1.21.0.

Hardware connection is validated and is correct. 

I run into a problem when I try to open a file. A 

FR_DISK_ERR error is returned. 

The error looks like the problem mentioned in:

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

The error seems to come from this line:

if (disk_read(fs->drv, fs->win.d8, sector, 1) != RES_OK) in ff.c

Possible fixes mentioned in the linked post do not work.

Any clues about this?

#fatfs #sd-card #stm32f4-discovery #sdio
5 REPLIES 5
Posted on March 29, 2018 at 18:17

>>

Any clues about this?

You'll need to dig below this, the underlying read to the SD card is failing, presumably in sd_diskio.c, you'd want to instrument that.

There is workable code for the SD cards under the HAL example trees if CubeMX doesn't work.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Ogulcan Ariyurek
Associate II
Posted on April 25, 2018 at 14:40

Hi,

I exactly have the same problem. In fact, I traced down to the same line as stated.

Besides, I've managed to make it work with CubeMX v4.21 with FW v1.16, however I cannot make it work with CubeMX v4.25 with FW v1.21 (current latest version).

I tried the solution provided in here: 

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

 

This did not solve my problem.

Looking forward to hear any workaround as soon as possible, and ultimately a fix in the next version.

Regards,

Ogulcan

Posted on April 25, 2018 at 15:13

You're going to need to trace it deeper to understand why the sector read isn't working.

Should perhaps not be dependent on CubeMX, but rather look at the SD/FatFs examples with HAL. At the very least use the examples to test your interface and card functionality under 1.21

ST has let this mess drag on far too long...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 25, 2018 at 16:02

Hi Clive,

I have managed to make my hardware work with  CubeMX version 4.21 and F4 FW version 1.16, so I know that there is no hardware issue. I followed this video to do so: 

https://www.youtube.com/watch?v=0NbBem8U80Y

 

I tried the HAL examples beforehand given in STM32Cube_FW_F4_V1.21.0, but STM32F4 Discovery Board does not have uSD example as the board does not have uSD without its base board. I've copied from others and those did not work.

I also cannot downgrade my original project as CubeMX does not let me to do so. Therefore, I'll most probably skip this task until a new fixed version is released.

Regards,

Ogulcan

Posted on April 25, 2018 at 17:34

With the exception of the GPIO pin chosen for Card Detect functionality the SDIO/SDMMC pins are quite strongly defined across a range of F4 products. I tend to build to the STM32F4DIS-BB schematic as I have a bunch of those.

The NUCLEO-144 has turned into my break-out board of preference these days. Have a bunch of working SDIO/SDMMC projects for those across most families.

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