[U-Boot] [PATCH 3/5] nand erase: .spread, .part, .chip subcommands

Ben Gardiner bengardiner at nanometrics.ca
Tue Aug 31 23:46:09 CEST 2010


On Mon, Aug 30, 2010 at 7:03 PM, Scott Wood <scottwood at freescale.com> wrote:
> A while back, in http://lists.denx.de/pipermail/u-boot/2009-June/054428.html,
> Michele De Candia posted a patch to not count bad blocks toward the
> requested size to be erased.  This is desireable when you're passing in
> something like $filesize, but not when you're trying to erase a partition.
>
> Thus, a .spread subcommand (named for consistency with
> http://lists.denx.de/pipermail/u-boot/2010-August/075163.html) is introduced
> to make explicit the user's desire to erase for a given amount of data,
> rather than to erase a specific region of the chip.

I'm flattered that you have chosen to use '.spread'

> While passing $filesize to "nand erase" is useful, accidentally passing
> something like $fliesize currently produces quite unpleasant results, as the
> variable evaluates to nothing and U-Boot assumes that you want to erase
> the entire rest of the chip/partition.  To improve the safety of the
> erase command, require the user to make explicit their intentions by
> using a .part or .chip subcommand.  This is an incompatible user interface
> change, but keeping compatibility would eliminate the safety gain, and IMHO
> it's worth it.

Agreed. It also makes the arguments expected by the nand erase
variants easier to understand for new users.

> While touching nand_erase_opts(), make it accept 64-bit offsets and sizes,
> fix the percentage display when erase length is rounded up, eliminate
> an inconsistent warning about rounding up the erase length which only
> happened when the length was less than one block (rounding up for $filesize
> is normal operation), and add a diagnostic if there's an attempt to erase
> beginning at a non-block boundary.
>
> Signed-off-by: Scott Wood <scottwood at freescale.com>

applies to 962ad59e25640e586e2bceabf67a628a27f8f508 of
git://git.denx.de/u-boot.git -- one checkpatch error

Tested on da850evm_config with NAND enabled;

Tested-by: Ben Gardiner <bengardiner at nanometrics.ca>

> @@ -84,13 +84,19 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
>        struct mtd_oob_ops oob_opts;
>        struct nand_chip *chip = meminfo->priv;
>
> +       if ((opts->offset & (meminfo->writesize - 1)) != 0) {
> +               printf("Attempt to erase non page aligned data\n");
> +               return -1;
> +       }
> +
>        memset(&erase, 0, sizeof(erase));
>        memset(&oob_opts, 0, sizeof(oob_opts));
>
>        erase.mtd = meminfo;
>        erase.len  = meminfo->erasesize;
>        erase.addr = opts->offset;
> -       erase_length = opts->length;
> +       erase_length = lldiv(opts->length + meminfo->erasesize - 1,
> +                            meminfo->erasesize);

checkpatch is complaining:
error: checkpatch: code indent should use tabs where possible
drivers/mtd/nand/nand_util.c:99:1:
+^I                     meminfo->erasesize);$


Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca


More information about the U-Boot mailing list