3 # Copyright (C) 2009-2011 OpenWrt.org
9 ar71xx_get_mtd_offset_size_format() {
16 dev=$(find_mtd_part $mtd)
17 [ -z "$dev" ] && return
19 dd if=$dev bs=1 skip=$offset count=$size 2>/dev/null | hexdump -v -e "1/1 \"$format\""
22 ar71xx_get_mtd_part_magic() {
24 ar71xx_get_mtd_offset_size_format "$mtd" 0 4 %02x
27 wndr3700_board_detect() {
34 magic="$(ar71xx_get_mtd_part_magic firmware)"
37 machine="NETGEAR WNDR3700"
40 model="$(ar71xx_get_mtd_offset_size_format art 41 32 %c)"
41 # Use awk to remove everything unprintable
42 model_stripped="$(ar71xx_get_mtd_offset_size_format art 41 32 %c | LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}')"
45 if [ "${model:24:1}" = 'N' ]; then
46 machine="NETGEAR WNDRMAC"
48 machine="NETGEAR WNDR3700v2"
52 machine="NETGEAR ${model_stripped:14}"
55 machine="NETGEAR ${model_stripped:15}"
59 machine="NETGEAR ${model_stripped}"
63 AR71XX_BOARD_NAME="$name"
64 AR71XX_MODEL="$machine"
67 cybertan_get_hw_magic() {
70 part=$(find_mtd_part firmware)
71 [ -z "$part" ] && return 1
73 dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
79 part=$(find_mtd_part firmware)
80 [ -z "$part" ] && return 1
82 dd if=$part bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
88 part=$(find_mtd_part firmware)
89 [ -z "$part" ] && return 1
91 dd if=$part bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
94 tplink_board_detect() {
99 hwid=$(tplink_get_hwid)
100 mid=$(tplink_get_mid)
106 model="EasyLink EL-M150"
109 model="EasyLink EL-MINI"
121 model="MERCURY MAC1200R"
124 model="TellStick ZNet Lite"
127 model="OMYlink OMY-X1"
136 model="TP-Link TL-WR703N"
139 model="TP-Link TL-WR710N"
141 if [ "$hwid" = '07100002' -a "$mid" = '00000002' ]; then
146 model="TP-Link TL-WR720N"
149 model="TP-Link TL-WA701N/ND"
152 model="TP-Link TL-WA730RE"
155 model="TP-Link TL-WR740N/ND"
158 model="TP-Link TL-WR741N/ND"
161 model="TP-Link TL-WR743N/ND"
164 model="TP-Link TL-WA750RE"
167 model="TP-Link TL-WA7210N"
170 model="TP-Link TL-WA7510N"
173 model="TP-Link TL-WA801N/ND"
176 model="TP-Link TL-WA830RE"
178 if [ "$hwver" = ' v10' ]; then
183 model="TP-Link TL-WR841N/ND"
185 if [ "$hwid" = '08410002' -a "$mid" = '00000002' ]; then
190 model="TP-Link TL-WR842N/ND"
193 model="TP-Link TL-WR843N/ND"
196 model="TP-Link TL-WA850RE"
199 model="TP-Link TL-WA860RE"
202 model="TP-Link TL-WA901N/ND"
205 if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
206 model="Rosewill RNX-N360RT"
209 model="TP-Link TL-WR941N/ND"
213 model="TP-Link TL-WR1041N/ND"
216 model="TP-Link TL-WR1043N/ND"
219 model="TP-Link TL-WR2543N/ND"
222 model="TP-Link TL-MR10U"
225 model="TP-Link TL-MR11U"
228 model="TP-Link TL-MR12U"
231 model="TP-Link TL-MR13U"
234 model="TP-Link TL-MR3020"
237 model="TP-Link TL-MR3040"
240 model="TP-Link TL-MR3220"
243 model="TP-Link TL-MR3420"
246 model="TP-Link TL-WDR3320"
249 model="TP-Link TL-WDR3500"
252 model="TP-Link TL-WDR3600"
255 model="TP-Link TL-WDR4300"
259 model="TP-Link TL-WDR4300 (IL)"
262 model="TP-Link TL-WDR4310"
265 model="TP-Link TL-WDR4900"
268 model="TP-Link TL-WDR6500"
271 model="MERCURY MW4530R"
274 model="NC-LINK SMART-300"
277 model="TP-Link Archer C5"
281 model="TP-Link Archer C7"
288 AR71XX_MODEL="$model$hwver"
291 tplink_pharos_get_model_string() {
293 part=$(find_mtd_part 'product-info')
294 [ -z "$part" ] && return 1
296 # The returned string will end with \r\n, but we don't remove it here
297 # to simplify matching against it in the sysupgrade image check
298 dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1
301 tplink_pharos_board_detect() {
302 local model_string="$(tplink_pharos_get_model_string | tr -d '\r')"
303 local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS"
307 'CPE210(TP-LINK|UN|N300-2)')
308 model='TP-Link CPE210'
310 'CPE220(TP-LINK|UN|N300-2)')
311 model='TP-Link CPE220'
313 'CPE510(TP-LINK|UN|N300-5)')
314 model='TP-Link CPE510'
316 'CPE520(TP-LINK|UN|N300-5)')
317 model='TP-Link CPE520'
321 [ -n "$model" ] && AR71XX_MODEL="$model v$2"
324 gl_inet_board_detect() {
325 local size="$(mtd_get_part_size 'firmware')"
329 AR71XX_MODEL='GL-iNet 6408A v1'
332 AR71XX_MODEL='GL-iNet 6416A v1'
337 ar71xx_board_detect() {
341 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
359 *"ALFA Network AP120C")
362 *"ALFA Network AP96")
365 *"ALFA Network N2/N5")
389 *"AP121 reference board")
395 *"AP132 reference board")
398 *"AP136-010 reference board")
401 *"AP136-020 reference board")
404 *"AP135-020 reference board")
407 *"AP143 reference board")
410 *"AP147-010 reference board")
413 *"AP152 reference board")
443 *"COMFAST CF-E316N v2")
446 *"CPE210/220/510/520")
448 tplink_pharos_board_detect
456 *"DB120 reference board")
492 *"dLAN pro 500 Wireless+")
493 name="dlan-pro-500-wp"
495 *"dLAN pro 1200+ WiFi ac")
496 name="dlan-pro-1200-ac"
519 *"GL-CONNECT INET v1")
554 name="nanostation-m-xw"
561 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
563 if [ "x$size" = "x00790000" ]; then
567 if [ "x$size" = "x00f90000" ]; then
610 *"WD My Net Wi-Fi Range Extender")
619 *"NBG460N/550N/550NH")
620 name="nbg460n_550n_550nh"
664 *"PB44 reference board")
673 *"RouterBOARD 411/A/AH")
679 *"RouterBOARD 433/AH")
682 *"RouterBOARD 433UAH")
694 *"RouterBOARD 493/AH")
703 *"RouterBOARD 750GL")
712 *"RouterBOARD 911G-2HPnD")
715 *"RouterBOARD 911G-5HPnD")
718 *"RouterBOARD 911G-5HPacD")
719 name="rb-911g-5hpacd"
721 *"RouterBOARD 912UAG-2HPnD")
722 name="rb-912uag-2hpnd"
724 *"RouterBOARD 912UAG-5HPnD")
725 name="rb-912uag-5hpnd"
727 *"RouterBOARD 951G-2HnD")
730 *"RouterBOARD 951Ui-2HnD")
733 *"RouterBOARD 2011L")
736 *"RouterBOARD 2011UAS")
739 *"RouterBOARD 2011UiAS")
742 *"RouterBOARD 2011UAS-2HnD")
743 name="rb-2011uas-2hnd"
745 *"RouterBOARD 2011UiAS-2HnD")
746 name="rb-2011uias-2hnd"
748 *"RouterBOARD SXT Lite2")
751 *"RouterBOARD SXT Lite5")
766 *"RouterStation Pro")
767 name="routerstation-pro"
775 "Smart Electronics Black Swift board"*)
778 *"Telldus TellStick ZNet Lite")
779 name="tellstick-znet-lite"
803 name="tl-wr1043nd-v2"
874 *"TL-WDR3600/4300/4310")
962 name="unifi-outdoor-plus"
982 *"WNDR3700/WNDR3800/WNDRMAC")
983 wndr3700_board_detect "$machine"
1024 *"WZR-HP-AG300H/WZR-600DHP")
1025 name="wzr-hp-ag300h"
1028 name="wzr-hp-g300nh"
1034 name="wzr-hp-g300nh2"
1048 *EmbWir-Dorin-Router)
1049 name="ew-dorin-router"
1051 "8devices Carambola2"*)
1054 *"Sitecom WLR-8100")
1057 *"BHU BXU2000n-2 rev. A1")
1058 name="bxu2000n-2-a1"
1061 name="hiwifi-hc6361"
1065 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1066 tplink_board_detect "$machine"
1068 [ -z "$name" ] && name="unknown"
1070 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1071 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1073 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1075 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1076 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1079 ar71xx_board_name() {
1082 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1083 [ -z "$name" ] && name="unknown"