The current MTD commandline partitioning driver does not allow fill-up
partitions that are followed by one or more fixed size partitions. This
modification allows fill-up partitions to be places anywhere in the flash.
Many devices are available with different flash size. Some of them have a
flash partition with configuration data at the end of the flash, this made
it necessary to create a seperate firmware image for each supported flash
size. For example, instead of

  mtdparts=".... 3712k(firmware),64k(art)"

a fill-up partition can be used:

  mtdparts=".... -(firmware),64k(art)"

Signed-off-by: Erwin Authried <ea...@softsys.co.at>

--- /dev/null
+++ b/target/linux/generic/patches-3.10/413-mtd-enhance-fillup-partition.patch
@@ -0,0 +1,69 @@
+diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
+--- a/drivers/mtd/cmdlinepart.c
++++ b/drivers/mtd/cmdlinepart.c
+@@ -169,10 +169,6 @@ static struct mtd_partition * newpart(char *s,
+ 
+       /* test if more partitions are following */
+       if (*s == ',') {
+-              if (size == SIZE_REMAINING) {
+-                      printk(KERN_ERR ERRP "no partitions allowed after a 
fill-up partition\n");
+-                      return ERR_PTR(-EINVAL);
+-              }
+               /* more partitions follow, parse them */
+               parts = newpart(s + 1, &s, num_parts, this_part + 1,
+                               &extra_mem, extra_mem_size);
+@@ -313,6 +309,8 @@ static int parse_cmdline_partitions(struct mtd_info 
*master,
+       int i, err;
+       struct cmdline_mtd_partition *part;
+       const char *mtd_id = master->name;
++      uint64_t size_top;
++      int i_fillup;
+ 
+       /* parse command line */
+       if (!cmdline_parsed) {
+@@ -333,14 +331,34 @@ static int parse_cmdline_partitions(struct mtd_info 
*master,
+       if (!part)
+               return 0;
+ 
++      /* calculate size after fillup partition */
++      for (i_fillup = part->num_parts-1,
++              size_top = 0; i_fillup >= 0; i_fillup--) {
++              if (part->parts[i_fillup].size == SIZE_REMAINING)
++                      break;
++              size_top += part->parts[i_fillup].size;
++              if (part->parts[i_fillup].offset != OFFSET_CONTINUOUS)
++                      size_top = 0;
++      }
++
+       for (i = 0, offset = 0; i < part->num_parts; i++) {
+               if (part->parts[i].offset == OFFSET_CONTINUOUS)
+                       part->parts[i].offset = offset;
+               else
+                       offset = part->parts[i].offset;
+ 
+-              if (part->parts[i].size == SIZE_REMAINING)
+-                      part->parts[i].size = master->size - offset;
++              if (part->parts[i].size == SIZE_REMAINING) {
++                      if (i_fillup == i) {
++                              part->parts[i].size
++                                      = (size_top + offset < master->size)
++                                      ? master->size - size_top - offset : 0;
++                      } else {
++                              printk(KERN_WARNING ERRP
++                              "%s: Only one fillup partition allowed\n",
++                                      part->mtd_id);
++                              part->parts[i].size = 0;
++                      }
++              }
+ 
+               if (offset + part->parts[i].size > master->size) {
+                       printk(KERN_WARNING ERRP
+@@ -357,7 +375,7 @@ static int parse_cmdline_partitions(struct mtd_info 
*master,
+                       part->num_parts--;
+                       memmove(&part->parts[i], &part->parts[i + 1],
+                               sizeof(*part->parts) * (part->num_parts - i));
+-                      i--;
++                      i--; i_fillup--;
+               }
+       }
+ 
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to