From: Tom <Tom.Rix@windriver.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Nand: Implement raw read/write and biterr
Date: Wed, 30 Sep 2009 14:22:09 -0500 [thread overview]
Message-ID: <4AC3AFE1.2030506@windriver.com> (raw)
In-Reply-To: <1254334299-9583-1-git-send-email-jrigby@control4.com>
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@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
next prev parent reply other threads:[~2009-09-30 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-30 18:11 [U-Boot] [PATCH] Nand: Implement raw read/write and biterr John Rigby
2009-09-30 19:22 ` Tom [this message]
2009-09-30 21:34 ` John Rigby
2009-10-19 18:10 ` Scott Wood
2009-10-19 19:04 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AC3AFE1.2030506@windriver.com \
--to=tom.rix@windriver.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.