cancel
Showing results for 
Search instead for 
Did you mean: 

Can't initialize SDMMC on stm32h757i-eval

Matteo-uC
Visitor

Hello,

I am using a STM32H757-i eval board. 

I created a project through file >> new stm32 project, selected my board, then generated code.

However, I am going into error handler when initializing the SDMMC.

 

My path to go to error handler :

 

  MX_SDMMC1_SD_Init();
  if (HAL_SD_Init(&hsd1) != HAL_OK)
  {
    Error_Handler();
  }
  /* Initialize the Card parameters */
  if (HAL_SD_InitCard(hsd) != HAL_OK)
  {
    return HAL_ERROR;
  }
  errorstate = SD_PowerON(hsd);
  if (errorstate != HAL_SD_ERROR_NONE)
  {
    hsd->State = HAL_SD_STATE_READY;
    hsd->ErrorCode |= errorstate;
    return HAL_ERROR;
  }
  errorstate = SDMMC_CmdGoIdleState(hsd->Instance);
  /* CMD8: SEND_IF_COND: Command available only on V2.0 cards */
  errorstate = SDMMC_CmdOperCond(hsd->Instance);
  errorstate = SDMMC_GetCmdResp7(SDMMCx);
uint32_t SDMMC_GetCmdResp7(SDMMC_TypeDef *SDMMCx)
{
  uint32_t sta_reg;
  /* 8 is the number of required instructions cycles for the below loop statement.
  The SDMMC_CMDTIMEOUT is expressed in ms */
  uint32_t count = SDMMC_CMDTIMEOUT * (SystemCoreClock / 8U / 1000U);

  do
  {
    if (count-- == 0U)
    {
      return SDMMC_ERROR_TIMEOUT;
    }
    sta_reg = SDMMCx->STA;
  } while (((sta_reg & (SDMMC_FLAG_CCRCFAIL | SDMMC_FLAG_CMDREND | SDMMC_FLAG_CTIMEOUT)) == 0U) ||
           ((sta_reg & SDMMC_FLAG_CMDACT) != 0U));

  if (__SDMMC_GET_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT))
  {
    /* Card is not SD V2.0 compliant */
    __SDMMC_CLEAR_FLAG(SDMMCx, SDMMC_FLAG_CTIMEOUT);

    return SDMMC_ERROR_CMD_RSP_TIMEOUT;
  }

So having SDMMC_ERROR_CMD_RSP_TIMEOUT as error.

 

I tried both of theses solutions, both didn't work :

https://community.st.com/t5/stm32-mcus-embedded-software/stm32h757i-eval-sd-card-does-not-seem-to-be-recognized/m-p/151848#M8777

https://community.st.com/t5/stm32-mcus-products/stm32h757i-eval-sdmmc-initialization-problem/m-p/707296#M257413

Would you have ideas to debug it ?

Best Regards

Matteo

1 REPLY 1

@Matteo-uC what firmware are you using? (Project Manager, Project, Mcu and Firmware Package)

I'm having a very similar issue with a U5 processor, the issues may be connected.