[En-Nut-Discussion] How to format and use dataflash with RW file system...

Harald Kipp harald.kipp at egnite.de
Tue Jan 26 20:14:43 CET 2010


Ole Reinhardt wrote:

> A simple flash file system with ware leveling would be a real cool
> extension to NutOS :)

Indeed. Some time ago I spent more than a week to evaluate some ideas on
this topic. Gosh! The required bookkeeping is even more complicated than
the PHAT stuff.

In general most of the wear leveling file systems are based on
journaling. Modified sectors are not written back to their old location.
Instead a new sector is allocated for each update. Somehow you need to
mark the old sector outdated. During runtime you can use a table in RAM.
But somehow this table must be build again when rebooting the system.

An important thing to note is, that not the write access but the erase
outwears the flash. One funny method was to re-program the remaining 1s
in the first bytes of outdated sectors to zero. However, not all chips
like this second programming cycle without an initial erase cycle.

Another way is to add a revision number to each sector. During boot-up
the driver can locate outdated sectors by verifying these numbers.
Nevertheless, more tables are required to map hardware sectors to files.
 The standard rule applies here: Fast access requires more RAM.
Supporting a 2 Gig flash with an 8-bit AVR will become a challenge.

FAT works very well on systems with scarce memory resources. The problem
with FAT is, that each write access modifies the FAT table, which is
stored in fixed sectors. These sectors will wear out soon. If you use it
mainly for read access, it's a good, existing solution.

AFAIK, MMC/SD-Cards map the whole file system into a kind of journaling
FS, but all known techniques are protected by patents.

>From my experience, adding a journal file system to Nut/OS can be done.
But its implementation is anything else but trivial. If I remember
correctly, it took more than a year to get the PHAT drivers working
reliable.

Harald




More information about the En-Nut-Discussion mailing list