summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gardiner <bengardiner@nanometrics.ca>2010-08-31 17:48:04 -0400
committerScott Wood <scottwood@freescale.com>2010-10-11 15:11:01 -0500
commit59a50d2de1f9c037166a6f86e6e6cdc1670aa155 (patch)
treec376d14563d7a0b23591a6df49f0630ceb01d226
parentca75b20ebbfd40189a0157c7a2ef4360b0885cc4 (diff)
downloadu-boot-imx-59a50d2de1f9c037166a6f86e6e6cdc1670aa155.zip
u-boot-imx-59a50d2de1f9c037166a6f86e6e6cdc1670aa155.tar.gz
u-boot-imx-59a50d2de1f9c037166a6f86e6e6cdc1670aa155.tar.bz2
mtdparts: new add.spread: add part skipping bad blocks
This patch adds a new 'mtdparts add' variant: add.spread. This command variant adds a new partition to the mtdparts variable but also increases the partitions size by skipping bad blocks and aggregating any additional bad blocks found at the end of the partition. Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca> CC: Wolfgang Denk <wd@denx.de> CC: Scott Wood <scottwood@freescale.com>
-rw-r--r--common/cmd_mtdparts.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 347e409..17865b7 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -1949,9 +1949,13 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
/* mtdparts add <mtd-dev> <size>[@<offset>] <name> [ro] */
- if (((argc == 5) || (argc == 6)) && (strcmp(argv[1], "add") == 0)) {
+ if (((argc == 5) || (argc == 6)) && (strncmp(argv[1], "add", 3) == 0)) {
#define PART_ADD_DESC_MAXLEN 64
char tmpbuf[PART_ADD_DESC_MAXLEN];
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ struct mtd_info *mtd;
+ uint64_t next_offset;
+#endif
u8 type, num, len;
struct mtd_device *dev;
struct mtd_device *dev_tmp;
@@ -1986,15 +1990,25 @@ int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
debug("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
dev->id->num, dev->id->mtd_id);
- if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) {
+ p = list_entry(dev->parts.next, struct part_info, link);
+
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ if (get_mtd_info(dev->id->type, dev->id->num, &mtd))
+ return 1;
+
+ if (!strcmp(&argv[1][3], ".spread")) {
+ spread_partition(mtd, p, &next_offset);
+ debug("increased %s to %d bytes\n", p->name, p->size);
+ }
+#endif
+
+ dev_tmp = device_find(dev->id->type, dev->id->num);
+ if (dev_tmp == NULL) {
device_add(dev);
- } else {
+ } else if (part_add(dev_tmp, p) != 0) {
/* merge new partition with existing ones*/
- p = list_entry(dev->parts.next, struct part_info, link);
- if (part_add(dev_tmp, p) != 0) {
- device_del(dev);
- return 1;
- }
+ device_del(dev);
+ return 1;
}
if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
@@ -2039,6 +2053,10 @@ U_BOOT_CMD(
" - delete partition (e.g. part-id = nand0,1)\n"
"mtdparts add <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
" - add partition\n"
+#if defined(CONFIG_CMD_MTDPARTS_SPREAD)
+ "mtdparts add.spread <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
+ " - add partition, padding size by skipping bad blocks\n"
+#endif
"mtdparts default\n"
" - reset partition table to defaults\n"
#if defined(CONFIG_CMD_MTDPARTS_SPREAD)