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")
451 tplink_pharos_board_detect
455 tplink_pharos_board_detect
463 *"DB120 reference board")
499 *"dLAN pro 500 Wireless+")
500 name="dlan-pro-500-wp"
502 *"dLAN pro 1200+ WiFi ac")
503 name="dlan-pro-1200-ac"
529 *"GL-CONNECT INET v1")
570 name="nanostation-m-xw"
580 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
582 if [ "x$size" = "x00790000" ]; then
586 if [ "x$size" = "x00f90000" ]; then
632 *"WD My Net Wi-Fi Range Extender")
641 *"NBG460N/550N/550NH")
642 name="nbg460n_550n_550nh"
692 *"PB44 reference board")
701 *"RouterBOARD 411/A/AH")
707 *"RouterBOARD 433/AH")
710 *"RouterBOARD 433UAH")
722 *"RouterBOARD 493/AH")
731 *"RouterBOARD 750GL")
740 *"RouterBOARD 911G-2HPnD")
743 *"RouterBOARD 911G-5HPnD")
746 *"RouterBOARD 911G-5HPacD")
747 name="rb-911g-5hpacd"
749 *"RouterBOARD 912UAG-2HPnD")
750 name="rb-912uag-2hpnd"
752 *"RouterBOARD 912UAG-5HPnD")
753 name="rb-912uag-5hpnd"
755 *"RouterBOARD 951G-2HnD")
758 *"RouterBOARD 951Ui-2HnD")
761 *"RouterBOARD 2011L")
764 *"RouterBOARD 2011UAS")
767 *"RouterBOARD 2011UiAS")
770 *"RouterBOARD 2011UAS-2HnD")
771 name="rb-2011uas-2hnd"
773 *"RouterBOARD 2011UiAS-2HnD")
774 name="rb-2011uias-2hnd"
776 *"RouterBOARD SXT Lite2")
779 *"RouterBOARD SXT Lite5")
794 *"RouterStation Pro")
795 name="routerstation-pro"
803 "Smart Electronics Black Swift board"*)
806 *"Telldus TellStick ZNet Lite")
807 name="tellstick-znet-lite"
834 name="tl-wr1043nd-v2"
908 *"TL-WDR3600/4300/4310")
1005 name="unifi-outdoor"
1007 *"UniFiAP Outdoor+")
1008 name="unifi-outdoor-plus"
1031 *"WNDR3700/WNDR3800/WNDRMAC")
1032 wndr3700_board_detect "$machine"
1076 *"WZR-HP-AG300H/WZR-600DHP")
1077 name="wzr-hp-ag300h"
1080 name="wzr-hp-g300nh"
1086 name="wzr-hp-g300nh2"
1100 *EmbWir-Dorin-Router)
1101 name="ew-dorin-router"
1103 "8devices Carambola2"*)
1106 *"Sitecom WLR-8100")
1109 *"BHU BXU2000n-2 rev. A1")
1110 name="bxu2000n-2-a1"
1113 name="hiwifi-hc6361"
1117 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1118 tplink_board_detect "$machine"
1120 [ -z "$name" ] && name="unknown"
1122 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1123 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1125 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1127 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1128 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1131 ar71xx_board_name() {
1134 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1135 [ -z "$name" ] && name="unknown"