Skip to main content
Peter Hambly
Visitor II
January 25, 2023
Question

STM32U5 SDMMC HAL_SD_GetError() error HAL_SD_ERROR_RX_OVERRUN.

  • January 25, 2023
  • 1 reply
  • 1540 views

This is DMA error: SDMMC_ERROR_RX_OVERRUN meaning Receive FIFO overrun. This typically occurs after about 1 week of normal running. I have a test mode that simulates SD card usage to recreate 100 days of usage in 22 hours.

If the SD card is kept on, this fault does not occur, the filesystem is only mounted once. If the SD card is turned on and off in each simulated hour, the fault occurs in about 6-7 hours (c25 days of simulated usage:

SDMMC card setup:

hsd1.Instance = SDMMC1;

hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;

hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_ENABLE;

hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; // do not used SDMMC_BUS_WIDE_4B - you will get DMA errors

hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE;

hsd1.Init.ClockDiv = 1;

We could reduce the SDMMC bus speed by setting hsd1.Init.ClockDiv = 3; (16MHz). This is implied by https://community.st.com/s/question/0D53W000003vQI1SAM/rx-overrun-error-when-reading-blocks-from-usd-card-using-hal-driver. The SD card is already slower than the MSP432 driven SD card it replaces - this seems really slow.

When this fault occurs the device has to be rebooted. HAL_SD_deinit() then HAL_SD_Init() produces HAL_ERROR.

We are using FATFS and have noticed that using FATFs results in non 32 byte aligned reads https://community.st.com/s/question/0D50X00009XkWmRSAV/sd-card-memory-corruption-due-to-overly-aggressive-cache-maintenance?t=1612158756960. I should be able to fix this with compiler alignment directives.

Any other suggestions of approaches to fix this problem?

This topic has been closed for replies.

1 reply

Mohamed Aymen HZAMI
ST Employee
April 7, 2023

Hello @Peter Hambly​,

You can refer to the Firmware example under this path "STM32Cube\Repository\STM32Cube_FW_U5_V1.1.1\Projects\STM32U575I-EV\Examples\SD\SD_ReadWrite_DMALinkedList"

Try to follow the example SDMMC configuration.

Mohamed Aymen