Skip to main content
JOK K
Visitor II
March 29, 2018
Question

STM32f4 discorvery, fatfs, SD card problem

  • March 29, 2018
  • 5 replies
  • 927 views
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
This topic has been closed for replies.

5 replies

Tesla DeLorean
Guru
March 29, 2018
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Ogulcan Ariyurek
Associate III
April 25, 2018
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

Tesla DeLorean
Guru
April 25, 2018
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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Ogulcan Ariyurek
Associate III
April 25, 2018
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