cancel
Showing results for 
Search instead for 
Did you mean: 

bug in stm32CubeMX for SDIO 4bit

kshin.111
Associate III

stm32cubeMX have bug in SDIO 4bit

i use stm32f407vg, stm32CubeMX ver 5.4.0

in use 1 bit true work but 4bit not working.

this code generate for SDIO mode: SD 1 bit

/**
  * @brief SDIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_SDIO_SD_Init(void)
{
 
  /* USER CODE BEGIN SDIO_Init 0 */
 
  /* USER CODE END SDIO_Init 0 */
 
  /* USER CODE BEGIN SDIO_Init 1 */
 
  /* USER CODE END SDIO_Init 1 */
  hsd.Instance = SDIO;
  hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
  hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
  hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
  hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
  hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
  hsd.Init.ClockDiv = 4;
  /* USER CODE BEGIN SDIO_Init 2 */
 
  /* USER CODE END SDIO_Init 2 */
 
}

and this code generate for SDIO mode: SD 4 bit Wide bus

/**
  * @brief SDIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_SDIO_SD_Init(void)
{
 
  /* USER CODE BEGIN SDIO_Init 0 */
 
  /* USER CODE END SDIO_Init 0 */
 
  /* USER CODE BEGIN SDIO_Init 1 */
 
  /* USER CODE END SDIO_Init 1 */
  hsd.Instance = SDIO;
  hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
  hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
  hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
  hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
  hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
  hsd.Init.ClockDiv = 4;
  /* USER CODE BEGIN SDIO_Init 2 */
 
  /* USER CODE END SDIO_Init 2 */
 
}

Line 20 in two code equal, And, of course, there are some bug in sub-functions in mode 4bit wide bus.

1 ACCEPTED SOLUTION

Accepted Solutions
Khouloud ZEMMELI
ST Employee

​This was already added to the code in your case :

 if (HAL_SD_Init(&hsd) != HAL_OK)

{

Error_Handler();

}

 if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)

{

Error_Handler();

}

After discussion with the team , the SDIO shall start with 1 bit then it will be switched to be compatible with your config.

Best Regards,

Khouloud.

View solution in original post

6 REPLIES 6
Khouloud ZEMMELI
ST Employee

​Hello @kshin.11​ ,

Could you please give me more info about the part number and version of CubeMX? or share your ioc file please.

Thanks,

Khouloud

Khouloud ZEMMELI
ST Employee

​sorry @kshin.11​  I saw those info now, I will check it.

Khouloud ZEMMELI
ST Employee

Issue reproduced, it will be fixed in the next release.

Thanks @kshin.11​ for your feedback.

Best Regards,

Khouloud​

Khouloud ZEMMELI
ST Employee

​This was already added to the code in your case :

 if (HAL_SD_Init(&hsd) != HAL_OK)

{

Error_Handler();

}

 if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)

{

Error_Handler();

}

After discussion with the team , the SDIO shall start with 1 bit then it will be switched to be compatible with your config.

Best Regards,

Khouloud.

kshin.111
Associate III

Thanks @Khouloud Zemmeli for the quick reply.

Ajrekom enda Allah

Dear Zemmeli,

i'm using cubeMX 5.4.0.

As your answer, I need to add your script to your code.

Could you show me detail where to add ?

Which function ? which file ?

Thank you very much