Hello,
I'm writing this huge Forum request because the Keil support didn't answer my email support request in a proper way, yet. I'm a bit disappointed, so I hope somebody else might help me...Maybe I'm not the only one, who has problems with the flashfilesystem.
I want to use the flashfilesystem delivered with the RealTime Libary on the on the MCB2300 board (with LPC2378 from NXP). Using ARM-MDK (3.04) and RL-ARM (3.04).
First I'm describing my configuration of the FFS and after that I explain my problems.
The flashfilesystem should be placed in the upper 5 sectors of the internal flash of the microcontroller.
So this is my device configuration file FS_FlashDev.h:
... //Definition of the FlashSectors used by the Flash File System // DFB( size , baseadr ), /* Comment */ \ <-- macro continuation sign (Don't forget) #define FLASH_DEVICE \ DFB(0x001000, 0x000000), /* Sector Size 4kB */ \ DFB(0x001000, 0x001000), /* Sector Size 4kB */ \ DFB(0x001000, 0x002000), /* Sector Size 4kB */ \ DFB(0x001000, 0x003000), /* Sector Size 4kB */ \ DFB(0x001000, 0x004000), /* Sector Size 4kB */ \ // Number of previously defined sectors #define FL_NSECT 5
I setup the File_Config.c like this:
Flash Drive Option checked Target device Base address 0x0007 8000 Device Size in bytes 0x0001 0000 CPU Clock Frequency[Hz] 48000000 Initial Content of Erased Memory 0xFF Device Description File FS_FlashDev.h Default Drive: Flash
Comment: I'm not sure if I configured the Target device Base address correctly. According to the documentation it specifies the device base address in the memory space of ARM processor I guess in my case it's the absolute starting address of the first Sector defined in the FS_FlashDev.h.
I finally added the IAP.s file for calling the IAP routine of the microcontroller and the RTLFS.lib. Everything was compiled, linked and loaded to the MCB2300 board.
I created a simple testing programm:
... int main (void) { FILE *filehandle; int ch,i; ... printf ("Initialize Flash File System..."); i = finit(); if( i != 0 ) { printf ("(finit = %d)Failed\n",i); } else { printf ("(finit() = %d)OK\n",i); } printf("Formatting Flash File System..."); if ( fformat ("F:") != 0 ){ printf ("Failed\n"); }else{ printf ("OK\n"); } printf("Writing a small Testfile..."); filehandle = fopen ("F:Test.txt","w"); if (filehandle == NULL) { printf ("File not found!\n"); }else { printf("File opened..."); printf("%d Bytes written to File...", fprintf( filehandle, "0123456789" )); fclose ( filehandle ); printf("File closed\n"); } printf("Read back the written File..."); filehandle = fopen ("F:Test.txt","r"); if (filehandle == NULL) { printf ("File not found!\n"); }else { printf("File opened..."); // Read all characters from the file while ( !feof (filehandle) ) { ch = fgetc ( filehandle ); printf("%c", ch ); if ( ferror (filehandle)) { printf ("File read error..."); break; } } fclose ( filehandle ); printf("File closed\n"); } printf ("Checking Flash File System..."); if (fcheck ("F:") != 0) { printf ("Failed\n"); printf ("Flash File System inconsistent, formatting..."); } else { printf ("OK\n"); } while(1); }
So I have the following result: 1. finit returns with "(finit() = 1)Failed"
2. fformat returns with "OK"
3. Writing to file is working. When I set a breakpoint in debugging mode after closing the written file, the correct filename is displayed in the Peripheral->RTX-Kernel->Flashfilesystem tab. When I check the memory position of the first sector, I can see the data written to the flash.
4. Reading the file doesn't work correctly. It doesn't read anything useful, because it seems to read from the wrong position and so it could not detect the file end and is reading without stopping...
So I would be happy, if anybody can give me some hints, what I have done wrong.
Thank you to all the people taking the time to read this text to help me....
Rainer