AnsweredAssumed Answered

SD and FATFS on STM32F7xx issue with card init, how to change the source files for CubeMX

Question asked by Stefan Müller on Oct 30, 2017
Latest reply on Jan 10, 2018 by Stefan Müller

Hi to everyone,

 

I just bought STM32F769 Disco Board as platform to develop SW for my next project. I'm using CubeMX 4.23, F7xx FW package 1.8.0 and latest SW4STM32. For the CubeMX I was choosing the processor type and not the Disco Board as later on it will be an own PCB and I wanted to be as much independent as possible.

 

As I tried to get SD Card and FAT FS running I realized that Disk Init and therefore Hardware init on the MCU seems to go wrong. I debugged it down and found 2 issues in the code generated by CubeMX:

 

First is very simple as the card detect pin needs to be inversed in the fatfs_platform.c file to fit the Disco Board.

 

Second issue is that the SD_initialize function of sd_diskio.c just does nothing (ok it calls CheckStatus but doesn't init anything)

Therefore I modified from original code:

/**

* @brief Initializes a Drive

* @param lun : not used

* @retval DSTATUS: Operation status

*/

DSTATUS SD_initialize(BYTE lun)

{

return SD_CheckStatus(lun);

}

 

 

to:

 

/**
  * @brief  Initializes a Drive
  * @param  lun : not used
  * @retval DSTATUS: Operation status
  */
DSTATUS SD_initialize(BYTE lun)
{
 Stat = STA_NOINIT;

 if(BSP_SD_Init() == MSD_OK)
 {
  return SD_CheckStatus(lun);
 }

 return Stat;
}

 

So far it works all fine...

Now my questions:

 

1: Was this the right way to solve it or did I oversee something?

2: How/where can I Change the source files for the CubeMX so that after newly generating the Project files my changes are kept? I was looking for the .c files in the FW package but there are everywhere in  the examples but nowhere seems to be a source Location for the cubeMX....

 

 

Thanks in advance

 

Stefan

Outcomes