2025-07-23 4:30 PM
When I upgraded to STM32CubeMx version 6.15.0, my project that uses FatFs added a call to HAL_SD_Init() inside MX_SDMMC1_SD_Init() when I regenerated code:
This is incorrect behavior because the FatFs library calls HAL_SD_Init() from BSP_SD_Init if the SD card is present, based on the configured Detect_SDIO pin in the CubeMx Platform settings. The newly generated code in version 6.15 causes the ErrorHandler() to be called on power-up if there is no SD card attached.
I'm using an STM32H7B3. I attached an example ioc file that shows this issue. The code was correct in version 6.14
2025-07-29 3:49 AM - edited 2025-07-29 3:50 AM
Hello @cvanbeek
Thank you for bringing this issue to our attention. I am currently checking this issue internally.
I'll get back to you as soon as possible.
KR,
Souhaib
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-10-30 7:53 AM
Hello @Souhaib MAZHOUD ,
Any news on this? I would also be interessted in the information you might have.
Best regards
2025-10-31 2:26 AM - edited 2025-10-31 2:27 AM
2025-10-31 7:59 AM
Hello @Souhaib MAZHOUD,
This shouldn't be normal behavior. Many systems are designed so that SD cards are removable media. A missing SD card should not halt the entire system, especially since the functionality to detect its presence is already built into the FatFs library. At a bare minimum, the new HAL_SD_Init() lines should go inside a user code section the first time the file is generated. Then, I would only need to remove the incorrect code once instead of every time I regenerate the CubeMx code.
The other thread doesn't explain why this new code is the normal behavior. It just gives debugging instructions for figuring out where the code entered the ErrorHandler(). I already know where it does that; in the new lines of code ST added to MX_SDMMC1_SD_Init(). Please revert this behavior and let the FatFs BSP handle SD initialization again.
Best regards,
Cory
2025-10-31 8:06 AM
Hi again,
I had to manualy put the HAL_SD_Init() in the user section, because it is not being called, instead the HAL_SD_MspInit() is called. Without the HAL_SD_Init() function (which itself is calling the MspInit function) it didn't work at all. Now I'm not getting errors right at the start.
BR