Skip to main content
auraner
Associate II
July 3, 2019
Question

Sporadic SDMMC_ERROR_CMD_RSP_TIMEOUT using FatFS + SDIO + DMA

  • July 3, 2019
  • 8 replies
  • 3816 views

Hi all,

I am trying to write to SD Card through SDIO interface with DMA (1 data line) on a STM32F4 MCU on a custom made board. Configuration is done by CubeMX.

When writing to one file at a rate of 200kBytes every 10 seconds, after some time (one minute to ten minutes), the driver fails in SDMMC_GetCmdResp1() (file stm32f4xx_II_sd.h) with error code SDMMC_ERROR_CMD_RSP_TIMEOUT.

Following fixes have been tried out without success:

  • Lowering the clock speed from 45MHz down to 1.4 MHz
  • Increase the timeout in SDMMC_GetCmdResp1() from 1ms to 100ms
  • Enable SDIO HW flow control

Has anyone experienced this issue? Is there a workaround?

Thanks and best!

This topic has been closed for replies.

8 replies

dbgarasiya
Senior
September 13, 2019

Hello.

i am using same problem using stm32f779bi on also my custom board

have you any other idea to solve out this problem?

auraner
auranerAuthor
Associate II
September 13, 2019

Hi,

I introduced a fail-save machanism, that simply remounts the SD Card in case of any error and rewrites the data... Not the proper way to go, more like a work-around. We will try to reduce SDIO line length in a new PCB version and investigate the error at that point.

If you have any news, please let me know.

Best,

dbgarasiya
Senior
September 14, 2019

Thansks for replying @auraner

i will try your way to get working of this problem

i will definately let you know if i get any other information about this problem

Thanks again

dbgarasiya
Senior
September 16, 2019

Hi,

I am not getting solution of above mentioned problem eventhough applying ideas which you have suggest

if there any changes required for this

I am attaching my project with this

Thanks

Hoddy
Associate II
January 6, 2020

For me, this was solved by setting all pins in HAL_SD_MspInit function to GPIO_PULLUP

auraner
auranerAuthor
Associate II
January 8, 2020

Thanks for your answer @Hoddy​, unfortunately it does not solve our issue...

Gleb Zaitsev
Visitor II
January 23, 2024

Hi all.

I had a similar problem. The SD state before the write call was HAL_SD_CARD_PROGRAMMING. I added a state check and now everything works fine.

HAL_SD_CardStateTypeDef state ;
do
{
 state = HAL_SD_GetCardState(&hsd);
}
while (state == HAL_SD_CARD_RECEIVING || state == HAL_SD_CARD_SENDING || state == HAL_SD_CARD_PROGRAMMING);

sd_state = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*) pData, WriteAddr, NumOfBlocks);

Best