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"'
76 dir505_board_detect() {
77 local dev=$(find_mtd_part 'mac')
78 [ -z "$dev" ] && return
80 # The revision is stored at the beginning of the "mac" partition
81 local rev="$(LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}' $dev)"
82 AR71XX_MODEL="D-Link DIR-505 rev. $rev"
88 part=$(find_mtd_part firmware)
89 [ -z "$part" ] && return 1
91 dd if=$part bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
97 part=$(find_mtd_part firmware)
98 [ -z "$part" ] && return 1
100 dd if=$part bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
103 tplink_board_detect() {
108 hwid=$(tplink_get_hwid)
109 mid=$(tplink_get_mid)
115 model="EasyLink EL-M150"
118 model="EasyLink EL-MINI"
130 model="MERCURY MAC1200R"
133 model="TellStick ZNet Lite"
136 model="OMYlink OMY-G1"
139 model="OMYlink OMY-X1"
148 model="TP-Link TL-WR703N"
151 model="TP-Link TL-WR710N"
153 if [ "$hwid" = '07100002' -a "$mid" = '00000002' ]; then
158 model="TP-Link TL-WR720N"
161 model="TP-Link TL-WA701N/ND"
164 model="TP-Link TL-WA730RE"
167 model="TP-Link TL-WR740N/ND"
170 model="TP-Link TL-WR741N/ND"
173 model="TP-Link TL-WR743N/ND"
176 model="TP-Link TL-WA750RE"
179 model="TP-Link TL-WA7210N"
182 model="TP-Link TL-WA7510N"
185 model="TP-Link TL-WA801N/ND"
188 model="TP-Link TL-WA830RE"
190 if [ "$hwver" = ' v10' ]; then
195 model="TP-Link TL-WR841N/ND"
197 if [ "$hwid" = '08410002' -a "$mid" = '00000002' ]; then
202 model="TP-Link TL-WR842N/ND"
205 model="TP-Link TL-WR843N/ND"
208 model="TP-Link TL-WA850RE"
211 model="TP-Link TL-WA860RE"
214 model="TP-Link TL-WA901N/ND"
217 if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
218 model="Rosewill RNX-N360RT"
221 model="TP-Link TL-WR941N/ND"
225 model="TP-Link TL-WR1041N/ND"
228 model="TP-Link TL-WR1043N/ND"
231 model="TP-Link TL-WR2543N/ND"
234 model="TP-Link TL-MR10U"
237 model="TP-Link TL-MR11U"
240 model="TP-Link TL-MR12U"
243 model="TP-Link TL-MR13U"
246 model="TP-Link TL-MR3020"
249 model="TP-Link TL-MR3040"
252 model="TP-Link TL-MR3220"
255 model="TP-Link TL-MR3420"
258 model="TP-Link TL-WDR3320"
261 model="TP-Link TL-WDR3500"
264 model="TP-Link TL-WDR3600"
267 model="TP-Link TL-WDR4300"
271 model="TP-Link TL-WDR4300 (IL)"
274 model="TP-Link TL-WDR4310"
277 model="TP-Link TL-WDR4900"
280 model="TP-Link TL-WDR6500"
283 model="Mercury MW4530R"
286 model="NC-LINK SMART-300"
289 model="TP-Link Archer C5"
293 model="TP-Link Archer C7"
300 AR71XX_MODEL="$model$hwver"
303 tplink_pharos_get_model_string() {
305 part=$(find_mtd_part 'product-info')
306 [ -z "$part" ] && return 1
308 # The returned string will end with \r\n, but we don't remove it here
309 # to simplify matching against it in the sysupgrade image check
310 dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1
313 tplink_pharos_board_detect() {
314 local model_string="$(tplink_pharos_get_model_string | tr -d '\r')"
315 local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS"
319 'CPE210(TP-LINK|UN|N300-2)')
320 model='TP-Link CPE210'
322 'CPE220(TP-LINK|UN|N300-2)')
323 model='TP-Link CPE220'
325 'CPE510(TP-LINK|UN|N300-5)')
326 model='TP-Link CPE510'
328 'CPE520(TP-LINK|UN|N300-5)')
329 model='TP-Link CPE520'
333 [ -n "$model" ] && AR71XX_MODEL="$model v$2"
336 gl_inet_board_detect() {
337 local size="$(mtd_get_part_size 'firmware')"
341 AR71XX_MODEL='GL-iNet 6408A v1'
344 AR71XX_MODEL='GL-iNet 6416A v1'
349 ar71xx_board_detect() {
353 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
371 *"ALFA Network AP120C")
374 *"ALFA Network AP96")
377 *"ALFA Network N2/N5")
401 *"AP121 reference board")
407 *"AP132 reference board")
410 *"AP136-010 reference board")
413 *"AP136-020 reference board")
416 *"AP135-020 reference board")
419 *"AP143 reference board")
422 *"AP147-010 reference board")
425 *"AP152 reference board")
455 *"COMFAST CF-E316N v2")
460 tplink_pharos_board_detect
464 tplink_pharos_board_detect
472 *"DB120 reference board")
509 *"dLAN pro 500 Wireless+")
510 name="dlan-pro-500-wp"
512 *"dLAN pro 1200+ WiFi ac")
513 name="dlan-pro-1200-ac"
539 *"GL-CONNECT INET v1")
580 name="nanostation-m-xw"
590 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
592 if [ "x$size" = "x00790000" ]; then
596 if [ "x$size" = "x00f90000" ]; then
642 *"WD My Net Wi-Fi Range Extender")
651 *"NBG460N/550N/550NH")
652 name="nbg460n_550n_550nh"
702 *"PB44 reference board")
711 *"RouterBOARD 411/A/AH")
717 *"RouterBOARD 433/AH")
720 *"RouterBOARD 433UAH")
732 *"RouterBOARD 493/AH")
741 *"RouterBOARD 750GL")
750 *"RouterBOARD 911G-2HPnD")
753 *"RouterBOARD 911G-5HPnD")
756 *"RouterBOARD 911G-5HPacD")
757 name="rb-911g-5hpacd"
759 *"RouterBOARD 912UAG-2HPnD")
760 name="rb-912uag-2hpnd"
762 *"RouterBOARD 912UAG-5HPnD")
763 name="rb-912uag-5hpnd"
765 *"RouterBOARD 951G-2HnD")
768 *"RouterBOARD 951Ui-2HnD")
771 *"RouterBOARD 2011L")
774 *"RouterBOARD 2011UAS")
777 *"RouterBOARD 2011UiAS")
780 *"RouterBOARD 2011UAS-2HnD")
781 name="rb-2011uas-2hnd"
783 *"RouterBOARD 2011UiAS-2HnD")
784 name="rb-2011uias-2hnd"
786 *"RouterBOARD SXT Lite2")
789 *"RouterBOARD SXT Lite5")
804 *"RouterStation Pro")
805 name="routerstation-pro"
813 "Smart Electronics Black Swift board"*)
816 *"Telldus TellStick ZNet Lite")
817 name="tellstick-znet-lite"
844 name="tl-wr1043nd-v2"
918 *"TL-WDR3600/4300/4310")
1015 name="unifi-outdoor"
1017 *"UniFiAP Outdoor+")
1018 name="unifi-outdoor-plus"
1041 *"WNDR3700/WNDR3800/WNDRMAC")
1042 wndr3700_board_detect "$machine"
1086 *"WZR-HP-AG300H/WZR-600DHP")
1087 name="wzr-hp-ag300h"
1090 name="wzr-hp-g300nh"
1096 name="wzr-hp-g300nh2"
1113 *EmbWir-Dorin-Router)
1114 name="ew-dorin-router"
1116 "8devices Carambola2"*)
1119 *"Sitecom WLR-8100")
1122 *"BHU BXU2000n-2 rev. A1")
1123 name="bxu2000n-2-a1"
1126 name="hiwifi-hc6361"
1130 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1131 tplink_board_detect "$machine"
1133 [ -z "$name" ] && name="unknown"
1135 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1136 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1138 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1140 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1141 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1144 ar71xx_board_name() {
1147 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1148 [ -z "$name" ] && name="unknown"