[OpenWrt-Devel] [PATCH 3/7] kirkwood: find active Linksys root partition

Claudio Leite leitec at staticky.com
Fri Nov 6 21:29:10 EST 2015


This is imported verbatim from the mvebu WRT1900AC port.

It picks up the current boot partition from the kernel command line,
then renames that partition "ubi" so that it auto-mounts.

Signed-off-by: Claudio Leite <leitec at staticky.com>
---
 target/linux/kirkwood/config-3.18                  |  1 +
 target/linux/kirkwood/config-4.3                   |  1 +
 .../patches-3.18/100-find_active_root.patch        | 61 ++++++++++++++++++++++
 .../patches-4.3/100-find_active_root.patch         | 61 ++++++++++++++++++++++
 4 files changed, 124 insertions(+)
 create mode 100644 target/linux/kirkwood/patches-3.18/100-find_active_root.patch
 create mode 100644 target/linux/kirkwood/patches-4.3/100-find_active_root.patch

diff --git a/target/linux/kirkwood/config-3.18 b/target/linux/kirkwood/config-3.18
index b936ba9..17b2819 100644
--- a/target/linux/kirkwood/config-3.18
+++ b/target/linux/kirkwood/config-3.18
@@ -189,6 +189,7 @@ CONFIG_LZO_DECOMPRESS=y
 CONFIG_MACH_KIRKWOOD=y
 CONFIG_MACH_MVEBU_ANY=y
 # CONFIG_MACH_NETXBIG is not set
+CONFIG_MANGLE_BOOTARGS=y
 CONFIG_MDIO_BOARDINFO=y
 CONFIG_MIGHT_HAVE_PCI=y
 CONFIG_MMC=y
diff --git a/target/linux/kirkwood/config-4.3 b/target/linux/kirkwood/config-4.3
index 86eace5..1e68af5 100644
--- a/target/linux/kirkwood/config-4.3
+++ b/target/linux/kirkwood/config-4.3
@@ -197,6 +197,7 @@ CONFIG_MAC80211_STA_HASH_MAX_SIZE=0
 CONFIG_MACH_KIRKWOOD=y
 CONFIG_MACH_MVEBU_ANY=y
 # CONFIG_MACH_NETXBIG is not set
+CONFIG_MANGLE_BOOTARGS=y
 CONFIG_MDIO_BOARDINFO=y
 CONFIG_MIGHT_HAVE_PCI=y
 CONFIG_MMC=y
diff --git a/target/linux/kirkwood/patches-3.18/100-find_active_root.patch b/target/linux/kirkwood/patches-3.18/100-find_active_root.patch
new file mode 100644
index 0000000..e32b608
--- /dev/null
+++ b/target/linux/kirkwood/patches-3.18/100-find_active_root.patch
@@ -0,0 +1,61 @@
+The WRT1900AC among other Linksys routers uses a dual-firmware layout.
+Dynamically rename the active partition to "ubi".
+
+Signed-off-by: Imre Kaloz <kaloz at openwrt.org>
+
+--- a/drivers/mtd/ofpart.c
++++ b/drivers/mtd/ofpart.c
+@@ -25,12 +25,15 @@ static bool node_has_compatible(struct d
+ 	return of_get_property(pp, "compatible", NULL);
+ }
+ 
++static int mangled_rootblock;
++
+ static int parse_ofpart_partitions(struct mtd_info *master,
+ 				   struct mtd_partition **pparts,
+ 				   struct mtd_part_parser_data *data)
+ {
+ 	struct device_node *node;
+ 	const char *partname;
++	const char *owrtpart = "ubi";
+ 	struct device_node *pp;
+ 	int nr_parts, i;
+ 
+@@ -78,9 +81,15 @@ static int parse_ofpart_partitions(struc
+ 		(*pparts)[i].offset = of_read_number(reg, a_cells);
+ 		(*pparts)[i].size = of_read_number(reg + a_cells, s_cells);
+ 
+-		partname = of_get_property(pp, "label", &len);
+-		if (!partname)
+-			partname = of_get_property(pp, "name", &len);
++		if (mangled_rootblock && (i == mangled_rootblock)) {
++				partname = owrtpart;
++		} else {
++			partname = of_get_property(pp, "label", &len);
++
++			if (!partname)
++				partname = of_get_property(pp, "name", &len);
++		}
++
+ 		(*pparts)[i].name = partname;
+ 
+ 		if (of_get_property(pp, "read-only", &len))
+@@ -178,6 +187,18 @@ static int __init ofpart_parser_init(voi
+ 	return 0;
+ }
+ 
++static int __init active_root(char *str)
++{
++	get_option(&str, &mangled_rootblock);
++
++	if (!mangled_rootblock)
++		return 1;
++
++	return 1;
++}
++
++__setup("mangled_rootblock=", active_root);
++
+ static void __exit ofpart_parser_exit(void)
+ {
+ 	deregister_mtd_parser(&ofpart_parser);
diff --git a/target/linux/kirkwood/patches-4.3/100-find_active_root.patch b/target/linux/kirkwood/patches-4.3/100-find_active_root.patch
new file mode 100644
index 0000000..e32b608
--- /dev/null
+++ b/target/linux/kirkwood/patches-4.3/100-find_active_root.patch
@@ -0,0 +1,61 @@
+The WRT1900AC among other Linksys routers uses a dual-firmware layout.
+Dynamically rename the active partition to "ubi".
+
+Signed-off-by: Imre Kaloz <kaloz at openwrt.org>
+
+--- a/drivers/mtd/ofpart.c
++++ b/drivers/mtd/ofpart.c
+@@ -25,12 +25,15 @@ static bool node_has_compatible(struct d
+ 	return of_get_property(pp, "compatible", NULL);
+ }
+ 
++static int mangled_rootblock;
++
+ static int parse_ofpart_partitions(struct mtd_info *master,
+ 				   struct mtd_partition **pparts,
+ 				   struct mtd_part_parser_data *data)
+ {
+ 	struct device_node *node;
+ 	const char *partname;
++	const char *owrtpart = "ubi";
+ 	struct device_node *pp;
+ 	int nr_parts, i;
+ 
+@@ -78,9 +81,15 @@ static int parse_ofpart_partitions(struc
+ 		(*pparts)[i].offset = of_read_number(reg, a_cells);
+ 		(*pparts)[i].size = of_read_number(reg + a_cells, s_cells);
+ 
+-		partname = of_get_property(pp, "label", &len);
+-		if (!partname)
+-			partname = of_get_property(pp, "name", &len);
++		if (mangled_rootblock && (i == mangled_rootblock)) {
++				partname = owrtpart;
++		} else {
++			partname = of_get_property(pp, "label", &len);
++
++			if (!partname)
++				partname = of_get_property(pp, "name", &len);
++		}
++
+ 		(*pparts)[i].name = partname;
+ 
+ 		if (of_get_property(pp, "read-only", &len))
+@@ -178,6 +187,18 @@ static int __init ofpart_parser_init(voi
+ 	return 0;
+ }
+ 
++static int __init active_root(char *str)
++{
++	get_option(&str, &mangled_rootblock);
++
++	if (!mangled_rootblock)
++		return 1;
++
++	return 1;
++}
++
++__setup("mangled_rootblock=", active_root);
++
+ static void __exit ofpart_parser_exit(void)
+ {
+ 	deregister_mtd_parser(&ofpart_parser);
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list