With this patch "nand erase clean" writes correctly the cleanmarkers. Without this patch "nand erase clean" fills the OOB with zeros which marks all blocks as bad.
Signed-off-by: Ilko Iliev <[EMAIL PROTECTED]> --- drivers/mtd/nand/nand_util.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index 52b3d21..a601772 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -156,10 +156,19 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts) /* format for JFFS2 ? */ if (opts->jffs2) { - chip->ops.len = chip->ops.ooblen = 64; + if ( chip->ecc.layout->oobfree->length < cleanmarker.totlen ) { + memset(buf, 0xFF, sizeof(buf)); + chip->ops.oobbuf = buf; + chip->ops.ooboffs = chip->badblockpos & ~0x01; + chip->ops.len = chip->ops.ooblen = meminfo->oobsize; + } + else { + chip->ops.oobbuf = (uint8_t *)&cleanmarker; + chip->ops.ooboffs = chip->ecc.layout->oobfree->offset; + chip->ops.len = chip->ops.ooblen = cleanmarker.totlen; + } + chip->ops.datbuf = NULL; - chip->ops.oobbuf = buf; - chip->ops.ooboffs = chip->badblockpos & ~0x01; result = meminfo->write_oob(meminfo, erase.addr + meminfo->oobsize, @@ -170,7 +179,8 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts) continue; } else - printf("%s: MTD writeoob at 0x%08x\n",mtd_device, erase.addr + meminfo->oobsize ); + MTDDEBUG (MTD_DEBUG_LEVEL3, "%s: MTD writeoob at 0x%08x\n", + mtd_device, erase.addr + meminfo->oobsize ); } if (!opts->quiet) { @@ -189,12 +199,13 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts) if (percent != percent_complete) { percent_complete = percent; - printf("\rErasing at 0x%x -- %3d%% complete.", - erase.addr, percent); + printf("\rErasing %sat 0x%x -- %3d%% complete.", + opts->jffs2 ? "and writing cleanmarker ": "", + erase.addr, percent); if (opts->jffs2 && result == 0) - printf(" Cleanmarker written at 0x%x.", - erase.addr); + MTDDEBUG (MTD_DEBUG_LEVEL3, " Cleanmarker written at 0x%x.", + erase.addr); } } } -- 1.5.2.2 -- Mit freundlichen Grüßen/With best regards, Ilko Iliev Ronetix Development Tools GmbH CPU Modules, JTAG/BDM Emulators and Flash Programmers Waidhausenstrasse 13/5, 1140 Vienna, Austria E-Mail: [EMAIL PROTECTED]; Web: www.ronetix.at _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot