Subject: Re: MTD devices in NetBSD
To: Garrett D'Amore <>
From: Charles M. Hannum <mycroft@MIT.EDU>
List: tech-kern
Date: 03/23/2006 15:57:03
On Thu, Mar 23, 2006 at 12:38:32PM -0800, Garrett D'Amore wrote:
> For NOR, absolutely.  Many NOR systems are actually mapped *directly*
> into system memory.  I presume this to be true (that you can read less
> than a sector, not the mapping bit) for NAND, but I confess I'm still
> largely ignorant of NAND.

All the NAND parts I've used can be read in 256- or 512-byte sectors.
These are the sizes for the common NAND flash protocol that many vendors
use (which, mysteriously, happens to be the same as SmartMedia).  This
protocol also does overwrites (but not erases) with the same size
sectors.  If you're truly writing less than a block, you'll need to
buffer the old contents, erase, and rewrite.  Given that writes are
really slow on many devices, avoiding erase/rewrite cycles when possible
is a huge performance win -- not to mention that it will prolong the
life of the media.

Also note that with NAND flash it's generally a good idea to do a read/
verify after writing, because the parts are notoriously low quality.
This is also an opportunity to notice that you're losing with
opportunistic overwrites and retry with a full erase/write/verify cycle
before marking the block bad.

Lastly, note that there is some moderately unavoidable attach-time
overhead with NAND devices.  To be able to do random sector reads, you
need to map where the logical blocks really are, which involves reading
all the metadata.  This makes your {attach,mount,first access} time
somewhat dependent on the size of the device.