AnsweredAssumed Answered

Bug report: STM32CubeMX 4.23 SD_initialize

Question asked by Hector Fernandez on Oct 26, 2017
Latest reply on Dec 7, 2017 by Amel N

As I explaned inBug report: STM32CubeMX 4.23 MX_RTC_Init, I have found another big error in the code generation of STM32CubeMX 4.23.

In this case, the bug is related to FATFS + SDMMC. In my case, I am working with an STM32F767 microcontroller.

 

I updated an old project to change some config settings, and when I regenerated the project files with STM32CubeMX 4.23, my SDMMC peripheral stopped working correctly. So far, it was working nice with the code generated by an older version of STM32CubeMX.

So, (thanks to GIT) I checked which files changed since last release, and I noticed that the problem was in  "SD_initialize" function in "sd_diskio" file (inside Src folder).

The code that the newest version generates is:

 

DSTATUS SD_initialize(BYTE lun)
{
     return SD_CheckStatus(lun);
}

 

but, the same functions was different in my old code:

 

DSTATUS SD_initialize(BYTE lun)
{
     Stat = STA_NOINIT;

     /* Configure the uSD device */
     if(BSP_SD_Init() == MSD_OK)
     {
           Stat &= ~STA_NOINIT;
     }

     return Stat;
}

 

It is easy to understand that the difference between the new version and the old one is the lack of BSP_SD_Init(). This function isn't called in any other place but SD_initialize(). So, that is the reason because SDMMC stopped working.

 

Changing this piece of code in my new code solved all the problems and everything works as expected again.

 

Please, solve this bug in the next release. So far, I have found out 2 bugs in less than 2h. 

Outcomes