2023-01-25 01:40 AM
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?
2023-04-07 06:32 AM
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