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-G1"
130 model="OMYlink OMY-X1"
139 model="TP-Link TL-WR703N"
142 model="TP-Link TL-WR710N"
144 if [ "$hwid" = '07100002' -a "$mid" = '00000002' ]; then
149 model="TP-Link TL-WR720N"
152 model="TP-Link TL-WA701N/ND"
155 model="TP-Link TL-WA730RE"
158 model="TP-Link TL-WR740N/ND"
161 model="TP-Link TL-WR741N/ND"
164 model="TP-Link TL-WR743N/ND"
167 model="TP-Link TL-WA750RE"
170 model="TP-Link TL-WA7210N"
173 model="TP-Link TL-WA7510N"
176 model="TP-Link TL-WA801N/ND"
179 model="TP-Link TL-WA830RE"
181 if [ "$hwver" = ' v10' ]; then
186 model="TP-Link TL-WR841N/ND"
188 if [ "$hwid" = '08410002' -a "$mid" = '00000002' ]; then
193 model="TP-Link TL-WR842N/ND"
196 model="TP-Link TL-WR843N/ND"
199 model="TP-Link TL-WA850RE"
202 model="TP-Link TL-WA860RE"
205 model="TP-Link TL-WA901N/ND"
208 if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
209 model="Rosewill RNX-N360RT"
212 model="TP-Link TL-WR941N/ND"
216 model="TP-Link TL-WR1041N/ND"
219 model="TP-Link TL-WR1043N/ND"
222 model="TP-Link TL-WR2543N/ND"
225 model="TP-Link TL-MR10U"
228 model="TP-Link TL-MR11U"
231 model="TP-Link TL-MR12U"
234 model="TP-Link TL-MR13U"
237 model="TP-Link TL-MR3020"
240 model="TP-Link TL-MR3040"
243 model="TP-Link TL-MR3220"
246 model="TP-Link TL-MR3420"
249 model="TP-Link TL-WDR3320"
252 model="TP-Link TL-WDR3500"
255 model="TP-Link TL-WDR3600"
258 model="TP-Link TL-WDR4300"
262 model="TP-Link TL-WDR4300 (IL)"
265 model="TP-Link TL-WDR4310"
268 model="TP-Link TL-WDR4900"
271 model="TP-Link TL-WDR6500"
274 model="MERCURY MW4530R"
277 model="NC-LINK SMART-300"
280 model="TP-Link Archer C5"
284 model="TP-Link Archer C7"
291 AR71XX_MODEL="$model$hwver"
294 tplink_pharos_get_model_string() {
296 part=$(find_mtd_part 'product-info')
297 [ -z "$part" ] && return 1
299 # The returned string will end with \r\n, but we don't remove it here
300 # to simplify matching against it in the sysupgrade image check
301 dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1
304 tplink_pharos_board_detect() {
305 local model_string="$(tplink_pharos_get_model_string | tr -d '\r')"
306 local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS"
310 'CPE210(TP-LINK|UN|N300-2)')
311 model='TP-Link CPE210'
313 'CPE220(TP-LINK|UN|N300-2)')
314 model='TP-Link CPE220'
316 'CPE510(TP-LINK|UN|N300-5)')
317 model='TP-Link CPE510'
319 'CPE520(TP-LINK|UN|N300-5)')
320 model='TP-Link CPE520'
324 [ -n "$model" ] && AR71XX_MODEL="$model v$2"
327 gl_inet_board_detect() {
328 local size="$(mtd_get_part_size 'firmware')"
332 AR71XX_MODEL='GL-iNet 6408A v1'
335 AR71XX_MODEL='GL-iNet 6416A v1'
340 ar71xx_board_detect() {
344 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
362 *"ALFA Network AP120C")
365 *"ALFA Network AP96")
368 *"ALFA Network N2/N5")
392 *"AP121 reference board")
398 *"AP132 reference board")
401 *"AP136-010 reference board")
404 *"AP136-020 reference board")
407 *"AP135-020 reference board")
410 *"AP143 reference board")
413 *"AP147-010 reference board")
416 *"AP152 reference board")
446 *"COMFAST CF-E316N v2")
449 *"CPE210/220/510/520")
451 tplink_pharos_board_detect
459 *"DB120 reference board")
495 *"dLAN pro 500 Wireless+")
496 name="dlan-pro-500-wp"
498 *"dLAN pro 1200+ WiFi ac")
499 name="dlan-pro-1200-ac"
522 *"GL-CONNECT INET v1")
557 name="nanostation-m-xw"
564 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
566 if [ "x$size" = "x00790000" ]; then
570 if [ "x$size" = "x00f90000" ]; then
613 *"WD My Net Wi-Fi Range Extender")
622 *"NBG460N/550N/550NH")
623 name="nbg460n_550n_550nh"
670 *"PB44 reference board")
679 *"RouterBOARD 411/A/AH")
685 *"RouterBOARD 433/AH")
688 *"RouterBOARD 433UAH")
700 *"RouterBOARD 493/AH")
709 *"RouterBOARD 750GL")
718 *"RouterBOARD 911G-2HPnD")
721 *"RouterBOARD 911G-5HPnD")
724 *"RouterBOARD 911G-5HPacD")
725 name="rb-911g-5hpacd"
727 *"RouterBOARD 912UAG-2HPnD")
728 name="rb-912uag-2hpnd"
730 *"RouterBOARD 912UAG-5HPnD")
731 name="rb-912uag-5hpnd"
733 *"RouterBOARD 951G-2HnD")
736 *"RouterBOARD 951Ui-2HnD")
739 *"RouterBOARD 2011L")
742 *"RouterBOARD 2011UAS")
745 *"RouterBOARD 2011UiAS")
748 *"RouterBOARD 2011UAS-2HnD")
749 name="rb-2011uas-2hnd"
751 *"RouterBOARD 2011UiAS-2HnD")
752 name="rb-2011uias-2hnd"
754 *"RouterBOARD SXT Lite2")
757 *"RouterBOARD SXT Lite5")
772 *"RouterStation Pro")
773 name="routerstation-pro"
781 "Smart Electronics Black Swift board"*)
784 *"Telldus TellStick ZNet Lite")
785 name="tellstick-znet-lite"
809 name="tl-wr1043nd-v2"
883 *"TL-WDR3600/4300/4310")
980 name="unifi-outdoor-plus"
1003 *"WNDR3700/WNDR3800/WNDRMAC")
1004 wndr3700_board_detect "$machine"
1045 *"WZR-HP-AG300H/WZR-600DHP")
1046 name="wzr-hp-ag300h"
1049 name="wzr-hp-g300nh"
1055 name="wzr-hp-g300nh2"
1069 *EmbWir-Dorin-Router)
1070 name="ew-dorin-router"
1072 "8devices Carambola2"*)
1075 *"Sitecom WLR-8100")
1078 *"BHU BXU2000n-2 rev. A1")
1079 name="bxu2000n-2-a1"
1082 name="hiwifi-hc6361"
1086 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1087 tplink_board_detect "$machine"
1089 [ -z "$name" ] && name="unknown"
1091 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1092 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1094 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1096 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1097 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1100 ar71xx_board_name() {
1103 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1104 [ -z "$name" ] && name="unknown"