mtd-utils/nandwrite: what if write fails?

Josh Boyer jwboyer at linux.vnet.ibm.com
Tue Oct 17 11:33:59 EDT 2006


On Tue, 2006-10-17 at 16:17 +0200, Ricard Wanderlof wrote:
> I have a question regarding writes to NAND flash; for instance, in 
> mtd-utils/nandwrite.c, prior to writing to a block, it is checked so that 
> it isn't bad (using the MEMGETBADBLOCK ioctl). However, what happens if 
> the block goes bad during write? If the pwrite() call which writes out the 
> page data fails, the application says perror() and exits. Shouldn't it 
> mark the block as bad, and re-write the data so far written to the block 
> to the next good block? As I understand it, mtd doesn't mark a block bad, 
> it is up to the application or overlying file system (e.g. JFFS2). So it 
> won't even help to run nandwrite again as the block has not been marked 
> bad.

pwrite can fail because of a transient error.  NAND can get soft bit
flips that can be cleared by erasing the block.  So to mark a block bad
without at least trying to write to it a couple of times seems a bit
drastic.

josh





More information about the linux-mtd mailing list