
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.e' commands) will produce a partition table that matches what was put their by the gang-programmer.
It can also be useful when doing in-situ programming with u-boot as the flash programmer as demonstrated by the openmoko project's use of the 'dynpart' command [2] upon which this patch series was based.
---
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 once again open to suggestion.
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 > nand bad
Device 0 bad blocks: 062c0000 0a140000 128a0000 12e20000 18bc0000 1ff80000 1ffa0000 1ffc0000 1ffe0000 U-Boot > mtdparts default U-Boot > print 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 > 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 ) ----------------------------------------------------------
[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