cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO(FatFS) File open(write) problem

Kim KyungTack
Associate III
Posted on April 03, 2018 at 05:35

Hi.

At the first time, SDIO works well but 10~20 minutes later, when i try to open a file(FA_CREATE_NEW | FA_WRITE options), there is no answer for 30 seconds and then SDIO does not work anymore after being shown FR_DISK_ERR.

Through debugging, I found that SDIO doesn't work as soon as the osMessageGet called on SD-Write function (osMessageGet result is osEventTimeout).

This problem disappears when the SDIO clock speed is lowered (ClockDiv is 8 or more). However, the Read/Write speed get very slow too much than i want.

STM32F429 use

CubeMX 4.25.0

STM32CubeF4 Firmware Package v1.21.0

FreeRTOS 9.0.0 (CMSIS 1.02)

FatFS R0.12c

SDIO Settings (DMA used)

0690X00000604XPQAY.jpg0690X00000604LGQAY.jpg0690X00000604UzQAI.jpg0690X00000604YCQAY.jpg
28 REPLIES 28

Standard board or something custom? USART and pins usable for diagnostic output? Which?​

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

USART2 with DMA and a lot of circular buffering - no delays for waiting flushing through USART ... flushing buffers from main cycle ...

standard boards mostly include debug support ... and i didn't use any standard board all the time i'm working with STM32F1/F4

and on my board i'm using HSE 12MHz

developer2
Senior

after additional investigation and testing i found that there is register DTIMER, and for each transfer is initialized with constant : SDMMC_DATATIMEOUT , value: 0xFFFFFFFFU

which means (2^32 - 1) / 48MHz = 89.5 -> 89.5 * 2 = 179seconds = 3 minutes ...

after deducting DTIMER register to zero SDIO is raising interrupt DTIMEOUT ... and this interrupt is processed as "Data Transfer abort" in IRQ Handler ... even if there is no transfer in progress ...

so probably developers in ST forgot to handle DTIMER register after successful transfer ... which cause Aborting transfer that already finished before 179seconds ...

if this message is read by ST's develpers , then please fix the bug in HAL ...

Kind regards,

Evgeniy Vasyliev
Associate III

@Kim KyungTack​, I am facing exactly the same problem as you describe in start of this post, I am getting lost on how to solve it. Did you solve it during this period (I see that you wrote this question more than a year ago). If there is any solution with it - please let me know. Thank you.

@Evgeniy Vasyliev​ . I do not know exactly why, but it does not appear after updating "CubeMX" and "packages". I'm sorry I can not help you much.

jim campbell
Associate II

I had a similar issue (doesn't quite seem the same though).

The fix in this post solved my problem. (see the post near the bottom by Hockuba.Krzysztof October 12, 2018 at 8:06 AM)

https://community.st.com/s/question/0D50X00009XkeZ4SAJ/stm32l4-sdmmc-command-timeout?t=1569885552908

Sir

Can you share config in stmcubemx and source code, please...

I can mount the sd card, but can't create a file

my code like this

 if(f_mount(&SDFatFS, SDPath, 0) != FR_OK){

    printf("Failed to mount sd card\n");

 }else{

    printf("mounting sd card successfully\n");

    if(f_open(&SDFile, "test.txt", FA_CREATE_ALWAYS | FA_WRITE) == FR_OK){

       printf("File has created\n");

    }else{

       printf("Failed to create file\n");

    }

 }

thanks sir

Sorry not using CubeMX

Probably not an issue with top level code, need to review interface level code.​

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

Hi @developer2​ !

Have you managed to make any workaround?