Skip to main content
FRugi.1
Visitor II
Dec 23, 2022 1:49 PM UTC
Solved

MX_SDIO_SD_Init wrong bus wide initialization

I have a STM32F407 with an SD card wired in 4-bytes mode and FATFS middleware to manage the files.

I upgraded to STM32CubeIDE 1.11 two weeks ago, but since then the SD card stopped working. The initialization fails in the SD_WideBus_Enable function, since scr[1] is read as 0 (file stm32f4xx_hal_sd.c).

I noticed that this behavior disappears when I set hsd.Init.BusWide = SDIO_BUS_WIDE_1B in MX_SDIO_SD_Init (file sdio.c). This, however, was changed in SDIO_BUS_WIDE_4B in the newer version of the IDE, breaking the functionality.

I was not able to check whether the SD actually works in 4-bits mode when initialized to SDIO_BUS_WIDE_1B, but I think so, since the HAL_SD_ConfigWideBusOperation gets called with 4 bytes.

So, is it correct to continue using SDIO_BUS_WIDE_1B? If so, how can I preserve it, since every time I let Cube to generate the files the modification gets overwritten?

This topic has been closed for replies.
Amel NASRI
Amel NASRIBest answer
ST Technical Moderator
Jan 2, 2023 2:31 PM UTC

Hi @FRugi.1​ & @DDi S.1​ ,

An explanation of what was updated is provided by @Ghofrane GSOURI​ in this thread: SDCARD does not work (FR_NOT_READY) when migrating from FW_F4 V1.27.0 to newer FW_F4 V1.27.1.

Could you please refer to it?

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.

3 replies

DDi S.1
Associate III
Dec 26, 2022 2:47 PM UTC

Hi.

I did it this way and I hope it helps you.

in main.c put the following line:

/* USER CODE BEGIN 2 */

 hsd.Init.BusWide = SDIO_BUS_WIDE_1B;

Amel NASRI
Amel NASRIBest answer
ST Technical Moderator
Jan 2, 2023 2:31 PM UTC

Hi @FRugi.1​ & @DDi S.1​ ,

An explanation of what was updated is provided by @Ghofrane GSOURI​ in this thread: SDCARD does not work (FR_NOT_READY) when migrating from FW_F4 V1.27.0 to newer FW_F4 V1.27.1.

Could you please refer to it?

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Visitor II
Oct 30, 2023 3:43 AM UTC

thunks, however you are!!