AnsweredAssumed Answered

SD Card Cannot be mounted successfully using the Code generated by CubeMX

Question asked by Lingjun Kong on Jul 17, 2017
Latest reply on Jul 17, 2017 by Valentin

to use the FATFs on the STM32F746NG-Discovery Board, I generate the code using the CubeMX.

this is my main.c file.

during the debugging, I found that the value returned by the f_mount is FR_NOT_READY, so that the function will always fall into Error_Handle();

 

but with the same board and sd card, the demo project:

STM32Cube_FW_F7_V1.7.0\Projects\STM32746G-Discovery\Applications\FatFs\FatFs_uSD\MDK-ARM

it could work well.

 

I want to know whether there is any other thing I've forgot to add to the project? Or the code generator itself has a big bug?

 

the method i generate the code is:

 

  1. select the board

2. config the pinout

and choose the FATFS

3. resolve the clock

 

4.do nothing

5. change the heap size

7. and generate the project

 

8.open project and add this line to main.c

 

FATFS SDFatFs; /* File system object for SD card logical drive */
FIL MyFile; /* File object */
char SDPath[4]; /* SD card logical drive path */

 

if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 1) != FR_OK)
{
Error_Handler();
}

 

 

and rebuilt it, debug, falls into error_handle.

Outcomes