[U-Boot] [PATCH] - fix "nand erase clean" problem

Scott Wood scottwood at freescale.com
Mon Oct 27 19:50:07 CET 2008


On Sun, Oct 26, 2008 at 05:48:47PM +0100, Ilko Iliev wrote:
> 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 <iliev at ronetix.at>
> ---
>  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 ) {

Patch is linewrapped.  Also, no space after ( or before ).

Why must the cleanmarker fit in the first free segment?

> +                               memset(buf, 0xFF, sizeof(buf));
> +                               chip->ops.oobbuf = buf;
> +                               chip->ops.ooboffs = chip->badblockpos & 
> ~0x01;
> +                               chip->ops.len = chip->ops.ooblen = 
> meminfo->oobsize;

What if oobsize > 64 (as with 4k pages)?  Why write anything at all if
you're not going to write the cleanmarker?  Why badblockpos & ~1 (I know
existing code does it, but why)?

> +                       }
> +                       else {

} else {

> +                               chip->ops.oobbuf = (uint8_t *)&cleanmarker;
> +                               chip->ops.ooboffs = 
> chip->ecc.layout->oobfree->offset;
> +                               chip->ops.len = chip->ops.ooblen = 
> cleanmarker.totlen;
> +                       }

Set ooboffs to zero, and use MTD_OOB_AUTO.

-Scott


More information about the U-Boot mailing list