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

Tom Tom.Rix at windriver.com
Wed Sep 30 21:22:09 CEST 2009


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