mtd: allow multiple -(name) parts on cmdline.
PATCH 1/1 mtd: allow multiple -(name) parts on cmdline.
This allows to specify multiple -(name) SIZE_REMAINING partitions on the commandline parser.
Example:
mtdparts=physmap-flash.0:256k(uboot),128k(params),-(firmware),1966080(kernel),-(rootfs)
Having a "firmaware" partition makes it easier to flash/erase firmware on embedded decvices. Many platforms have such a partition already defined in their platform or device tree code.
This patch makes it possible to define such partitions on the cmdline as well.
--- drivers/mtd/cmdlinepart.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/mtd/cmdlinepart.c +10 -6
@@ -167,10 +167,6 @@ static struct mtd_partition * newpart(char *s,/* test if more partitions are following */ if (*s ==',' ) { -if (size ==SIZE_REMAINING ) { -pr_err ("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);
@@ -335,20 +331,28 @@ static int parse_cmdline_partitions(struct mtd_info *master,return 0 ;for (i =0 , offset =0 ; i < part->num_parts; i++) { +int move_offset; +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 ) +if (part->parts[i].size ==SIZE_REMAINING ) { part->parts[i].size = master->size - offset; + move_offset =0 ; + }else { + move_offset =1 ; + }if (offset + part->parts[i].size > master->size) {pr_warn ("%s: partitioning exceeds flash size, truncating\n" , part->mtd_id); part->parts[i].size = master->size - offset; } - offset += part->parts[i].size; + +if (move_offset) + offset += part->parts[i].size;if (part->parts[i].size ==0 ) { pr_warn("%s: skipping zero sized partition\n",
Signature · 1 line
2.19.1
+Rafal for the subpartition stuff
Hi Daniel,
Quoted 5 lines · On Mon, 5 Nov 2018 14:37:52 +0100 Daniel Danzberger <[email protected]> wrote:
This allows to specify multiple -(name)
SIZE_REMAININGpartitions on the commandline parser.Example:
mtdparts=physmap-flash.0:256k(uboot),128k(params),-(firmware),1966080(kernel),-(rootfs)
Now that Rafal introduced sub-partitioning support I'd prefer to go for this solution. If I take your example, that would give something like:
mtdparts=physmap-flash.0:256k(uboot),128k(params),-(firmware);firmware:1966080(kernel),-(rootfs)
I'm not entirely sure, but I think all you'd have to do to support that is add "cmdline" to the default_subpartition_type[] array [1] (or simply use default_partition_type since default_subpartition_type and default_partition_type would be the same after this change).
Regards,
Boris
[1]https://elixir.bootlin.com/linux/latest/source/drivers/mtd/mtdpart.c#L800