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.
Solved:
The hint "Are you sure that your SPI driver is functioning fine?" was after all the right one. As I wrote: In RTE_Device.h I assigned SPI2-NSS-Pin to PB9. But it is possible to edit the RTE_Device.h in the way, that I can now select the PD4-GPIO in the Dropout-Menu. So the SPI-Driver now gets the right NSS/CS Pin and the Flash-Driver will toggle it automatically as it is meant to. BUT: it was confusing to not get any Error-Return from the Keil Flash-Driver or the File System. In previous versions it was possible the use File System with Debug option and the Compiler DAP Event Messaging (selected in the "Manage Run-Time-Environment" under "LFN Debug"). But this option is not present in Middleware V7.2