open question on flash speed/app blocking

Mark Sienkiewicz ms at
Wed Jan 16 17:47:58 EST 2002

At 12:47 PM 1/16/2002 -0700, Herman Oosthuysen wrote:
>Hmm, the problem is not writing to flash per se, but rather garbage
>collection, which requires the erase of dirty Flash sectors.
 >If your system has to write to flash every few seconds, then consider using
>a file system that has a large write cache, to enable you to survive the
>periods when the system is busy erasing a sector.

Or you can use a system that starts erasing sectors well in advance of
needing them, so you never need to wait for the erase operation.

For example, suppose the only thing you need to store in the flash is a
stream of records where you only need the most recent XXX bytes.  You could
make a circular buffer in the flash, and start an erase operation any time
there are not at least N already-erased sectors ahead of where you are
writing.  If your data rate has a known upper bound, you can compute N from
the maximum erase time on the spec sheet for your flash chip.

That doesn't exactly make a filesystem, but it is very easy to do from user
mode.  I have a similar application:  I save a big chunk of data at shutdown
time.  At boot time, I find the newest record and restore it, but I also
find the _oldest_ record and start erasing it.  At shutdown time, I don't
need to erase anything -- it is already erased.

I'm not that familiar with jffs2, but if I remember correctly, it has a
filesystem parameter for how many empty flash sectors it must maintain.
Maybe if you set it higher than the minimum needed to make garbage
collection work, it will erase things early enough to avoid blocking anybody.
If you want to use jffs2, it would be worth looking into.

Mark S.

More information about the linux-mtd mailing list