cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L462 FATFS FR_DISK_ERR on f_write

SYako
Associate III

Using custom board with l462re, sdcard connected directly to mcu without external pullups.

SDMMC clockdiv set to 10, SDMMC freq set to 48MHz.

When ever I'm trying to use f_write or f_mkfs they return FR_DISK_ERR.

Sometimes sdcard is corrupts(file is created but files size is 4gb).

Tried 5-6 sdcards from 1gb to 32gb.

Same code but on f767 is working fine.

3 REPLIES 3

To understand why the top-level code fails you'll need to look at the DISKIO layer, and validate that.

I wouldn't use f_mkfs() until you have the read/write sector(s) stuff working flawlessly.

Do you have a UART you can output debug/telemetry data on? Which UART/pins ?

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

I can use stlink for debug(breakpoints)

Today I checked connection between stm and sd card, all acording to cubemx configuration. Also I managed to write small test file, but when Im trying to write big file by blocks(log some data from adc to sdcard) f_write returns FR_DISK_ERR. Also I noticed that f_open is also returning FR_DISK_ERR if file doesnt exists. Sometimes stm get stuck in SDMMC_GetCmdResp1 or SDMMC_GetCmdResp3.

Noticed that cubemx generating code with sdmmc in 1bit width mode, is this normal?

Tried everything in both 1 and 4 bit modes.