STM32L4: HAL_MMC driver - get stuck in MMC_ReadExtCSD()
I'm using STM32L4A6 and it's SDMMC peripheral to communicate with an eMMC device.
I found it occasionally get stuck in the MMC_InitCard() call. Further investigation shows it's stuck in the MMC_ReadExtCSD() call, where it utilizes a timeout value of 0x0FFFFFFF in a loop. (stm32l4xx_hal_mmc.c, line 3844). The timeout is measured by tick count. But with such a large number, what ever the unit for the tick is, this basically makes it an infinitive loop.
I experimented with a much smaller value, ie 1000 etc. It does get out of the loop with a timeout error. This triggers subsequent error handling. And once it got out, retry for once or twice usually can get it pass here.
My questions:
- What's the likely cause for the failure. The comment in MMC_ReadExtCSD() describes the block of code as 'poll on SDMMC flags'. So something is wrong.
- Why such a large value for timeout? Or it mean to be modified by developers? And what value is reasonable?
I'm using STM32 CubeL4 firmware package1.17.0 (and STM32L4xx HAL 1.13.0).
Thanks!
