cancel
Showing results for 
Search instead for 
Did you mean: 

Version 6.15.0 Incorrectly Forces SD Initialization with FatFs Library

cvanbeek
Associate III

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:

cvanbeek_0-1753312529733.png

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.

cvanbeek_1-1753312667573.png

cvanbeek_2-1753312697411.png

I'm using an STM32H7B3.  I attached an example ioc file that shows this issue.  The code was correct in version 6.14

 

5 REPLIES 5
Souhaib MAZHOUD
ST Employee

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.

VojtechD
Associate

Hello  @Souhaib MAZHOUD , 

Any news on this? I would also be interessted in the information you might have. 

 

Best regards

Hello @VojtechD 

This topic has been discussed in this community thread and it is a normal behavior.

BR, 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.

cvanbeek
Associate III

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

 

VojtechD
Associate

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