2

I've got some problems with the FATFs library and the STM32F7 Series. I want to connect a SD-Card (32GB, SanDisk, FAT32) with the F746G-Discovery-Board to save some data on it. (at first .txt-Files, later read .csv Files to visualize some measuring data).

My problem is, that the f_mount function gives me a "FR_OK" but in the next step I can't open a file with f_open. I located the problem by debugging step by step. It's in the ff.c file of the FatFs lib.

res = find_volume(&path, &fs, mode); 

At this point the program stops. jumping into the function the problem is following line

stat = disk_initialize(fs->drv);    /* Initialize the physical drive */  

So the SD-Card is not initialized/mounted? But why does the f_mount giving me the FR_OK?

It would be really nice if someone could help. Thanks!

I tried following things:

-formatted SD-Card (exFat,..)

-other Paths

in main:

FIL fil;

FRESULT fr;

FATFS FatFs;

fr=f_mount(&FatFs,(TCHAR const*)SDPath,1);

if(fr!= FR_OK)
{
    Error_Handler(); 
}

else if (fr == FR_OK)
{
      char path[13] = "testfile.txt";
      fr = f_open(&fil, (char*)path, FA_WRITE | FA_CREATE_ALWAYS);
      // File should be created
      //here begins the main problem

  if ( fr == FR_OK ) // File opened
  {
       f_printf(&fil, "%d", 1234);
  }
    else if (fr != FR_OK)
    {
    Error_Handler();
    }
}

f_close(&fil);
f_mount(0,"SD",0);
Melissa123
  • 55
  • 1
  • 10
  • I'm guessing that you didn't implement the `disk_*` functions. Look inside of them and then the question is: does the [`disk_initialize`](http://elm-chan.org/fsw/ff/doc/dinit.html) function initialize the communication with the SD card? If not then that is where you should start. These functions should be located inside `diskio.c` and are the interface used by fatfs. – Tarick Welling Oct 21 '19 at 14:03
  • Thanks for the answer. The disk_initialize function worked. It was a problem with the hardware configurations. – Melissa123 Oct 28 '19 at 09:20
  • 2
    Please add an answer to your own question so you can close it if you have resolved it with the solution to your problem. – Tarick Welling Oct 28 '19 at 09:23

0 Answers0