From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] dfu, nand: before write a buffer to nand, erase the nand sectors
Date: Mon, 17 Jun 2013 19:51:26 -0500 [thread overview]
Message-ID: <1371516686.9073.17@snotra> (raw)
In-Reply-To: <1371445261-3785-1-git-send-email-hs@denx.de> (from hs@denx.de on Mon Jun 17 00:01:01 2013)
On 06/17/2013 12:01:01 AM, Heiko Schocher wrote:
> before writing the received buffer to nand, erase the nand
> sectors. If not doing this, nand write fails. See for
> more info here:
>
> http://lists.denx.de/pipermail/u-boot/2013-June/156361.html
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Cc: Scott Wood <scottwood@freescale.com>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Cc: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Tom Rini <trini@ti.com>
>
> ---
> - changes for v2:
> - use opts.spread as Scott Wood suggested
>
> drivers/dfu/dfu_nand.c | 17 +++++++++++++++--
> 1 Datei ge?ndert, 15 Zeilen hinzugef?gt(+), 2 Zeilen entfernt(-)
>
> diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
> index 7dc89b2..93db9bd 100644
> --- a/drivers/dfu/dfu_nand.c
> +++ b/drivers/dfu/dfu_nand.c
> @@ -63,12 +63,25 @@ static int nand_block_op(enum dfu_nand_op op,
> struct dfu_entity *dfu,
>
> nand = &nand_info[nand_curr_device];
>
> - if (op == DFU_OP_READ)
> + if (op == DFU_OP_READ) {
> ret = nand_read_skip_bad(nand, start, &count, &actual,
> lim, buf);
> - else
> + } else {
> + nand_erase_options_t opts;
> +
> + memset(&opts, 0, sizeof(opts));
> + opts.offset = start;
> + opts.length = count;
> + opts.spread = 1;
> + opts.quiet = 1;
> + /* first erase */
> + ret = nand_erase_opts(nand, &opts);
> + if (ret)
> + return ret;
> + /* then write */
> ret = nand_write_skip_bad(nand, start, &count, &actual,
> lim, buf, 0);
BTW, I notice you are currently using the limit functionality of
nand_read/write_skip_bad... opts.spread currently does not have this
support (as I noted before), which means that if there's an error you'd
erase too much and then refuse to write.
Maybe we need an opts.limit?
adjust_size_for_badblocks, OTOH, is probably the opposite of what you
wanted -- it subtracts from the size in order to get the number of good
blocks within an interval, rather than adding the number of bad blocks
to turn a data size into an interval. It's meant to produce an input
to be used with skipping/spreading operations.
Which makes me think we have a bug in cmd_nand.c -- we should be
setting .spread in erase cases where we call adjust_size_for_badblocks.
-Scott
next prev parent reply other threads:[~2013-06-18 0:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-14 10:24 [U-Boot] [PATCH] dfu, nand: before write a buffer to nand, erase the nand sectors Heiko Schocher
2013-06-14 22:19 ` Scott Wood
2013-06-17 5:01 ` [U-Boot] [PATCH v2] " Heiko Schocher
2013-06-18 0:51 ` Scott Wood [this message]
2013-06-20 4:36 ` Heiko Schocher
2013-06-20 17:22 ` Scott Wood
2013-06-21 5:09 ` [U-Boot] [PATCH v3] " Heiko Schocher
2013-06-21 22:50 ` Scott Wood
2013-06-24 16:50 ` [U-Boot] [PATCH v4] " Heiko Schocher
2013-06-24 23:26 ` Scott Wood
2013-07-25 4:43 ` [U-Boot] [PATCH v5] dfu, nand, ubi: add partubi alt settings for updating ubi partition Heiko Schocher
2013-07-26 22:05 ` 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=1371516686.9073.17@snotra \
--to=scottwood@freescale.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.