On Sun, Jan 18, 2009 at 04:28:04PM -0500, Stefan Monnier wrote:
> What's the difference between writing the flash using the `mtd' utility,
> or writing it by catting into /dev/mtdblockN ?

Ideally you want to use the mtd command.

The problem with flash is that you can't simply write to it one byte at
a time; the typical erase size -- the smallest unit that can be written
-- for a 4M flash chip is 64k. To alter a single byte means reading 64k
of data into ram, altering a single byte in the ram copy, erasing 64k
from flash and then writing the 64k from ram back to flash. Only one
byte has changed, but 64k of data needed to be backed up and restored to
do so.

This is the problem with unaligned writes to the flash; writing 64k of
data this way may mean repeatedly erasing and reprograming the same 64k
of flash -- worst case you'd erase 64*1024 times, once for each byte
written; cat has no knowledge of the flash erase size and the kernel's
mtdblock layer will happily reprogram an entire 64k just because one
byte changed.

The mtd utility understands the flash, so to write 64k (or whatever the
erase size of the flash chip happens to be) the mtd util only has to
erase once and then immediately write all 64k.
_______________________________________________
openwrt-devel mailing list
[email protected]
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to