Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patches: update TP-Link CPE210v2-support
update openwrt/openwrt#642, seems like this patch waas incomplete before
- Loading branch information
1 parent
61ddf4f
commit 006df45
Showing
3 changed files
with
142 additions
and
92 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
patches/007-Add_TP-Link_Pharos_v2_board_detection.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,104 @@ | ||
commit 251906597f5aa3d06b96ae7368d11a4959e64c96 | ||
Author: Robert Marko <robimarko@gmail.com> | ||
Date: Fri Jan 19 12:58:40 2018 +0100 | ||
|
||
ar71xx: Add TP-Link Pharos v2 board detection | ||
|
||
Add support for detecting TP-Link Pharos v2 boards. | ||
They use different format in product-info partition than v1 boards. | ||
|
||
Code for this patch was written by Alexander Couzens <lynxis@fe80.eu> | ||
|
||
Signed-off-by: Robert Marko <robimarko@gmail.com> | ||
|
||
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh | ||
index b6642495de..c40c83f5dd 100755 | ||
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh | ||
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh | ||
@@ -361,6 +361,25 @@ tplink_pharos_board_detect() { | ||
AR71XX_MODEL="TP-Link $model v$2" | ||
} | ||
|
||
+tplink_pharos_v2_get_model_string() { | ||
+ local part | ||
+ part=$(find_mtd_part 'product-info') | ||
+ [ -z "$part" ] && return 1 | ||
+ | ||
+ # The returned string will end with \r\n, but we don't remove it here | ||
+ # to simplify matching against it in the sysupgrade image check | ||
+ dd if=$part bs=1 skip=4360 count=64 2>/dev/null | tr -d '\r\0' | head -n 1 | ||
+} | ||
+ | ||
+tplink_pharos_v2_board_detect() { | ||
+ local model_string="$(tplink_pharos_v2_get_model_string)" | ||
+ local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS" | ||
+ | ||
+ local model="${1%%\(*}" | ||
+ | ||
+ AR71XX_MODEL="TP-Link $model v$2" | ||
+} | ||
+ | ||
ar71xx_board_detect() { | ||
local machine | ||
local name | ||
@@ -532,6 +551,10 @@ ar71xx_board_detect() { | ||
name="cpe210" | ||
tplink_pharos_board_detect | ||
;; | ||
+ *"CPE210 v2") | ||
+ name="cpe210-v2" | ||
+ tplink_pharos_v2_board_detect | ||
+ ;; | ||
*"CPE505N") | ||
name="cpe505n" | ||
;; | ||
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh | ||
index 3d7b1593e1..1ed6882741 100755 | ||
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh | ||
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh | ||
@@ -120,6 +120,34 @@ tplink_pharos_check_image() { | ||
return 0 | ||
} | ||
|
||
+tplink_pharos_v2_check_image() { | ||
+ local image_magic="$(get_magic_long "$1")" | ||
+ local board_magic="$2" | ||
+ [ "$image_magic" != "$board_magic" ] && { | ||
+ echo "Invalid image magic '$image_magic'. Expected '$board_magic'." | ||
+ return 1 | ||
+ } | ||
+ | ||
+ local model_string="$(tplink_pharos_v2_get_model_string)" | ||
+ local line | ||
+ | ||
+ # Here $1 is given to dd directly instead of get_image as otherwise the skip | ||
+ # will take almost a second (as dd can't seek then) | ||
+ # | ||
+ # This will fail if the image isn't local, but that's fine: as the | ||
+ # read loop won't be executed at all, it will return true, so the image | ||
+ # is accepted (loading the first 1.5M of a remote image for this check seems | ||
+ # a bit extreme) | ||
+ dd if="$1" bs=1 skip=1511432 count=1024 2>/dev/null | tr -d '\0\xff\r' | while read line; do | ||
+ [ "$line" = "$model_string" ] && break | ||
+ done || { | ||
+ echo "Unsupported image (model not in support-list)" | ||
+ return 1 | ||
+ } | ||
+ | ||
+ return 0 | ||
+} | ||
+ | ||
seama_get_type_magic() { | ||
get_image "$@" | dd bs=1 count=4 skip=53 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' | ||
} | ||
@@ -550,6 +578,10 @@ platform_check_image() { | ||
tplink_pharos_check_image "$1" && return 0 | ||
return 1 | ||
;; | ||
+ cpe210-v2) | ||
+ tplink_pharos_v2_check_image "$1" "01000000" && return 0 | ||
+ return 1 | ||
+ ;; | ||
a40|\ | ||
a60|\ | ||
mr1750|\ |
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