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 # Use awk to remove everything after the first zero byte
41 model="$(ar71xx_get_mtd_offset_size_format art 41 32 %c | LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}')"
44 if [ "${model:24:1}" = 'N' ]; then
45 machine="NETGEAR WNDRMAC"
47 machine="NETGEAR WNDR3700v2"
51 machine="NETGEAR ${model:14}"
54 machine="NETGEAR ${model:15}"
58 machine="NETGEAR $model"
62 AR71XX_BOARD_NAME="$name"
63 AR71XX_MODEL="$machine"
66 cybertan_get_hw_magic() {
69 part=$(find_mtd_part firmware)
70 [ -z "$part" ] && return 1
72 dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
78 part=$(find_mtd_part firmware)
79 [ -z "$part" ] && return 1
81 dd if=$part bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
87 part=$(find_mtd_part firmware)
88 [ -z "$part" ] && return 1
90 dd if=$part bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
93 tplink_board_detect() {
98 hwid=$(tplink_get_hwid)
105 model="EasyLink EL-M150"
108 model="EasyLink EL-MINI"
117 model="MERCURY MAC1200R"
126 model="TP-Link TL-WR703N"
129 model="TP-Link TL-WR710N"
132 model="TP-Link TL-WR720N"
135 model="TP-Link TL-WA701N/ND"
138 model="TP-Link TL-WA730RE"
141 model="TP-Link TL-WR740N/ND"
144 model="TP-Link TL-WR741N/ND"
147 model="TP-Link TL-WR743N/ND"
150 model="TP-Link TL-WA750RE"
153 model="TP-Link TL-WA7210N"
156 model="TP-Link TL-WA7510N"
159 model="TP-Link TL-WA801N/ND"
162 model="TP-Link TL-WA830RE"
164 if [ "$hwver" = 'v10' ]; then
169 model="TP-Link TL-WR841N/ND"
172 model="TP-Link TL-WR842N/ND"
175 model="TP-Link TL-WR843N/ND"
178 model="TP-Link TL-WA850RE"
181 model="TP-Link TL-WA860RE"
184 model="TP-Link TL-WA901N/ND"
187 if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
188 model="Rosewill RNX-N360RT"
191 model="TP-Link TL-WR941N/ND"
195 model="TP-Link TL-WR1041N/ND"
198 model="TP-Link TL-WR1043N/ND"
201 model="TP-Link TL-WR2543N/ND"
204 model="TP-Link TL-MR10U"
207 model="TP-Link TL-MR11U"
210 model="TP-Link TL-MR12U"
213 model="TP-Link TL-MR13U"
216 model="TP-Link TL-MR3020"
219 model="TP-Link TL-MR3040"
222 model="TP-Link TL-MR3220"
225 model="TP-Link TL-MR3420"
228 model="TP-Link TL-WDR3320"
231 model="TP-Link TL-WDR3500"
234 model="TP-Link TL-WDR3600"
237 model="TP-Link TL-WDR4300"
241 model="TP-Link TL-WDR4300 (IL)"
244 model="TP-Link TL-WDR4310"
247 model="TP-Link TL-WDR4900"
250 model="TP-Link TL-WDR6500"
253 model="MERCURY MW4530R"
256 model="NC-LINK SMART-300"
259 model="TP-Link Archer C5"
263 model="TP-Link Archer C7"
270 AR71XX_MODEL="$model $hwver"
273 tplink_pharos_get_model_string() {
275 part=$(find_mtd_part 'product-info')
276 [ -z "$part" ] && return 1
278 # The returned string will end with \r\n, but we don't remove it here
279 # to simplify matching against it in the sysupgrade image check
280 dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1
283 tplink_pharos_board_detect() {
284 local model_string="$(tplink_pharos_get_model_string | tr -d '\r')"
285 local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS"
289 'CPE210(TP-LINK|UN|N300-2)')
290 model='TP-Link CPE210'
292 'CPE220(TP-LINK|UN|N300-2)')
293 model='TP-Link CPE220'
295 'CPE510(TP-LINK|UN|N300-5)')
296 model='TP-Link CPE510'
298 'CPE520(TP-LINK|UN|N300-5)')
299 model='TP-Link CPE520'
303 [ -n "$model" ] && AR71XX_MODEL="$model v$2"
306 gl_inet_board_detect() {
307 local size="$(mtd_get_part_size 'firmware')"
311 AR71XX_MODEL='GL-iNet 6408A v1'
314 AR71XX_MODEL='GL-iNet 6416A v1'
319 ar71xx_board_detect() {
323 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
341 *"ALFA Network AP96")
344 *"ALFA Network N2/N5")
374 *"AP132 reference board")
377 *"AP136-010 reference board")
380 *"AP136-020 reference board")
383 *"AP135-020 reference board")
386 *"AP143 reference board")
389 *"AP147-010 reference board")
392 *"AP152 reference board")
416 *"COMFAST CF-E316N v2")
419 *"CPE210/220/510/520")
421 tplink_pharos_board_detect
423 *"DB120 reference board")
456 *"dLAN pro 500 Wireless+")
457 name="dlan-pro-500-wp"
459 *"dLAN pro 1200+ WiFi ac")
460 name="dlan-pro-1200-ac"
477 *"GL-CONNECT INET v1")
506 name="nanostation-m-xw"
513 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
515 if [ "x$size" = "x00790000" ]; then
519 if [ "x$size" = "x00f90000" ]; then
559 *"WD My Net Wi-Fi Range Extender")
568 *"NBG460N/550N/550NH")
569 name="nbg460n_550n_550nh"
604 *"PB44 reference board")
613 *"RouterBOARD 411/A/AH")
619 *"RouterBOARD 433/AH")
622 *"RouterBOARD 433UAH")
634 *"RouterBOARD 493/AH")
643 *"RouterBOARD 750GL")
652 *"RouterBOARD 911G-2HPnD")
655 *"RouterBOARD 911G-5HPnD")
658 *"RouterBOARD 911G-5HPacD")
659 name="rb-911g-5hpacd"
661 *"RouterBOARD 912UAG-2HPnD")
662 name="rb-912uag-2hpnd"
664 *"RouterBOARD 912UAG-5HPnD")
665 name="rb-912uag-5hpnd"
667 *"RouterBOARD 951G-2HnD")
670 *"RouterBOARD 951Ui-2HnD")
673 *"RouterBOARD 2011L")
676 *"RouterBOARD 2011UAS")
679 *"RouterBOARD 2011UiAS")
682 *"RouterBOARD 2011UAS-2HnD")
683 name="rb-2011uas-2hnd"
685 *"RouterBOARD 2011UiAS-2HnD")
686 name="rb-2011uias-2hnd"
688 *"RouterBOARD SXT Lite2")
691 *"RouterBOARD SXT Lite5")
706 *"RouterStation Pro")
707 name="routerstation-pro"
715 "Smart Electronics Black Swift board"*)
737 name="tl-wr1043nd-v2"
805 *"TL-WDR3600/4300/4310")
890 name="unifi-outdoor-plus"
910 *"WNDR3700/WNDR3800/WNDRMAC")
911 wndr3700_board_detect "$machine"
949 *"WZR-HP-AG300H/WZR-600DHP")
959 name="wzr-hp-g300nh2"
973 *EmbWir-Dorin-Router)
974 name="ew-dorin-router"
976 "8devices Carambola2"*)
982 *"BHU BXU2000n-2 rev. A1")
990 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
991 tplink_board_detect "$machine"
993 [ -z "$name" ] && name="unknown"
995 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
996 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
998 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1000 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1001 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1004 ar71xx_board_name() {
1007 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1008 [ -z "$name" ] && name="unknown"