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="$(echo -n "$model" | 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"
118 model="MERCURY MAC1200R"
127 model="TP-Link TL-WR703N"
130 model="TP-Link TL-WR710N"
133 model="TP-Link TL-WR720N"
136 model="TP-Link TL-WA701N/ND"
139 model="TP-Link TL-WA730RE"
142 model="TP-Link TL-WR740N/ND"
145 model="TP-Link TL-WR741N/ND"
148 model="TP-Link TL-WR743N/ND"
151 model="TP-Link TL-WA750RE"
154 model="TP-Link TL-WA7210N"
157 model="TP-Link TL-WA7510N"
160 model="TP-Link TL-WA801N/ND"
163 model="TP-Link TL-WA830RE"
165 if [ "$hwver" = 'v10' ]; then
170 model="TP-Link TL-WR841N/ND"
173 model="TP-Link TL-WR842N/ND"
176 model="TP-Link TL-WR843N/ND"
179 model="TP-Link TL-WA850RE"
182 model="TP-Link TL-WA860RE"
185 model="TP-Link TL-WA901N/ND"
188 if [ "$hwid" = "09410002" -a "$mid" = "00420001" ]; then
189 model="Rosewill RNX-N360RT"
192 model="TP-Link TL-WR941N/ND"
196 model="TP-Link TL-WR1041N/ND"
199 model="TP-Link TL-WR1043N/ND"
202 model="TP-Link TL-WR2543N/ND"
205 model="TP-Link TL-MR10U"
208 model="TP-Link TL-MR11U"
211 model="TP-Link TL-MR12U"
214 model="TP-Link TL-MR13U"
217 model="TP-Link TL-MR3020"
220 model="TP-Link TL-MR3040"
223 model="TP-Link TL-MR3220"
226 model="TP-Link TL-MR3420"
229 model="TP-Link TL-WDR3320"
232 model="TP-Link TL-WDR3500"
235 model="TP-Link TL-WDR3600"
238 model="TP-Link TL-WDR4300"
242 model="TP-Link TL-WDR4300 (IL)"
245 model="TP-Link TL-WDR4310"
248 model="TP-Link TL-WDR4900"
251 model="TP-Link TL-WDR6500"
254 model="MERCURY MW4530R"
257 model="NC-LINK SMART-300"
260 model="TP-Link Archer C5"
264 model="TP-Link Archer C7"
271 AR71XX_MODEL="$model $hwver"
274 tplink_pharos_get_model_string() {
276 part=$(find_mtd_part 'product-info')
277 [ -z "$part" ] && return 1
279 # The returned string will end with \r\n, but we don't remove it here
280 # to simplify matching against it in the sysupgrade image check
281 dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1
284 tplink_pharos_board_detect() {
285 local model_string="$(tplink_pharos_get_model_string | tr -d '\r')"
286 local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS"
290 'CPE210(TP-LINK|UN|N300-2)')
291 model='TP-Link CPE210'
293 'CPE220(TP-LINK|UN|N300-2)')
294 model='TP-Link CPE220'
296 'CPE510(TP-LINK|UN|N300-5)')
297 model='TP-Link CPE510'
299 'CPE520(TP-LINK|UN|N300-5)')
300 model='TP-Link CPE520'
304 [ -n "$model" ] && AR71XX_MODEL="$model v$2"
307 gl_inet_board_detect() {
308 local size="$(mtd_get_part_size 'firmware')"
312 AR71XX_MODEL='GL-iNet 6408A v1'
315 AR71XX_MODEL='GL-iNet 6416A v1'
320 ar71xx_board_detect() {
324 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
342 *"ALFA Network AP96")
345 *"ALFA Network N2/N5")
375 *"AP132 reference board")
378 *"AP136-010 reference board")
381 *"AP136-020 reference board")
384 *"AP135-020 reference board")
387 *"AP143 reference board")
390 *"AP147-010 reference board")
393 *"AP152 reference board")
420 *"COMFAST CF-E316N v2")
423 *"CPE210/220/510/520")
425 tplink_pharos_board_detect
430 *"DB120 reference board")
466 *"dLAN pro 500 Wireless+")
467 name="dlan-pro-500-wp"
469 *"dLAN pro 1200+ WiFi ac")
470 name="dlan-pro-1200-ac"
493 *"GL-CONNECT INET v1")
528 name="nanostation-m-xw"
535 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
537 if [ "x$size" = "x00790000" ]; then
541 if [ "x$size" = "x00f90000" ]; then
584 *"WD My Net Wi-Fi Range Extender")
593 *"NBG460N/550N/550NH")
594 name="nbg460n_550n_550nh"
629 *"PB44 reference board")
638 *"RouterBOARD 411/A/AH")
644 *"RouterBOARD 433/AH")
647 *"RouterBOARD 433UAH")
659 *"RouterBOARD 493/AH")
668 *"RouterBOARD 750GL")
677 *"RouterBOARD 911G-2HPnD")
680 *"RouterBOARD 911G-5HPnD")
683 *"RouterBOARD 911G-5HPacD")
684 name="rb-911g-5hpacd"
686 *"RouterBOARD 912UAG-2HPnD")
687 name="rb-912uag-2hpnd"
689 *"RouterBOARD 912UAG-5HPnD")
690 name="rb-912uag-5hpnd"
692 *"RouterBOARD 951G-2HnD")
695 *"RouterBOARD 951Ui-2HnD")
698 *"RouterBOARD 2011L")
701 *"RouterBOARD 2011UAS")
704 *"RouterBOARD 2011UiAS")
707 *"RouterBOARD 2011UAS-2HnD")
708 name="rb-2011uas-2hnd"
710 *"RouterBOARD 2011UiAS-2HnD")
711 name="rb-2011uias-2hnd"
713 *"RouterBOARD SXT Lite2")
716 *"RouterBOARD SXT Lite5")
731 *"RouterStation Pro")
732 name="routerstation-pro"
740 "Smart Electronics Black Swift board"*)
765 name="tl-wr1043nd-v2"
833 *"TL-WDR3600/4300/4310")
918 name="unifi-outdoor-plus"
938 *"WNDR3700/WNDR3800/WNDRMAC")
939 wndr3700_board_detect "$machine"
977 *"WZR-HP-AG300H/WZR-600DHP")
987 name="wzr-hp-g300nh2"
1001 *EmbWir-Dorin-Router)
1002 name="ew-dorin-router"
1004 "8devices Carambola2"*)
1007 *"Sitecom WLR-8100")
1010 *"BHU BXU2000n-2 rev. A1")
1011 name="bxu2000n-2-a1"
1014 name="hiwifi-hc6361"
1018 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1019 tplink_board_detect "$machine"
1021 [ -z "$name" ] && name="unknown"
1023 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1024 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1026 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1028 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1029 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1032 ar71xx_board_name() {
1035 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1036 [ -z "$name" ] && name="unknown"