I am on a ZedBoard and I am trying to write on an SD card. I am working on an embedded system and I dont have any OS, I am running baremetal.
I can read fine from the SD card, their is no problem.
But when I triy to read, I have some weird behaviour :
- f_write returns FR_OK
- The bw (bytes written) variable is correct
- The file is created (I can see it when I read the SD card from my PC)
But when I read the file, it is empty.
Here is my code :
void WriteFile(char const* fileName, char* buffer, size_t size)
{
FIL file;
FATFS fs;
UINT bw;
FRESULT fr;
f_mount(&fs, "", 0);
f_open(&file, fileName, FA_WRITE | FA_CREATE_ALWAYS);
fr = f_write(&file, buffer, size, &bw);
if (size != bw || fr != FR_OK)
PRINT(("Error in writing !\n"));
f_close(&file);
f_mount(NULL, "", 0);
}
And I call the method like this :
WriteFile("Hello.txt", "Hello World !", 13);
Any idea what I am doing wrong ?