public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ben Gardiner <bengardiner@nanometrics.ca>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 0/5] mtdparts: add bad-block skipping
Date: Tue, 31 Aug 2010 17:47:59 -0400	[thread overview]
Message-ID: <cover.1283271480.git.bengardiner@nanometrics.ca> (raw)
In-Reply-To: <cover.1283187599.git.bengardiner@nanometrics.ca>

Ben Gardiner (5):
  mtdparts: regroup calls to get_mtd_device_nm
  mtd: add an mtd method for get_len_incl_bad()
  mtdparts: show net size in mtdparts list
  mtdparts: add new sub-command "spread"
  mtdparts: new add.spread: add part skipping bad blocks

 common/cmd_mtdparts.c        |  260 +++++++++++++++++++++++++++++++++++++-----
 drivers/mtd/mtdcore.c        |   49 ++++++++
 drivers/mtd/nand/nand_util.c |    6 +
 include/linux/mtd/mtd.h      |    4 +-
 4 files changed, 287 insertions(+), 32 deletions(-)

This patch series is based on the idea of Harald Welte <laforge@gnumonks.org>
and the comments of Wolfgang Denk <wd@denx.de> [1]. I started with Harald's
original patch and migrated it to a new mtdparts sub-command and added an
interface to the new functionality via a 'mtdparts add' variant.

I tried to keep it at the level of the mtd subsystem. Whereas the dynparts patch
was limited to NAND flashes, I believe this patch will work on any mtd device
that can report bad blocks.

These new commands can be useful when gang programming NAND chips where the
gang programmer is capable only of skipping bad blocks. One can use a
master image that contains images of each of the partitions padded-out
to their spec'd sizes; when u-boot first comes up 'mtdparts default;
mtdparts spread' (or a seq of 'mtdpart add.spread' commands) will produce a
partition table that matches what was put there by the gang-programmer.

It can also be useful when doing in-situ programming with u-boot being the
flash programmer as demonstrated by the openmoko project's use of the
'dynpart' command [2] upon which this patch series was based.

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>

[1] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/43549
[2] http://wiki.openmoko.org/wiki/NAND_bad_blocks

---

V2:
 * formating: spaces after 'if' and for
 * printing net partition sizes feature is now conditional on the new
   CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES macro; patch 2/4 was adding 264 bytes
   to the virtlab2 build -- now it adds 0 bytes -- see below for more binary
   size impact details
 * changed the net_part_size method to return the net size instead of using an
   output variable
 * checking mtd->block_isbad function pointer before dereferencing
 * there were some trailing whitespace errors when applying 3/4 and 4/4 that I
   have fixed now

V3:
 * rebased to 54841ab50c20d6fa6c9cc3eb826989da3a22d934 of
   git://git.denx.de/u-boot.git
 * more checkpatch fixes
 * adding openmoko to the copyright statements in cmd_mtdparts.c

V4:
 * rebased to b417260d871d4d8d336c160d95ed40cc8c0fb0fa of
   git://git.denx.de/u-boot.git
 * re-grouped list_partition #ifdefs into one
 * removed changelog and my (C) from file header
 * added source of port to the commit message
 * fixed multi-line comment style
 * indentation only by tabs
 * check for s == NULL when looking for '.' in command
 * do not include support for the '.i' synonym
 * rename to 'add.spread' to match 'mtdparts spread' as per Scott Wood's
   suggestion.

V5:
 * rebased to 962ad59e25640e586e2bceabf67a628a27f8f508 of
   git://git.denx.de/u-boot.git
 * renumbered patches; V5 introduces patch 2/5
 * return uint64_t instead of u32 for net_size
 * do a quick if((cond) return
 * calculate net_size by adding-up good blocks instead of subtracting bad
   blocks
 * try to strike a balance; reuse more code between the branches of
   #if defined(CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES) in
   print_partition_table
 * don't push dangling lines to the right
 * fix spelling errors in comments
 * more hanging arguments alignment
 * refactor the spread_partition function so that it delegates the
   bad-block counting to the mtd_get_len_incl_bad function -- as per
   Scott Woods' suggestion.
 * don't reproduce the same call to spread_partitions on either side
   of the check for existing device -- as per Scott Wood's comments.

V6:
 * return zero length and truncated if mtd_get_len_incl_bad is
   called with offset>=size -- as per Scott Wood's review
   comments
 * fix indentation on list_entry
 * don't use mtd_get_len_incl_bad to get net_size anymore as it was
   a bad idea. Just count up the good blocks.
 * check truncated return value to handle trying to absorb bad blocks
   past the end of the device -- as per Scott Wood's review comments

Testing was performed with da850evm.h plus NAND enabled. Here is an example
u-boot console session to demonstrate how the commands work:

-------------------------------------------------------------------------------
U-Boot > mtdparts default
U-Boot > nand bad

Device 0 bad blocks:
  062c0000
  0a140000
  128a0000
  12e20000
  18bc0000
  1ff80000
  1ffa0000
  1ffc0000
  1ffe0000
U-Boot > mtdparts

device nand0 <davinci_nand.1>, # parts = 11
 #: name                size            net size        offset
mask_flags
 0: zero                0x000c0000      0x000c0000      0x00000000      1
 1: conf                0x00200000      0x00200000      0x000c0000      0
 2: kernel_a            0x00400000      0x00400000      0x002c0000      0
 3: initrd_a            0x00400000      0x00400000      0x006c0000      0
 4: rootfs_a            0x07020000      0x07000000 (!)  0x00ac0000      0
 5: kernel_b            0x00400000      0x00400000      0x07ae0000      0
 6: initrd_b            0x00400000      0x00400000      0x07ee0000      0
 7: rootfs_b            0x07020000      0x07000000 (!)  0x082e0000      0

active partition: nand0,0 - (zero) 0x00020000 @ 0x00000000

defaults:
mtdids  : nand0=davinci_nand.1
mtdparts: mtdparts=mtdparts=davinci_nand.1:768k(zero)ro,2m(conf),4m(kernel_a),
4m(initrd_a),112m(rootfs_a),4m(kernel_b),4m(initrd_b),112m(rootfs_b)
U-Boot >
U-Boot > mtdparts spread
U-Boot > print mtdparts
mtdparts=mtdparts=davinci_nand.1:768k(zero)ro,2m(conf),4m(kernel_a),4m(initrd_a)
,114816k(rootfs_a),4m(kernel_b),4m(initrd_b),114816k(rootfs_b)
U-Boot > mtdparts

device nand0 <davinci_nand.1>, # parts = 11
 #: name                size            net size        offset
mask_flags
 0: zero                0x000c0000      0x000c0000      0x00000000      1
 1: conf                0x00200000      0x00200000      0x000c0000      0
 2: kernel_a            0x00400000      0x00400000      0x002c0000      0
 3: initrd_a            0x00400000      0x00400000      0x006c0000      0
 4: rootfs_a            0x07040000      0x07020000 (!)  0x00ac0000      0
 5: kernel_b            0x00400000      0x00400000      0x07b00000      0
 6: initrd_b            0x00400000      0x00400000      0x07f00000      0
 7: rootfs_b            0x07040000      0x07020000 (!)  0x08300000      0

active partition: nand0,0 - (zero) 0x00020000 @ 0x00000000

defaults:
mtdids  : nand0=davinci_nand.1
mtdparts: mtdparts=mtdparts=davinci_nand.1:768k(zero)ro,2m(conf),4m(kernel_a),
4m(initrd_a),112m(rootfs_a),4m(kernel_b),4m(initrd_b),112m(rootfs_b)
U-Boot >
U-Boot > mtdpart del rootfs_b
U-Boot > mtdpart add.spread nand0 112m rootfs_b
U-Boot > print mtdparts
mtdparts=mtdparts=davinci_nand.1:768k(zero)ro,2m(conf),4m(kernel_a),4m(initrd_a)
,114816k(rootfs_a),4m(kernel_b),4m(initrd_b),114816k(rootfs_b)

U-Boot > mtdpart del rootfs_b
U-Boot > mtdpart add.spread nand0 112m rootfs_b
U-Boot > print mtdparts
mtdparts=mtdparts=davinci_nand.1:768k(zero)ro,2m(conf),4m(kernel_a),4m(initrd_a)
,114816k(rootfs_a),4m(kernel_b),4m(initrd_b),114816k(rootfs_b)
U-Boot >
U-Boot > mtdparts del rootfs_b
U-Boot > mtdparts add nand0 112m rootfs_b
U-Boot > print mtdparts
mtdparts=mtdparts=davinci_nand.1:768k(zero)ro,2m(conf),4m(kernel_a),4m(initrd_a)
,114816k(rootfs_a),4m(kernel_b),4m(initrd_b),112m(rootfs_b)
-------------------------------------------------------------------------------

I verified the patches with checkpatch.

I confirmed that MAKEALL for 'ARM9' and '8xx' did not introduce any additional
warnings.

I tested the binary size and compiler warnings on ARM9 and 8xx. The patch series
saves 24 bytes of text on 8xx and 30 bytes of text on arm9 -- when none of the
config options are enabled. When the config options are enabled, text grows by
1413 bytes on arm9.

  parent reply	other threads:[~2010-08-31 21:47 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-06 16:28 [U-Boot-Users] [PATCH, resend] Support dynamic/patched NAND ENV offset Harald Welte
2008-07-07 18:47 ` Scott Wood
2008-07-08  0:09   ` Harald Welte
2008-07-08 16:05     ` Scott Wood
2008-07-08 21:12       ` Wolfgang Denk
2008-07-09  0:23         ` Harald Welte
2008-07-09  7:05           ` Wolfgang Denk
2008-07-09  7:25             ` Harald Welte
2008-07-09  8:04               ` Wolfgang Denk
2008-07-09 12:13                 ` Harald Welte
2010-06-01 20:23                 ` [U-Boot] mtdparts: add bad-block skipping Ben Gardiner
2010-06-01 22:20                   ` Wolfgang Denk
2010-06-01 22:34                   ` Wolfgang Denk
2010-06-02  5:08                     ` Ben Gardiner
2010-06-02 15:58                   ` [U-Boot] [PATCH 0/4 v2] " Ben Gardiner
2010-07-05 21:43                     ` [U-Boot] [PATCH v3 0/4] " Ben Gardiner
2010-07-12 19:06                       ` Ben Gardiner
2010-08-09 20:43                       ` [U-Boot] [PATCH v4 " Ben Gardiner
2010-08-30 17:38                         ` [U-Boot] [PATCH v5 0/5] " Ben Gardiner
2010-08-30 17:38                           ` [U-Boot] [PATCH v5 2/5] mtd: add an mtd method for get_len_incl_bad() Ben Gardiner
2010-08-30 20:57                             ` Scott Wood
2010-08-31 13:50                               ` Ben Gardiner
2010-08-31 21:48                             ` [U-Boot] [PATCH v6 " Ben Gardiner
     [not found]                           ` <1283185640-0-git-send-email-bengardiner@nanometrics.ca>
2010-08-30 17:38                             ` [U-Boot] [PATCH v5 3/5] mtdparts: show net size in mtdparts list Ben Gardiner
2010-08-30 20:50                               ` Scott Wood
2010-08-31 13:51                                 ` Ben Gardiner
2010-08-31 15:57                                   ` Scott Wood
2010-08-31 21:48                               ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-08-31 21:47                           ` Ben Gardiner [this message]
2010-09-09 20:54                             ` [U-Boot] [PATCH v6 0/5] mtdparts: add bad-block skipping Scott Wood
2010-08-09 20:43                       ` [U-Boot] [PATCH v4 1/4] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-08-09 20:43                       ` [U-Boot] [PATCH v4 2/4] mtdparts: show net size in mtdparts list Ben Gardiner
2010-08-26 18:57                         ` Scott Wood
2010-08-27 13:51                           ` Ben Gardiner
2010-08-27 15:44                           ` Ben Gardiner
2010-08-27 16:02                             ` Scott Wood
2010-08-27 16:45                               ` Ben Gardiner
2010-08-09 20:43                       ` [U-Boot] [PATCH v4 3/4] mtdparts: add new sub-command "spread" Ben Gardiner
2010-08-26 21:12                         ` Scott Wood
2010-08-27 13:51                           ` Ben Gardiner
2010-08-27 21:36                             ` Ben Gardiner
2010-08-27 21:46                               ` Scott Wood
2010-08-27 21:52                                 ` Ben Gardiner
2010-08-27 21:59                                 ` Scott Wood
2010-08-28  3:59                                   ` Ben Gardiner
2010-08-30 20:24                                     ` Scott Wood
2010-08-30 20:30                                       ` Ben Gardiner
2010-08-30 17:38                         ` [U-Boot] [PATCH v5 4/5] " Ben Gardiner
2010-08-30 21:01                           ` Scott Wood
2010-08-30 21:05                             ` Scott Wood
2010-08-31 13:51                             ` Ben Gardiner
2010-08-31 21:48                           ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-08-09 20:44                       ` [U-Boot] [PATCH v4 4/4] mtdparts: new add.spread: add part skipping bad blocks Ben Gardiner
2010-08-26 22:26                         ` Scott Wood
2010-08-27 13:52                           ` Ben Gardiner
2010-08-30 17:39                         ` [U-Boot] [PATCH v5 5/5] " Ben Gardiner
2010-08-31 21:48                           ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-07-05 21:43                     ` [U-Boot] [PATCH v3 1/4] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-08-30 17:38                       ` [U-Boot] [PATCH v5 1/5] " Ben Gardiner
2010-08-31 21:48                         ` [U-Boot] [PATCH v6 " Ben Gardiner
2010-07-05 21:43                     ` [U-Boot] [PATCH v3 2/4] mtdparts: show net size in mtdparts list Ben Gardiner
2010-08-07 20:08                       ` Wolfgang Denk
2010-08-08  4:06                         ` Harald Welte
2010-08-08 13:16                           ` Wolfgang Denk
2010-08-09 14:45                         ` Ben Gardiner
2010-09-18 19:42                           ` Wolfgang Denk
2010-07-05 21:43                     ` [U-Boot] [PATCH v3 3/4] mtdparts: add new sub-command "spread" Ben Gardiner
2010-08-07 20:12                       ` Wolfgang Denk
2010-07-05 21:43                     ` [U-Boot] [PATCH v3 4/4] mtdparts: new add.e: add part skipping bad blocks Ben Gardiner
2010-08-07 20:16                       ` Wolfgang Denk
2010-06-02 15:58                   ` [U-Boot] [PATCH 1/4 v2] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-06-02 15:58                   ` [U-Boot] [PATCH 2/4 v2] mtdparts: show net size in mtdparts list Ben Gardiner
2010-06-02 15:58                   ` [U-Boot] [PATCH 3/4 v2] mtdparts: add new sub-command "spread" Ben Gardiner
2010-06-02 15:58                   ` [U-Boot] [PATCH 4/4 v2] mtdparts: new add.e: add part skipping bad blocks Ben Gardiner
2010-08-09 18:25                     ` Scott Wood
2010-08-09 18:39                       ` Ben Gardiner
2010-08-09 18:51                         ` Scott Wood
2010-06-01 20:23                 ` [U-Boot] [PATCH 1/4] mtdparts: regroup calls to get_mtd_device_nm Ben Gardiner
2010-06-02  7:06                   ` Stefan Roese
2010-06-01 20:23                 ` [U-Boot] [PATCH 2/4] mtdparts: show net size in mtdparts list Ben Gardiner
2010-06-02  7:15                   ` Stefan Roese
2010-06-01 20:23                 ` [U-Boot] [PATCH 3/4] mtdparts: add new sub-command "spread" Ben Gardiner
2010-06-01 20:23                 ` [U-Boot] [PATCH 4/4] mtdparts: new add.e: add part skipping bad blocks Ben Gardiner
2008-07-09  0:18       ` [U-Boot-Users] [PATCH, resend] Support dynamic/patched NAND ENV offset Harald Welte
2008-07-09  5:28       ` Harald Welte
2008-07-09  7:07         ` Harald Welte
2008-07-09  8:11       ` [U-Boot-Users] [PATCH] " Harald Welte
2008-07-11 17:28         ` Scott Wood
2010-05-17 21:04           ` [U-Boot] [PATCH] NAND: Support dynamic location of enviromnent (CONFIG_ENV_OFFSET_OOB) Ben Gardiner
2010-05-26 22:58             ` Scott Wood
2010-05-26 23:38               ` Ben Gardiner
2010-05-31 21:29               ` [U-Boot] [PATCH v2] NAND: environment offset in OOB (CONFIG_ENV_OFFSET_OOB) Ben Gardiner
2010-06-30 21:32                 ` [U-Boot] [PATCH v3] " Ben Gardiner
2010-06-30 21:41                   ` Wolfgang Denk
2010-07-01  4:09                     ` Ben Gardiner
2010-07-01  3:37                   ` Vipin KUMAR
2010-07-01  5:29                     ` Ben Gardiner
2010-07-01  7:17                   ` Harald Welte
2010-07-05 13:57                     ` Ben Gardiner
2010-07-05 17:27                     ` [U-Boot] [PATCH v4] " Ben Gardiner
2010-07-12 16:17                       ` Ben Gardiner
2010-07-12 16:19                         ` Scott Wood
2010-07-13 19:26                       ` Scott Wood
2010-07-13 21:17                         ` Ben Gardiner

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=cover.1283271480.git.bengardiner@nanometrics.ca \
    --to=bengardiner@nanometrics.ca \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox