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 ubnt_get_mtd_part_magic() {
68 ar71xx_get_mtd_offset_size_format EEPROM 4118 2 %02x
71 ubnt_xm_board_detect() {
75 magic="$(ubnt_get_mtd_part_magic)"
79 "e80") # Different revisions of the NanoStation?
80 model="Ubiquiti NanoStation M"
83 model="Ubiquiti NanoStation loco M"
85 "e1b") # Rocket M5 untested
86 model="Ubiquiti Rocket M"
90 model="Ubiquiti Bullet M"
93 model="Ubiquiti PicoStation M"
97 [ -z "$model" ] || AR71XX_MODEL="${model}${magic:3:1}"
100 cybertan_get_hw_magic() {
103 part=$(find_mtd_part firmware)
104 [ -z "$part" ] && return 1
106 dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
109 dir505_board_detect() {
110 local dev=$(find_mtd_part 'mac')
111 [ -z "$dev" ] && return
113 # The revision is stored at the beginning of the "mac" partition
114 local rev="$(LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}' $dev)"
115 AR71XX_MODEL="D-Link DIR-505 rev. $rev"
121 part=$(find_mtd_part firmware)
122 [ -z "$part" ] && return 1
124 dd if=$part bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
130 part=$(find_mtd_part firmware)
131 [ -z "$part" ] && return 1
133 dd if=$part bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
136 tplink_board_detect() {
141 hwid=$(tplink_get_hwid)
142 mid=$(tplink_get_mid)
148 model="EasyLink EL-M150"
151 model="EasyLink EL-MINI"
163 model="MERCURY MAC1200R"
166 model="TellStick ZNet Lite"
169 model="OMYlink OMY-G1"
172 model="OMYlink OMY-X1"
181 model="TP-Link TL-WR703N"
184 model="TP-Link TL-WR710N"
186 if [ "$hwid" = '07100002' -a "$mid" = '00000002' ]; then
191 model="TP-Link TL-WR720N"
194 model="TP-Link TL-WA701N/ND"
197 model="TP-Link TL-WA730RE"
200 model="TP-Link TL-WR740N/ND"
203 model="TP-Link TL-WR741N/ND"
206 model="TP-Link TL-WR743N/ND"
209 model="TP-Link TL-WA750RE"
212 model="TP-Link TL-WA7210N"
215 model="TP-Link TL-WA7510N"
218 model="TP-Link TL-WA801N/ND"
221 model="TP-Link TL-WR802N"
224 model="TP-Link TL-WA830RE"
226 if [ "$hwver" = ' v10' ]; then
231 model="TP-Link TL-WR841N/ND"
233 if [ "$hwid" = '08410002' -a "$mid" = '00000002' ]; then
238 model="TP-Link TL-WR842N/ND"
241 model="TP-Link TL-WR843N/ND"
244 model="TP-Link TL-WA850RE"
247 model="TP-Link TL-WA860RE"
250 model="TP-Link TL-WA901N/ND"
253 if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
254 model="Rosewill RNX-N360RT"
257 model="TP-Link TL-WR941N/ND"
261 model="TP-Link TL-WR1041N/ND"
264 model="TP-Link TL-WR1043N/ND"
267 model="TP-Link TL-WR2543N/ND"
270 model="TP-Link TL-MR10U"
273 model="TP-Link TL-MR11U"
276 model="TP-Link TL-MR12U"
279 model="TP-Link TL-MR13U"
282 model="TP-Link TL-MR3020"
285 model="TP-Link TL-MR3040"
288 model="TP-Link TL-MR3220"
291 model="TP-Link TL-MR3420"
294 model="TP-Link TL-WDR3320"
297 model="TP-Link TL-WDR3500"
300 model="TP-Link TL-WDR3600"
303 model="TP-Link TL-WDR4300"
307 model="TP-Link TL-WDR4300 (IL)"
310 model="TP-Link TL-WDR4310"
313 model="TP-Link TL-WDR4900"
316 model="TP-Link TL-WDR6500"
319 model="Mercury MW4530R"
322 model="NC-LINK SMART-300"
325 model="TP-Link Archer C5"
329 model="TP-Link Archer C7"
336 AR71XX_MODEL="$model$hwver"
339 tplink_pharos_get_model_string() {
341 part=$(find_mtd_part 'product-info')
342 [ -z "$part" ] && return 1
344 # The returned string will end with \r\n, but we don't remove it here
345 # to simplify matching against it in the sysupgrade image check
346 dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1
349 tplink_pharos_board_detect() {
350 local model_string="$(tplink_pharos_get_model_string | tr -d '\r')"
351 local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS"
355 'CPE210(TP-LINK|UN|N300-2)')
356 model='TP-Link CPE210'
358 'CPE220(TP-LINK|UN|N300-2)')
359 model='TP-Link CPE220'
361 'CPE510(TP-LINK|UN|N300-5)')
362 model='TP-Link CPE510'
364 'CPE520(TP-LINK|UN|N300-5)')
365 model='TP-Link CPE520'
367 'EAP120(TP-LINK|UN|N300-2)')
368 model='TP-Link EAP120'
372 [ -n "$model" ] && AR71XX_MODEL="$model v$2"
375 gl_inet_board_detect() {
376 local size="$(mtd_get_part_size 'firmware')"
380 AR71XX_MODEL='GL-iNet 6408A v1'
383 AR71XX_MODEL='GL-iNet 6416A v1'
388 ar71xx_board_detect() {
392 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
410 *"ALFA Network AP120C")
413 *"ALFA Network AP96")
416 *"ALFA Network N2/N5")
440 *"AP121 reference board")
446 *"AP132 reference board")
449 *"AP136-010 reference board")
452 *"AP136-020 reference board")
455 *"AP135-020 reference board")
458 *"AP143 reference board")
461 *"AP147-010 reference board")
464 *"AP152 reference board")
523 tplink_pharos_board_detect
527 tplink_pharos_board_detect
544 *"DB120 reference board")
584 *"dLAN pro 500 Wireless+")
585 name="dlan-pro-500-wp"
587 *"dLAN pro 1200+ WiFi ac")
588 name="dlan-pro-1200-ac"
607 tplink_pharos_board_detect
621 *"GL-CONNECT INET v1")
664 name="nanostation-m-xw"
674 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
676 if [ "x$size" = "x00790000" ]; then
680 if [ "x$size" = "x00f90000" ]; then
726 *"WD My Net Wi-Fi Range Extender")
735 *"NBG460N/550N/550NH")
736 name="nbg460n_550n_550nh"
786 *"PB44 reference board")
795 *"RouterBOARD 411/A/AH")
801 *"RouterBOARD 433/AH")
804 *"RouterBOARD 433UAH")
816 *"RouterBOARD 493/AH")
825 *"RouterBOARD 750GL")
834 *"RouterBOARD 911G-2HPnD")
837 *"RouterBOARD 911G-5HPnD")
840 *"RouterBOARD 911G-5HPacD")
841 name="rb-911g-5hpacd"
843 *"RouterBOARD 912UAG-2HPnD")
844 name="rb-912uag-2hpnd"
846 *"RouterBOARD 912UAG-5HPnD")
847 name="rb-912uag-5hpnd"
849 *"RouterBOARD 951G-2HnD")
852 *"RouterBOARD 951Ui-2HnD")
855 *"RouterBOARD 2011L")
858 *"RouterBOARD 2011UAS")
861 *"RouterBOARD 2011UiAS")
864 *"RouterBOARD 2011UAS-2HnD")
865 name="rb-2011uas-2hnd"
867 *"RouterBOARD 2011UiAS-2HnD")
868 name="rb-2011uias-2hnd"
870 *"RouterBOARD SXT Lite2")
873 *"RouterBOARD SXT Lite5")
889 *"RouterStation Pro")
890 name="routerstation-pro"
898 "Smart Electronics Black Swift board"*)
901 *"Telldus TellStick ZNet Lite")
902 name="tellstick-znet-lite"
929 name="tl-wr1043nd-v2"
1001 name="tl-wdr3320-v2"
1006 *"TL-WDR3600/4300/4310")
1010 name="tl-wdr4900-v2"
1013 name="tl-wdr6500-v2"
1022 name="tl-wr741nd-v4"
1036 *"TL-WR841N/ND v11")
1037 name="tl-wr841n-v11"
1049 name="tl-wr941nd-v5"
1052 name="tl-wr941nd-v6"
1106 name="unifi-outdoor"
1108 *"UniFiAP Outdoor+")
1109 name="unifi-outdoor-plus"
1132 *"WNDR3700/WNDR3800/WNDRMAC")
1133 wndr3700_board_detect "$machine"
1177 *"WZR-HP-AG300H/WZR-600DHP")
1178 name="wzr-hp-ag300h"
1181 name="wzr-hp-g300nh"
1187 name="wzr-hp-g300nh2"
1207 *EmbWir-Dorin-Router)
1208 name="ew-dorin-router"
1210 "8devices Carambola2"*)
1213 *"Sitecom WLR-8100")
1216 *"BHU BXU2000n-2 rev. A1")
1217 name="bxu2000n-2-a1"
1220 name="hiwifi-hc6361"
1224 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1225 tplink_board_detect "$machine"
1227 [ -z "$name" ] && name="unknown"
1229 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1230 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1232 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1234 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1235 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1238 ar71xx_board_name() {
1241 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1242 [ -z "$name" ] && name="unknown"