cancel
Showing results for 
Search instead for 
Did you mean: 

Sporadic SDMMC_ERROR_CMD_RSP_TIMEOUT using FatFS + SDIO + DMA

auraner
Associate II

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!

8 REPLIES 8
dbgarasiya
Senior II

Hello.

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

have you any other idea to solve out this problem?

auraner
Associate II

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 II

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 II

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

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

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

Thanks for your answer @Hoddy (Community Member)​, I just confirm:

pullup CMD pin (no matter, with GPIO_PULLUP or with external resistor) is enough.

Gleb Zaitsev
Associate

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