stm32l5xx_hal_mmc.c driver crashing non-deterministically
When trying to read/write to the connected eMMC device, the eMMC driver will sometimes fail with an error. After failing in this way, every call to HAL_MMC_ReadBlocks or HAL_MMC_WriteBlocks will fail until the microcontroller is restarted.
If the first call in a series of reads succeeds, all following calls will complete without issue *UNLESS* the following calls are to a non-sequential part in eMMC memory, in which case they might fail.
A partial work-around I’ve found is to put HAL_Delay calls before each call to the eMMC memory, but this does not always work.
Similarly, running in debug mode and walking slowly through the process will always work. And then following calls at high-speed run without issue.
The HAL_MMC_GetCardState function always returns a 4 - HAL_MMC_CARD_TRANSFER. If I try to wait for the cardstate to become HAL_MMC_CARD_READY before making a call, it will stall indefinitely.
My hypothesis is that the stm32l5xx_hal_mmc driver is not correctly reading the eMMC card state. And therefore is not correctly waiting for the eMMC memory to be ready for a transmission before trying to send/receive data.
Because the card I’m using has a small processor and optimizes the speed for sequential blocks, it may be the case that I only see issues in non-sequential because they take longer, and the card isn’t ready for the new command somehow.
I’ve not been able to find any documentation on this issue, any assistance would be greatly appreciated.
