STM32CubeF1 icon indicating copy to clipboard operation
STM32CubeF1 copied to clipboard

MMC HAL driver fails to init

Open jhansen3141 opened this issue 4 years ago • 3 comments

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;
  }

jhansen3141 avatar Oct 07 '21 20:10 jhansen3141

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,

RKOUSTM avatar Oct 19 '21 09:10 RKOUSTM

ST Internal Reference: 110782

RKOUSTM avatar Oct 19 '21 09:10 RKOUSTM

Duplicate of STM32CubeF4#73.

RKOUSTM avatar Oct 19 '21 10:10 RKOUSTM

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,

RJMSTM avatar Apr 27 '23 16:04 RJMSTM