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"|\ # Note: the M5 / M5 Ti haven't yet been verified
87 model="Ubiquiti Rocket M"
91 model="Ubiquiti Bullet M"
94 model="Ubiquiti PicoStation M"
98 [ -z "$model" ] || AR71XX_MODEL="${model}${magic:3:1}"
101 cybertan_get_hw_magic() {
104 part=$(find_mtd_part firmware)
105 [ -z "$part" ] && return 1
107 dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
110 dir505_board_detect() {
111 local dev=$(find_mtd_part 'mac')
112 [ -z "$dev" ] && return
114 # The revision is stored at the beginning of the "mac" partition
115 local rev="$(LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}' $dev)"
116 AR71XX_MODEL="D-Link DIR-505 rev. $rev"
122 part=$(find_mtd_part firmware)
123 [ -z "$part" ] && return 1
125 dd if=$part bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
131 part=$(find_mtd_part firmware)
132 [ -z "$part" ] && return 1
134 dd if=$part bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
137 tplink_board_detect() {
142 hwid=$(tplink_get_hwid)
143 mid=$(tplink_get_mid)
149 model="EasyLink EL-M150"
152 model="EasyLink EL-MINI"
164 model="MERCURY MAC1200R"
167 model="TellStick ZNet Lite"
170 model="OMYlink OMY-G1"
173 model="OMYlink OMY-X1"
182 model="TP-Link TL-WR703N"
185 model="TP-Link TL-WR710N"
187 if [ "$hwid" = '07100002' -a "$mid" = '00000002' ]; then
192 model="TP-Link TL-WR720N"
195 model="TP-Link TL-WA701N/ND"
198 model="TP-Link TL-WA730RE"
201 model="TP-Link TL-WR740N/ND"
204 model="TP-Link TL-WR741N/ND"
207 model="TP-Link TL-WR743N/ND"
210 model="TP-Link TL-WA750RE"
213 model="TP-Link TL-WA7210N"
216 model="TP-Link TL-WA7510N"
219 model="TP-Link TL-WA801N/ND"
222 model="TP-Link TL-WR802N"
225 model="TP-Link TL-WA830RE"
227 if [ "$hwver" = ' v10' ]; then
232 model="TP-Link TL-WR841N/ND"
234 if [ "$hwid" = '08410002' -a "$mid" = '00000002' ]; then
239 model="TP-Link TL-WR842N/ND"
242 model="TP-Link TL-WR843N/ND"
245 model="TP-Link TL-WA850RE"
248 model="TP-Link TL-WA860RE"
251 model="TP-Link TL-WA901N/ND"
254 if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
255 model="Rosewill RNX-N360RT"
258 model="TP-Link TL-WR941N/ND"
262 model="TP-Link TL-WR1041N/ND"
265 model="TP-Link TL-WR1043N/ND"
268 model="TP-Link TL-WR2543N/ND"
271 model="TP-Link TL-MR10U"
274 model="TP-Link TL-MR11U"
277 model="TP-Link TL-MR12U"
280 model="TP-Link TL-MR13U"
283 model="TP-Link TL-MR3020"
286 model="TP-Link TL-MR3040"
289 model="TP-Link TL-MR3220"
292 model="TP-Link TL-MR3420"
295 model="TP-Link TL-WDR3320"
298 model="TP-Link TL-WDR3500"
301 model="TP-Link TL-WDR3600"
304 model="TP-Link TL-WDR4300"
308 model="TP-Link TL-WDR4300 (IL)"
311 model="TP-Link TL-WDR4310"
314 model="TP-Link TL-WDR4900"
317 model="TP-Link TL-WDR6500"
320 model="Mercury MW4530R"
323 model="NC-LINK SMART-300"
326 model="TP-Link Archer C5"
330 model="TP-Link Archer C7"
337 AR71XX_MODEL="$model$hwver"
340 tplink_pharos_get_model_string() {
342 part=$(find_mtd_part 'product-info')
343 [ -z "$part" ] && return 1
345 # The returned string will end with \r\n, but we don't remove it here
346 # to simplify matching against it in the sysupgrade image check
347 dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1
350 tplink_pharos_board_detect() {
351 local model_string="$(tplink_pharos_get_model_string | tr -d '\r')"
352 local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS"
356 'CPE210(TP-LINK|UN|N300-2)')
357 model='TP-Link CPE210'
359 'CPE220(TP-LINK|UN|N300-2)')
360 model='TP-Link CPE220'
362 'CPE510(TP-LINK|UN|N300-5)')
363 model='TP-Link CPE510'
365 'CPE520(TP-LINK|UN|N300-5)')
366 model='TP-Link CPE520'
368 'EAP120(TP-LINK|UN|N300-2)')
369 model='TP-Link EAP120'
373 [ -n "$model" ] && AR71XX_MODEL="$model v$2"
376 gl_inet_board_detect() {
377 local size="$(mtd_get_part_size 'firmware')"
381 AR71XX_MODEL='GL-iNet 6408A v1'
384 AR71XX_MODEL='GL-iNet 6416A v1'
389 ar71xx_board_detect() {
393 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
411 *"ALFA Network AP120C")
414 *"ALFA Network AP96")
417 *"ALFA Network N2/N5")
441 *"AP121 reference board")
447 *"AP132 reference board")
450 *"AP136-010 reference board")
453 *"AP136-020 reference board")
456 *"AP135-020 reference board")
459 *"AP143 reference board")
462 *"AP147-010 reference board")
465 *"AP152 reference board")
524 tplink_pharos_board_detect
528 tplink_pharos_board_detect
545 *"DB120 reference board")
585 *"dLAN pro 500 Wireless+")
586 name="dlan-pro-500-wp"
588 *"dLAN pro 1200+ WiFi ac")
589 name="dlan-pro-1200-ac"
608 tplink_pharos_board_detect
622 *"GL-CONNECT INET v1")
665 name="nanostation-m-xw"
675 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
677 if [ "x$size" = "x00790000" ]; then
681 if [ "x$size" = "x00f90000" ]; then
727 *"WD My Net Wi-Fi Range Extender")
736 *"NBG460N/550N/550NH")
737 name="nbg460n_550n_550nh"
787 *"PB44 reference board")
796 *"RouterBOARD 411/A/AH")
802 *"RouterBOARD 433/AH")
805 *"RouterBOARD 433UAH")
817 *"RouterBOARD 493/AH")
826 *"RouterBOARD 750GL")
835 *"RouterBOARD 911G-2HPnD")
838 *"RouterBOARD 911G-5HPnD")
841 *"RouterBOARD 911G-5HPacD")
842 name="rb-911g-5hpacd"
844 *"RouterBOARD 912UAG-2HPnD")
845 name="rb-912uag-2hpnd"
847 *"RouterBOARD 912UAG-5HPnD")
848 name="rb-912uag-5hpnd"
850 *"RouterBOARD 951G-2HnD")
853 *"RouterBOARD 951Ui-2HnD")
856 *"RouterBOARD 2011L")
859 *"RouterBOARD 2011UAS")
862 *"RouterBOARD 2011UiAS")
865 *"RouterBOARD 2011UAS-2HnD")
866 name="rb-2011uas-2hnd"
868 *"RouterBOARD 2011UiAS-2HnD")
869 name="rb-2011uias-2hnd"
871 *"RouterBOARD SXT Lite2")
874 *"RouterBOARD SXT Lite5")
890 *"RouterStation Pro")
891 name="routerstation-pro"
899 "Smart Electronics Black Swift board"*)
902 *"Telldus TellStick ZNet Lite")
903 name="tellstick-znet-lite"
930 name="tl-wr1043nd-v2"
1002 name="tl-wdr3320-v2"
1007 *"TL-WDR3600/4300/4310")
1011 name="tl-wdr4900-v2"
1014 name="tl-wdr6500-v2"
1023 name="tl-wr741nd-v4"
1037 *"TL-WR841N/ND v11")
1038 name="tl-wr841n-v11"
1050 name="tl-wr941nd-v5"
1053 name="tl-wr941nd-v6"
1107 name="unifi-outdoor"
1109 *"UniFiAP Outdoor+")
1110 name="unifi-outdoor-plus"
1133 *"WNDR3700/WNDR3800/WNDRMAC")
1134 wndr3700_board_detect "$machine"
1178 *"WZR-HP-AG300H/WZR-600DHP")
1179 name="wzr-hp-ag300h"
1182 name="wzr-hp-g300nh"
1188 name="wzr-hp-g300nh2"
1208 *EmbWir-Dorin-Router)
1209 name="ew-dorin-router"
1211 "8devices Carambola2"*)
1214 *"Sitecom WLR-8100")
1217 *"BHU BXU2000n-2 rev. A1")
1218 name="bxu2000n-2-a1"
1221 name="hiwifi-hc6361"
1225 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1226 tplink_board_detect "$machine"
1228 [ -z "$name" ] && name="unknown"
1230 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1231 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1233 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1235 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1236 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1239 ar71xx_board_name() {
1242 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1243 [ -z "$name" ] && name="unknown"