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.
Just to inform others who may have the same problems:
I got some proper information from keil support , that the issue is due to the ECC of the LPC2378 flash memory.
So I made some tests writing data with inbuild IAP routine of the LPC2378 and read it again. So my current result is that the first writing to a position works, but the second write doesn't work. So it seems the IAP routine doesn't work properly and so it's not possible for the filesystem to write the data correctly to the internal flash of the LPC2378.
Rainer, followed is some advices, can be useful: -make sure you read errata sheet for your chip. Some manufacturers does not provides programming internal flash on max speed. -try use fwrite and fread functions instead fprintf and fgetc. -make sure you include "retarget.c" file in project. -try start using file system in RAM memory first, then move to flash.
Mikhail Sokolov,
thanks for hints!
I contacted the support of NXP, now. To get some more information about the problem with the IAP routine. But this will take some time.
LPC2148 uses ECC flash data protection algorithm. This means it has a hidden byte where a control code for the flash page is stored. Based upon this data, an automatic error correction of a few bits in a page is possible. This makes the flash data reliability much better, but on the other hand has a side effects. You can not write tha flash page twice, this means you must write the whole page only once and then erase the whole sector. I think that one page is 16 (or maybe 32) bytes. IAP routines are able to write only 512/1024 byte blocks.
Flash File System does not work with ECC pages so this is the reason it is unusable for internal flash on devices using ECC.
hello Rainer, did you got some information from keil suport? because i also got some problems with the flashfile system and the internal flash! So if you got new information could you post it please. thanks ROmain
Hello MOURA Romain,
as I already posted on 13-Feb-2007 04:04 in my case the problem is the ECC Code of the internal flash memory of the LPC23xx. It's like Franc Urbanc wrote above. To write some bytes to the flash, the whole sector must be erased before you can write one time. To write again somewhere to this sector the sector must be erased again. So it's impossible to use the internal flash memory of the LPC23xx as fast working flash filesystem.
So you need some kind of external flash memory without ECC when you use an LPC23xx.
Rainer