[U-Boot] [PATCH 0/4 v2] mtdparts: add bad-block skipping
Ben Gardiner
bengardiner at nanometrics.ca
Wed Jun 2 17:58:35 CEST 2010
This patch series is based on the idea of Harald Welte <laforge at gnumonks.org>
and the comments of Wolfgang Denk <wd at 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.e' 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.
---
Changes in 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
NOTE: I'm not sure what to call the new subcommands, I chose 'spread' because
of the way it changes the existing mtdparts variable; however, I am
open to suggestions for a different name. I chose add.e/add.i because of the
behaviour of the write.e/write.i commands; however, I am again open to
suggestions.
Testing was performed in the u-boot-omap-l1 tree [3]. 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.e 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.i 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)
-------------------------------------------------------------------------------
Here are the MAKEALL results:
./MAKEALL arm on master
--------------------- SUMMARY ----------------------------
Boards compiled: 150
Boards with warnings or errors: 47 ( shannon evb4510 lpc2292sodimm modnet50
SMN42 guruplug mv88f6281gtw_ge netstar openrd_base rd6281a sheevaplug suen3
afeb9260 at91cap9adk at91rm9200dk at91rm9200ek at91sam9260ek at91sam9261ek
at91sam9263ek at91sam9g10ek at91sam9g20ek at91sam9m10g45ek at91sam9rlek cmc_pu2
CPUAT91 CPU9260 CPU9G20 csb637 eb_cpux9k2 kb9202 meesc mp2usb m501sk otc570
pm9261 pm9263 SBC35_A9G20 TNY_A9260 TNY_A9G20 actux1 actux2 actux3 actux4
ixdp425 ixdpg425 pdnb3 scpu )
----------------------------------------------------------
./MAKEALL arm with this patch series applied
--------------------- SUMMARY ----------------------------
Boards compiled: 150
Boards with warnings or errors: 47 ( shannon evb4510 lpc2292sodimm modnet50
SMN42 guruplug mv88f6281gtw_ge netstar openrd_base rd6281a sheevaplug suen3
afeb9260 at91cap9adk at91rm9200dk at91rm9200ek at91sam9260ek at91sam9261ek
at91sam9263ek at91sam9g10ek at91sam9g20ek at91sam9m10g45ek at91sam9rlek cmc_pu2
CPUAT91 CPU9260 CPU9G20 csb637 eb_cpux9k2 kb9202 meesc mp2usb m501sk otc570
pm9261 pm9263 SBC35_A9G20 TNY_A9260 TNY_A9G20 actux1 actux2 actux3 actux4
ixdp425 ixdpg425 pdnb3 scpu )
----------------------------------------------------------
./MAKEALL powerpc with this patch series applied
--------------------- SUMMARY ----------------------------
Boards compiled: 354
Boards with warnings or errors: 15 ( MVBC_P BMW caddy2 MPC8536DS MPC8536DS_NAND
MPC8536DS_SDCARD MPC8536DS_SPIFLASH MPC8544DS P2020DS P2020DS_36BIT PM854 AP1000
EVB64260 P3G4 ZUMA )
----------------------------------------------------------
The binary size impact was checked using the da830evm config + NAND enabled for
arm and the virtlab2 config for ppc. The entire patch series saves 64 bytes on
arm and 4 bytes on ppc -- due to the regrouping of calls in 1/4. With all the
config options introduced in this series enabled the patch series adds 1096
bytes on arm and 260 bytes on ppc.
[1] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/43549
[2] http://wiki.openmoko.org/wiki/NAND_bad_blocks
[3] git://arago-project.org/git/people/sekhar/u-boot-omapl1.git
More information about the U-Boot
mailing list