From: Joe Schaack <jscha...@xes-inc.com> Modify the nand_write_page() function to use ECC when appropriate to verify writes. Previously if a single bit error occured and software ECC was used the write verification would report a failure. However, the write really did succeed, since ECC can handle the error.
The issue can be simulated with a sequence of commands such as: # Inject a fake bit that is stuck low (2K page flash being used) nand erase 0 0x20000 mw.b 0x10000 0xff 0x1000 mw.b 0x10000 0xfe 1 nand write.raw 0x10000 0x0 0x1 # Write some data which needs to toggle the fake stuck bit mw.b 0x10000 0xab 1 nand write 0x10000 0x0 0x800 An error will occur: NAND write: device 0 offset 0x0, size 0x800 NAND write to offset 0 failed -5 0 bytes written: ERROR But you can verify data was correctly written: # Show data is correct when ECC is used nand read 0x10000 0x0 0x800 md 0x10000 # Show the bit is still stuck low nand read.raw 0x10000 0x0 0x1 md 0x10000 Change the behavior so ECC is used when verifying non-raw writes. This only impacts boards that have COFNIG_MTD_NAND_VERIFY_WRITE defined. Signed-off-by: Joe Schaack <jscha...@xes-inc.com> Signed-off-by: Peter Tyser <pty...@xes-inc.com> --- drivers/mtd/nand/nand_base.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index abcb84a..aa039ef 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2405,7 +2405,10 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, /* Send command to read back the data */ chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); - chip->ecc.read_page_raw(mtd, chip, vfy_buf, oob_required, page); + if (unlikely(raw)) + chip->ecc.read_page_raw(mtd, chip, vfy_buf, oob_required, page); + else + chip->ecc.read_page(mtd, chip, vfy_buf, oob_required, page); status = memcmp(buf, vfy_buf, mtd->writesize); -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot