Wrong timeout value in SDMMC_DATATIMEOUT for stm32l4xx_hal_sd.c
In HAL version 1.18.1 in the file stm32l4xx_hal_sd.c are multiple occasions if the following code:
if((HAL_GetTick() - tickstart) >= SDMMC_DATATIMEOUT)
{
return HAL_SD_ERROR_TIMEOUT;
}
The problem with this is, that the macro SDMMC_DATATIMEOUT (stm32l4xx_ll_sdmmc.h) is defined with a value of ((uint32_t)0xFFFFFFFFU). This value is very large for a timeout value in milliseconds and is most certainly wrong.
Additionally, because its the maximum value for this data type, the left side of the comparation is likely to overflow if not checked at the right moment.
Hello @SebastianSonntagBender,
Thank you for the report.
Regarding the issue, it has indeed been spotted and fixed internally, and it's just a matter of time before it's published.
With regards,
ST Internal Reference: 143350
ST Internal Reference: 222274