Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ramips: mt7621: Add Dual Partition support, for Linksys EA7300v2 and …
…EA7500v2 Enable dual partition operation for these Linksys routers - program to the alternative partition (similar to other dual partition routers). Tested and working. Signed-off-by: Russell Morris <rmorris@rkmorris.us>
- Loading branch information
Showing
7 changed files
with
215 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
target/linux/ramips/mt7621/base-files/lib/upgrade/linksys.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# Copyright (C) 2014 OpenWrt.org | ||
# | ||
|
||
linksys_get_target_firmware() { | ||
|
||
local cur_boot_part mtd_ubi0 | ||
|
||
cur_boot_part=$(/usr/sbin/fw_printenv -n boot_part) | ||
if [ -z "${cur_boot_part}" ] ; then | ||
mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num) | ||
case $(grep -E ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in | ||
kernel|rootfs) | ||
cur_boot_part=1 | ||
;; | ||
alt_kernel|alt_rootfs) | ||
cur_boot_part=2 | ||
;; | ||
esac | ||
>&2 printf "Current boot_part='%s' selected from ubi0/mtd_num='%s'" \ | ||
"${cur_boot_part}" "${mtd_ubi0}" | ||
fi | ||
|
||
case $cur_boot_part in | ||
1) | ||
fw_setenv -s - <<-EOF | ||
boot_part 2 | ||
bootcmd "run altnandboot" | ||
EOF | ||
printf "kernel2" | ||
return | ||
;; | ||
2) | ||
fw_setenv -s - <<-EOF | ||
boot_part 1 | ||
bootcmd "run nandboot" | ||
EOF | ||
printf "kernel1" | ||
return | ||
;; | ||
*) | ||
return | ||
;; | ||
esac | ||
} | ||
|
||
platform_do_upgrade_linksys() { | ||
local magic_long="$(get_magic_long "$1")" | ||
|
||
mkdir -p /var/lock | ||
local part_label="$(linksys_get_target_firmware)" | ||
touch /var/lock/fw_printenv.lock | ||
|
||
if [ ! -n "$part_label" ] | ||
then | ||
echo "cannot find target partition" | ||
exit 1 | ||
fi | ||
|
||
local target_mtd=$(find_mtd_part $part_label) | ||
|
||
[ "$magic_long" = "73797375" ] && { | ||
CI_KERNPART="$part_label" | ||
if [ "$part_label" = "kernel1" ] | ||
then | ||
CI_UBIPART="rootfs1" | ||
else | ||
CI_UBIPART="rootfs2" | ||
fi | ||
|
||
nand_upgrade_tar "$1" | ||
} | ||
[ "$magic_long" = "27051956" ] && { | ||
get_image "$1" | mtd write - $part_label | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
target/linux/ramips/patches-5.10/202-linksys-find-active-root.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
The WRT1900AC among other Linksys routers uses a dual-firmware layout. | ||
Dynamically rename the active partition to "ubi". | ||
|
||
Signed-off-by: Imre Kaloz <kaloz@openwrt.org> | ||
--- | ||
--- a/drivers/mtd/parsers/ofpart_core.c | ||
+++ b/drivers/mtd/parsers/ofpart_core.c | ||
@@ -38,6 +38,8 @@ static bool node_has_compatible(struct d | ||
return of_get_property(pp, "compatible", NULL); | ||
} | ||
|
||
+static int mangled_rootblock; | ||
+ | ||
static int parse_fixed_partitions(struct mtd_info *master, | ||
const struct mtd_partition **pparts, | ||
struct mtd_part_parser_data *data) | ||
@@ -47,6 +49,7 @@ static int parse_fixed_partitions(struct | ||
struct mtd_partition *parts; | ||
struct device_node *mtd_node; | ||
struct device_node *ofpart_node; | ||
+ const char *owrtpart = "ubi"; | ||
const char *partname; | ||
struct device_node *pp; | ||
int nr_parts, i, ret = 0; | ||
@@ -133,9 +136,15 @@ static int parse_fixed_partitions(struct | ||
parts[i].size = of_read_number(reg + a_cells, s_cells); | ||
parts[i].of_node = pp; | ||
|
||
- 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); | ||
+ } | ||
+ | ||
parts[i].name = partname; | ||
|
||
if (of_get_property(pp, "read-only", &len)) | ||
@@ -252,6 +261,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); |
62 changes: 62 additions & 0 deletions
62
target/linux/ramips/patches-5.15/202-linksys-find-active-root.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
The WRT1900AC among other Linksys routers uses a dual-firmware layout. | ||
Dynamically rename the active partition to "ubi". | ||
|
||
Signed-off-by: Imre Kaloz <kaloz@openwrt.org> | ||
--- | ||
--- a/drivers/mtd/parsers/ofpart_core.c | ||
+++ b/drivers/mtd/parsers/ofpart_core.c | ||
@@ -38,6 +38,8 @@ static bool node_has_compatible(struct d | ||
return of_get_property(pp, "compatible", NULL); | ||
} | ||
|
||
+static int mangled_rootblock; | ||
+ | ||
static int parse_fixed_partitions(struct mtd_info *master, | ||
const struct mtd_partition **pparts, | ||
struct mtd_part_parser_data *data) | ||
@@ -47,6 +49,7 @@ static int parse_fixed_partitions(struct | ||
struct mtd_partition *parts; | ||
struct device_node *mtd_node; | ||
struct device_node *ofpart_node; | ||
+ const char *owrtpart = "ubi"; | ||
const char *partname; | ||
struct device_node *pp; | ||
int nr_parts, i, ret = 0; | ||
@@ -133,9 +136,15 @@ static int parse_fixed_partitions(struct | ||
parts[i].size = of_read_number(reg + a_cells, s_cells); | ||
parts[i].of_node = pp; | ||
|
||
- 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); | ||
+ } | ||
+ | ||
parts[i].name = partname; | ||
|
||
if (of_get_property(pp, "read-only", &len)) | ||
@@ -252,6 +261,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); |