ar71xx-generic: backport a few TP-Link model detection and upgrade check patches

This commit is contained in:
Matthias Schiffer 2016-04-02 00:54:07 +02:00
parent 4f051061de
commit 196722663a
3 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,48 @@
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Fri, 1 Apr 2016 23:16:13 +0200
Subject: ar71xx: check both HWID and HWREV on upgrades of TP-LINK devices
There's no reason for us to be more lenient than the stock firmware, so
better check the HWREV as well to avoid bricked devices.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Backport of r49105
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 2fc1d10..420b794 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -66,6 +66,10 @@ tplink_get_image_hwid() {
get_image "$@" | dd bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
}
+tplink_get_image_mid() {
+ get_image "$@" | dd bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
tplink_get_image_boot_size() {
get_image "$@" | dd bs=4 count=1 skip=37 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
}
@@ -365,13 +369,17 @@ platform_check_image() {
}
local hwid
- local imageid
+ local mid
+ local imagehwid
+ local imagemid
hwid=$(tplink_get_hwid)
- imageid=$(tplink_get_image_hwid "$1")
+ mid=$(tplink_get_mid)
+ imagehwid=$(tplink_get_image_hwid "$1")
+ imagemid=$(tplink_get_image_mid "$1")
- [ "$hwid" != "$imageid" ] && {
- echo "Invalid image, hardware ID mismatch, hw:$hwid image:$imageid."
+ [ "$hwid" != "$imagehwid" -o "$mid" != "$imagemid" ] && {
+ echo "Invalid image, hardware ID mismatch, hw:$hwid $mid image:$imagehwid $imagemid."
return 1
}

View File

@ -0,0 +1,45 @@
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Fri, 1 Apr 2016 23:19:16 +0200
Subject: ar71xx: avoid AR71XX_MODEL ending with a space on some TP-LINK-like devices
Instead of adding the space when combining $model and $hwver, add the space
to the beginning of $hwver, so the resulting string won't end with a space
when $hwver is set to the empty string.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Backport of r49106
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 7f50d8a..9d650a1 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -133,7 +133,7 @@ tplink_board_detect() {
hwid=$(tplink_get_hwid)
mid=$(tplink_get_mid)
hwver=${hwid:6:2}
- hwver="v${hwver#0}"
+ hwver=" v${hwver#0}"
case "$hwid" in
"015000"*)
@@ -196,8 +196,8 @@ tplink_board_detect() {
"083000"*)
model="TP-Link TL-WA830RE"
- if [ "$hwver" = 'v10' ]; then
- hwver='v1'
+ if [ "$hwver" = ' v10' ]; then
+ hwver=' v1'
fi
;;
"084100"*)
@@ -296,7 +296,7 @@ tplink_board_detect() {
;;
esac
- AR71XX_MODEL="$model $hwver"
+ AR71XX_MODEL="$model$hwver"
}
tplink_pharos_get_model_string() {

View File

@ -0,0 +1,39 @@
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Fri, 1 Apr 2016 23:21:32 +0200
Subject: ar71xx: fix the revision of a few TP-LINK devices in AR71XX_MODEL to match labels/image names
Let's not confuse users about the revisions of their devices when we can
easily avoid it.
Not tested on real hardware.
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Backport of r49107
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 9d650a1..52ca255 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -162,6 +162,10 @@ tplink_board_detect() {
;;
"071000"*)
model="TP-Link TL-WR710N"
+
+ if [ "$hwid" = '07100002' -a "$mid" = '00000002' ]; then
+ hwver=' v2.1'
+ fi
;;
"072001"*)
model="TP-Link TL-WR720N"
@@ -202,6 +206,10 @@ tplink_board_detect() {
;;
"084100"*)
model="TP-Link TL-WR841N/ND"
+
+ if [ "$hwid" = '08410002' -a "$mid" = '00000002' ]; then
+ hwver=' v1.5'
+ fi
;;
"084200"*)
model="TP-Link TL-WR842N/ND"