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

Ilko Iliev iliev at ronetix.at
Mon Oct 27 20:39:17 CET 2008


Dear Scott,

Scott Wood wrote:
> 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 ).
>   
I will send again with git-send-email.
> Why must the cleanmarker fit in the first free segment?
>   
The Linux NAND driver looks for the cleanmarkers at this place.


>   
>> +                               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)?
>   
The current Linux NAND Flash driver supports 8, 16 and 64 bytes OOB.
The "badblockpos & ~1" is in the current  file - I have no idea 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
>   
I think the NAND driver should work not only with MTD_OOB_AUTO.

-- 
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: iliev at ronetix.at; Web: www.ronetix.at



More information about the U-Boot mailing list