STM32CubeF1
STM32CubeF1 copied to clipboard
MMC HAL driver fails to init
The current MMC HAL driver fails to init due to not selecting the card before attempting to read the extended CSD register.
In MMC_InitCard in stm32f1xx_hal_mmc.c, the HAL_MMC_GetCardCSD function is called which in turn calls MMC_ReadExtCSD attempting to read the extended CSD register. However, this is done before the call to select the card which causes the MMC_ReadExtCSD function/command to fail. This appears to be an issue in several device HAL drivers in addition to the F1.
Current code in MMC_InitCard:
/* Get CSD parameters */
if (HAL_MMC_GetCardCSD(hmmc, &CSD) != HAL_OK)
{
return hmmc->ErrorCode;
}
/* Select the Card */
errorstate = SDMMC_CmdSelDesel(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U));
if(errorstate != HAL_MMC_ERROR_NONE)
{
return errorstate;
}
Change needed for fix in MMC_InitCard:
/* Select the Card */
errorstate = SDMMC_CmdSelDesel(hmmc->Instance, (uint32_t)(((uint32_t)hmmc->MmcCard.RelCardAdd) << 16U));
if(errorstate != HAL_MMC_ERROR_NONE)
{
return errorstate;
}
/* Get CSD parameters */
if (HAL_MMC_GetCardCSD(hmmc, &CSD) != HAL_OK)
{
return hmmc->ErrorCode;
}
Hi @jhansen3141,
Thank you for your contribution. You are absolutely right about this point.
Actually, the point you raised has already been dealt and fixed internally. The fix will be made available in the frame of a future release.
Thank you again for your contribution. We are looking forward to reading from you again.
With regards,
ST Internal Reference: 110782
Duplicate of STM32CubeF4#73.
Hello @jhansen3141
Thank you again for having reported this point. It has been fixed in the frame of version 1.8.5 of this firmware.
With regards,