cancel
Showing results for 
Search instead for 
Did you mean: 

SDMMC init error since STM32CubeIDE 1.11.0 update

Brieuc
Associate II

There is a newly introduced bug in the freshly upgraded package coming with the IDE 1.11. MX_SDMMC1_SD_Init(void) does not configure hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B but directly to the final state choosen in CubeMX (in my case 4B). But the SD requires to be started and configured with 1B before switching to the final configuration. Forcing manually to 1B makes the job, but CubeMX changes it back to 4B after each generation. The easy workaround is to force 1B in the user code at the end of SD_init function.

Could you confirm this is a bug and roll back to the correct version ?

9 REPLIES 9
Diane POMABIA
ST Employee

Hi @Brieuc​ ,To confirm this bug , can you give me more detail about your workspace? Name of board?

Regard,

Diane P

Brieuc
Associate II

Hi Diane,

I use a custom board with a standard 4-wire SD connection driven by a STM32L476RGT6. The workspace has been upgraded from IDE 1.10 to 1.11 today. Do you need more details ?

fabio239955
Associate II

Hi Diane, Brieuc

I confirm the bug. A previous version of STM32CUBE used to generate code like this:

 hmmc1.Instance = SDMMC1;
 hmmc1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
 hmmc1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
 hmmc1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
 hmmc1.Init.BusWide = SDMMC_BUS_WIDE_1B; //<< OK it works
 hmmc1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
 hmmc1.Init.ClockDiv = 0;
 if (HAL_MMC_Init(&hmmc1) != HAL_OK)
 {
   Error_Handler();
 }
 if (HAL_MMC_ConfigWideBusOperation(&hmmc1, SDMMC_BUS_WIDE_4B) != HAL_OK)
 {
   Error_Handler();
 }

now Version: 1.11.2 generates code like this:

 hmmc1.Instance = SDMMC1;
 hmmc1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
 hmmc1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
 hmmc1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
 hmmc1.Init.BusWide = SDMMC_BUS_WIDE_4B; //<< WRONG!!!
 hmmc1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
 hmmc1.Init.ClockDiv = 0;
 if (HAL_MMC_Init(&hmmc1) != HAL_OK)
 {
   Error_Handler();
 }
 if (HAL_MMC_ConfigWideBusOperation(&hmmc1, SDMMC_BUS_WIDE_4B) != HAL_OK)
 {
   Error_Handler();
 }

I use a custom board with a standard 4-wire SD connection to a STM32L4; please find schematic in attachment

fabio239955
Associate II

attaching the .IOC file as well for your convenience

AScha.3
Chief II

but on my H743 sd-init is (always, i did not update now)

always working fine. so 4-bit mode is not the problem here.

  hsd1.Instance = SDMMC1;
  hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
  hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_ENABLE;
  hsd1.Init.BusWide = SDMMC_BUS_WIDE_4B;
  hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE;
  hsd1.Init.ClockDiv = 1;
  /* USER CODE BEGIN SDMMC1_Init 2 */
  if (HAL_SD_Init(&hsd1) != HAL_OK)
  {
     Error_Handler();
   }

sdmmc clk is 100MHz .

If you feel a post has answered your question, please click "Accept as Solution".
Diane POMABIA
ST Employee

Hi @Brieuc​ @fabio239955​ @AScha.3​ 

Thanks you for your feedback.

Can you give me you STM32CubeMx version ?

I'm escalating the problem to the relevant team so that it can be resolved.

Regards

DianeP

Thanks Dianep

My current STM32CubeIDE (with bug) is Version: 1.11.2 Build: 14494_20230119_0724 (UTC).

In April 2022 I was using a different version and it worked properly – non such a bug. I do not know the version. It was the latest available vestion at thet time.

With best regards

Fabio

AScha.3
Chief II

hi,

i am using :

STM32CubeIDE

Version: 1.10.1

Build: 12716_20220707_0928 (UTC)

OS: Linux, v.4.19.0-1-amd64, x86_64 / gtk 3.22.11

Java vendor: Eclipse Adoptium

Java runtime version: 11.0.14.1+1

Java version: 11.0.14.1

+

STM32CubeMX - STM32 Device Configuration Tool

Version: 6.6.1-RC2

Build: 20220706-1420 (UTC)

If you feel a post has answered your question, please click "Accept as Solution".

I can confirm the bug. Custom board with F746 chip, 4-bit SD card, FatFS(!). Version 1.10.1 of CubeIDE  generated this code:

 

static void MX_SDMMC1_SD_Init(void) {

/* USER CODE BEGIN SDMMC1_Init 0 */
/* USER CODE END SDMMC1_Init 0 */
/* USER CODE BEGIN SDMMC1_Init 1 */
/* USER CODE END SDMMC1_Init 1 */
 hsd1.Instance = SDMMC1;
 hsd1.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
 hsd1.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
 hsd1.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
 hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B;  //! 1 bit here
 hsd1.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
 hsd1.Init.ClockDiv = 1;

/* USER CODE BEGIN SDMMC1_Init 2 */
if (HAL_SD_Init(&hsd1) != HAL_OK) {
 Error_Handler();
 }
if (HAL_SD_ConfigWideBusOperation(&hsd1, SDMMC_BUS_WIDE_4B) != HAL_OK) {  //! 4 bit here
 Error_Handler();
 }
/* USER CODE END SDMMC1_Init 2 */
}

 

and everything worked as expected.

 

Newer versions of CubeIDE (1.12.1 and 1.13.0) generate the same code but with 4 bit constant in both places. And firmware simply hangs. Please return it to working state.