This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

EFS fopen in read mode wont work

I am using a SPI NOR Flash (AT45DB641E) with Keil MDK5 Flash File System v6.8 and EFS.
Init, Mounting and formatting works. Even "finfo()" works an delivers information about FS and overall flash size of 8MB.
But creating a file and then re-open it in read mode doesnt work. Like shown in this snippet:

file = fopen("reinhard.keil","w"); // open file in write mode
if(file != NULL)
   printf("Success: created \"reinhard.keil\" \r\n");  // this works!

if(fputs("This is an example for fputs.\n", file) >=0) // write a string to file
   printf("Success: wrote string to file \"reinhard.keil\" \r\n"); // this works too!

if(fclose(file)==NULL) // close file
   printf("Success: file \"reinhard.keil\" closed\r\n"); // this also works!

file = fopen("reinhard.keil","r");    // (re)open file in read mode
if(file == NULL)
{
   printf("Error: failed to re-open \"reinhard.keil\" \r\n"); // Hmmm, why is that?
   fsStat = ffind("reinhard.keil", &fsFileInfo); // lets look for this file
   if(fsStat != fsOK)
      printf("Can't find file"); // file still not present
}

What am i doing wrong? I already worked with Keil FS, but with SD-Card and FAT32...and it was doing well. Am I missing something with EFS? I know about the EFS-limitations, but I think I avoided them.

Parents Reply Children