Skip to main content
kshin.111
Associate III
October 31, 2019
Solved

bug in stm32CubeMX for SDIO 4bit

  • October 31, 2019
  • 6 replies
  • 1714 views

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.

This topic has been closed for replies.
Best answer by Khouloud ZEMMELI

​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.

6 replies

Khouloud ZEMMELI
ST Employee
October 31, 2019

​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
October 31, 2019

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

Khouloud ZEMMELI
ST Employee
October 31, 2019

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

Thanks @kshin.11​ for your feedback.

Best Regards,

Khouloud​

Khouloud ZEMMELI
Khouloud ZEMMELIBest answer
ST Employee
October 31, 2019

​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.

Le Loc - Duc
Associate II
May 13, 2020

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

kshin.111
kshin.111Author
Associate III
November 1, 2019

Thanks @Khouloud Zemmeli for the quick reply.

Ajrekom enda Allah