[U-Boot] [PATCH] Nand: Implement raw read/write and biterr

John Rigby jcrigby at gmail.com
Wed Sep 30 23:34:50 CEST 2009


Tom,

Thanks for the comments.  I'll wait a couple of days for others then
resubmit with fixes for these problems and any others that come up.

John

On Wed, Sep 30, 2009 at 1:22 PM, Tom <Tom.Rix at windriver.com> wrote:

> John Rigby wrote:
>
>> New commands nand read.raw and write.raw read/write
>> main and oob area.
>>
>> Implement previously stubbed nand biterr command.
>>
>> Document the above and also the previously undocumented
>> read.oob and write.oob.
>>
>> Signed-off-by: John Rigby <jrigby at control4.com>
>> ---
>>  common/cmd_nand.c |  115
>> +++++++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 files changed, 112 insertions(+), 3 deletions(-)
>>
>> diff --git a/common/cmd_nand.c b/common/cmd_nand.c
>> index 158a55f..a488038 100644
>> --- a/common/cmd_nand.c
>> +++ b/common/cmd_nand.c
>> @@ -90,6 +90,95 @@ static int nand_dump(nand_info_t *nand, ulong off, int
>> only_oob)
>>        return 0;
>>  }
>>  +#define NAND_RW_RAW_READ 0
>> +#define NAND_RW_RAW_WRITE 1
>> +
>> +static int nand_rdwr_raw(int rdwr, nand_info_t *nand, ulong off, u_char
>> *buf,
>> +                               size_t size)
>> +{
>> +       struct mtd_oob_ops ops = {
>> +               .len = nand->writesize,
>> +               .ooblen = nand->oobsize,
>> +               .mode = MTD_OOB_RAW,
>> +       };
>> +       int i;
>> +       int nrblocks = size / nand->writesize;
>> +       loff_t addr = (loff_t)(off & ~(nand->writesize - 1));
>>
>
> Silently dropping bytes.
> Would it be better to require the size to be a multiple of the block size ?
> Or at least warn of the dropped bytes.
>
>  +
>> +       while (nrblocks--) {
>> +               ops.datbuf = buf;
>>
>
> <snip>
>
>         }
>>  @@ -494,13 +600,16 @@ U_BOOT_CMD(nand, CONFIG_SYS_MAXARGS, 1, do_nand,
>>        "nand write - addr off|partition size\n"
>>        "    read/write 'size' bytes starting at offset 'off'\n"
>>        "    to/from memory address 'addr', skipping bad blocks.\n"
>> +       "     .oob - reads/writes oob only.\n"
>> +       "     .raw - reads/writes both main and oob with no error\n"
>> +       "            detection or correction\n"
>>
>
> Writing the oob area directly is UNSAFE.
> Having done to myself, it was a pain to undo.
> You should put at least document that.
>
> Tom
>


More information about the U-Boot mailing list