Skip to main content
manuislet
Associate II
May 17, 2023
Solved

STM32F401 SDIO FATFS always returnig FR_DISK_ERR

  • May 17, 2023
  • 3 replies
  • 3279 views

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

This topic has been closed for replies.
Best answer by KDJEM.1

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

3 replies

Tesla DeLorean
Guru
May 17, 2023

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
KDJEM.1
KDJEM.1Best answer
ST Technical Moderator
May 18, 2023

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 "Best answer" on the reply which solved your issue or answered your question.
manuislet
manuisletAuthor
Associate II
May 19, 2023

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?