aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2015-03-29 12:58:01 +0000
committerJohn Crispin <blogic@openwrt.org>2015-03-29 12:58:01 +0000
commit6d82dac68ca2524949044a1bdfbeb62d7ab1a0e6 (patch)
tree6c76cfc5a5c8d8c4f9c69652aa5e4e52a05bb2ac /target/linux
parent8280dfe1ac982dc7ded67cb647f3bd2803dc2be1 (diff)
downloadmaster-187ad058-6d82dac68ca2524949044a1bdfbeb62d7ab1a0e6.tar.gz
master-187ad058-6d82dac68ca2524949044a1bdfbeb62d7ab1a0e6.tar.bz2
master-187ad058-6d82dac68ca2524949044a1bdfbeb62d7ab1a0e6.zip
ar71xx: fix model string detection on NETGEAR WNDR3700/3800/WNDRMAC
There were a few issues with the existing code to detect the model string: * Always using the string starting with byte 56 would cut off the W of WNDR when the ID starts with 29763654+16+64 instead of 29763654+16+128 * The string contained garbage after the zero byte instead of cutting it off after the zero (which wasn't always visible using busybox tools, but could confuse other scripts) Tested on a WNDR3700v1 and a WNDR3700v2 using the new 29763654+16+64 ID in the ART. Furthermore, tested against ART dumps of a WNDR3700v2 using the old $'\xff...' value and a WNDR3800. The [ -z "$model" ] check was dropped as there is no way to actually hit this unless no ART partition is found at all. The awk command was carefully crafted to work both with gawk and the (horribly broken) busybox awk. Fixes #18992. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@45140 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux')
-rwxr-xr-xtarget/linux/ar71xx/base-files/lib/ar71xx.sh28
1 files changed, 19 insertions, 9 deletions
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index d2fe6efeb3..802524c545 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -37,16 +37,26 @@ wndr3700_board_detect() {
machine="NETGEAR WNDR3700"
;;
"33373031")
- local model
- model=$(ar71xx_get_mtd_offset_size_format art 56 10 %c)
- if [ -z "$model" ] || [ "$model" = $'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' ]; then
- machine="NETGEAR WNDR3700v2"
- elif [ -z "$model" ] || [ "$model" = $'\xff\xff\xff\xff\xff\xff\xff\xff\xffN' ]; then
- machine="NETGEAR WNDRMAC"
- else
+ # Use awk to remove everything after the first zero byte
+ model="$(ar71xx_get_mtd_offset_size_format art 41 32 %c | awk 'BEGIN{FS="[[:cntrl:]]"} {print $1; exit}')"
+ case $model in
+ $'\xff'*)
+ if [ "${model:24:1}" = 'N' ]; then
+ machine="NETGEAR WNDRMAC"
+ else
+ machine="NETGEAR WNDR3700v2"
+ fi
+ ;;
+ '29763654+16+64'*)
+ machine="NETGEAR ${model:14}"
+ ;;
+ '29763654+16+128'*)
+ machine="NETGEAR ${model:15}"
+ ;;
+ *)
+ # Unknown ID
machine="NETGEAR $model"
- fi
- ;;
+ esac
esac
AR71XX_BOARD_NAME="$name"