cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401 SDIO FATFS always returnig FR_DISK_ERR

manuislet
Associate II

Hi all,

I am trying to do a simple code for writing and reading files in a SDHC Card, i am trying to start with this example code:

https://community.st.com/s/article/how-to-create-a-file-system-on-a-sd-card-using-stm32bubeide

However, when the code reaches

  • f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, rtext, sizeof(rtext));

It stucks for 30 seconds an then returns FR_DISK_ERR, if i repeat the same operation without the SD Card, it returns FR_NOT_READY

I have tried formatting the card, different cards, etc, same result.

I attached the .ioc file, just if there is any missing configuation or something wrong...

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @manuislet​ ,

If your project generated with STM32CubeMX, could you please check that the workaround provided in this discussion https://community.st.com/s/question/0D53W0000216T7oSAE/mxsdiosdinit-wrong-bus-wide-initialization is applied.

Please let me know if the issue is solved.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3

Generally you should avoid F_MKFS or any WRITE functionality until you've validated the READ functionality of the DISKIO layer of FatFS

All cards these days come formatted, and have structures properly aligned wrt the erase block size of the underlying NAND Flash array. Reformatting tends to ignore this, and is highly detrimental to performance and wear.

F4 write failures.. I'd probably make sure HW Flow Control is OFF

dRonin OpenLager


_legacyfs_online_stmicro_images_0693W00000bkJdMQAU.png 

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

Hello @manuislet​ ,

If your project generated with STM32CubeMX, could you please check that the workaround provided in this discussion https://community.st.com/s/question/0D53W0000216T7oSAE/mxsdiosdinit-wrong-bus-wide-initialization is applied.

Please let me know if the issue is solved.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

manuislet
Associate II

Thanks @Community member​  and @KDJEM.1​, confirmed that changing SDIO mode from 4B to 1B, i can write and read any SDcard i have. Although speed with 1B is more than enough for my application, is there any tested/verified workaround for this bus?