stm32l4xx_hal_driver icon indicating copy to clipboard operation
stm32l4xx_hal_driver copied to clipboard

Wrong timeout value in SDMMC_DATATIMEOUT for stm32l4xx_hal_sd.c

Open SebastianSonntagBender opened this issue 7 months ago • 3 comments

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.

SebastianSonntagBender avatar Sep 04 '25 14:09 SebastianSonntagBender

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,

KRASTM avatar Sep 09 '25 08:09 KRASTM

ST Internal Reference: 143350

KRASTM avatar Sep 09 '25 08:09 KRASTM

ST Internal Reference: 222274

MKISTM avatar Nov 26 '25 14:11 MKISTM