25f6b01c184c23981eae42ee326c95dd9acadc00
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / lib / ar71xx.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2009-2011 OpenWrt.org
4 #
5
6 AR71XX_BOARD_NAME=
7 AR71XX_MODEL=
8
9 ar71xx_get_mtd_offset_size_format() {
10 local mtd="$1"
11 local offset="$2"
12 local size="$3"
13 local format="$4"
14 local dev
15
16 dev=$(find_mtd_part $mtd)
17 [ -z "$dev" ] && return
18
19 dd if=$dev bs=1 skip=$offset count=$size 2>/dev/null | hexdump -v -e "1/1 \"$format\""
20 }
21
22 ar71xx_get_mtd_part_magic() {
23 local mtd="$1"
24 ar71xx_get_mtd_offset_size_format "$mtd" 0 4 %02x
25 }
26
27 wndr3700_board_detect() {
28 local machine="$1"
29 local magic
30 local name
31
32 name="wndr3700"
33
34 magic="$(ar71xx_get_mtd_part_magic firmware)"
35 case $magic in
36 "33373030")
37 machine="NETGEAR WNDR3700"
38 ;;
39 "33373031")
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}')"
43 case $model in
44 $'\xff'*)
45 if [ "${model:24:1}" = 'N' ]; then
46 machine="NETGEAR WNDRMAC"
47 else
48 machine="NETGEAR WNDR3700v2"
49 fi
50 ;;
51 '29763654+16+64'*)
52 machine="NETGEAR ${model_stripped:14}"
53 ;;
54 '29763654+16+128'*)
55 machine="NETGEAR ${model_stripped:15}"
56 ;;
57 *)
58 # Unknown ID
59 machine="NETGEAR ${model_stripped}"
60 esac
61 esac
62
63 AR71XX_BOARD_NAME="$name"
64 AR71XX_MODEL="$machine"
65 }
66
67 ubnt_get_mtd_part_magic() {
68 ar71xx_get_mtd_offset_size_format EEPROM 4118 2 %02x
69 }
70
71 ubnt_xm_board_detect() {
72 local model
73 local magic
74
75 magic="$(ubnt_get_mtd_part_magic)"
76 case ${magic:0:3} in
77 "e00"|\
78 "e01"|\
79 "e80")
80 model="Ubiquiti NanoStation M"
81 ;;
82 "e0a")
83 model="Ubiquiti NanoStation loco M"
84 ;;
85 "e1b"|\
86 "e1d")
87 model="Ubiquiti Rocket M"
88 ;;
89 "e20"|\
90 "e2d")
91 model="Ubiquiti Bullet M"
92 ;;
93 "e30")
94 model="Ubiquiti PicoStation M"
95 ;;
96 esac
97
98 [ -z "$model" ] || AR71XX_MODEL="${model}${magic:3:1}"
99 }
100
101 cybertan_get_hw_magic() {
102 local part
103
104 part=$(find_mtd_part firmware)
105 [ -z "$part" ] && return 1
106
107 dd bs=8 count=1 skip=0 if=$part 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
108 }
109
110 dir505_board_detect() {
111 local dev=$(find_mtd_part 'mac')
112 [ -z "$dev" ] && return
113
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"
117 }
118
119 tplink_get_hwid() {
120 local part
121
122 part=$(find_mtd_part firmware)
123 [ -z "$part" ] && return 1
124
125 dd if=$part bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
126 }
127
128 tplink_get_mid() {
129 local part
130
131 part=$(find_mtd_part firmware)
132 [ -z "$part" ] && return 1
133
134 dd if=$part bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
135 }
136
137 tplink_board_detect() {
138 local model="$1"
139 local hwid
140 local hwver
141
142 hwid=$(tplink_get_hwid)
143 mid=$(tplink_get_mid)
144 hwver=${hwid:6:2}
145 hwver=" v${hwver#0}"
146
147 case "$hwid" in
148 "001001"*)
149 model="TP-Link TL-MR10U"
150 ;;
151 "001101"*)
152 model="TP-Link TL-MR11U"
153 ;;
154 "001201"*)
155 model="TP-Link TL-MR12U"
156 ;;
157 "001301"*)
158 model="TP-Link TL-MR13U"
159 ;;
160 "007260"*)
161 model="TellStick ZNet Lite"
162 ;;
163 "015000"*)
164 model="EasyLink EL-M150"
165 ;;
166 "015300"*)
167 model="EasyLink EL-MINI"
168 ;;
169 "044401"*)
170 model="ANTMINER-S1"
171 ;;
172 "044403"*)
173 model="ANTMINER-S3"
174 ;;
175 "066601"*)
176 model="OMYlink OMY-G1"
177 ;;
178 "066602"*)
179 model="OMYlink OMY-X1"
180 ;;
181 "070100"*)
182 model="TP-Link TL-WA701N/ND"
183 ;;
184 "070301"*)
185 model="TP-Link TL-WR703N"
186 ;;
187 "071000"*)
188 model="TP-Link TL-WR710N"
189
190 [ "$hwid" = '07100002' -a "$mid" = '00000002' ] && hwver=' v2.1'
191 ;;
192 "072001"*)
193 model="TP-Link TL-WR720N"
194 ;;
195 "073000"*)
196 model="TP-Link TL-WA730RE"
197 ;;
198 "074000"*)
199 model="TP-Link TL-WR740N/ND"
200 ;;
201 "074100"*)
202 model="TP-Link TL-WR741N/ND"
203 ;;
204 "074300"*)
205 model="TP-Link TL-WR743N/ND"
206 ;;
207 "075000"*)
208 model="TP-Link TL-WA750RE"
209 ;;
210 "080100"*)
211 model="TP-Link TL-WA801N/ND"
212 ;;
213 "080200"*)
214 model="TP-Link TL-WR802N"
215
216 [ "$hwid" = '08020002' -a "$mid" = '00000002' ] && hwver=' v2'
217 ;;
218 "083000"*)
219 model="TP-Link TL-WA830RE"
220
221 [ "$hwver" = ' v10' ] && hwver=' v1'
222 ;;
223 "084100"*)
224 model="TP-Link TL-WR841N/ND"
225
226 [ "$hwid" = '08410002' -a "$mid" = '00000002' ] && hwver=' v1.5'
227 ;;
228 "084200"*)
229 model="TP-Link TL-WR842N/ND"
230 ;;
231 "084300"*)
232 model="TP-Link TL-WR843N/ND"
233 ;;
234 "085000"*)
235 model="TP-Link TL-WA850RE"
236 ;;
237 "086000"*)
238 model="TP-Link TL-WA860RE"
239 ;;
240 "090100"*)
241 model="TP-Link TL-WA901N/ND"
242 ;;
243 "094000"*)
244 model="TP-Link TL-WR940N"
245 ;;
246 "094100"*)
247 model="TP-Link TL-WR941N/ND"
248
249 [ "$hwid" = "09410002" -a "$mid" = "00420001" ] && {
250 model="Rosewill RNX-N360RT"
251 hwver=""
252 }
253 ;;
254 "104100"*)
255 model="TP-Link TL-WR1041N/ND"
256 ;;
257 "104300"*)
258 model="TP-Link TL-WR1043N/ND"
259 ;;
260 "120000"*)
261 model="MERCURY MAC1200R"
262 ;;
263 "254300"*)
264 model="TP-Link TL-WR2543N/ND"
265 ;;
266 "302000"*)
267 model="TP-Link TL-MR3020"
268 ;;
269 "304000"*)
270 model="TP-Link TL-MR3040"
271 ;;
272 "322000"*)
273 model="TP-Link TL-MR3220"
274 ;;
275 "332000"*)
276 model="TP-Link TL-WDR3320"
277 ;;
278 "342000"*)
279 model="TP-Link TL-MR3420"
280 ;;
281 "350000"*)
282 model="TP-Link TL-WDR3500"
283 ;;
284 "360000"*)
285 model="TP-Link TL-WDR3600"
286 ;;
287 "3C0001"*)
288 model="OOLITE"
289 ;;
290 "3C0002"*)
291 model="MINIBOX_V1"
292 ;;
293 "430000"*)
294 model="TP-Link TL-WDR4300"
295 ;;
296 "430080"*)
297 iw reg set IL
298 model="TP-Link TL-WDR4300 (IL)"
299 ;;
300 "431000"*)
301 model="TP-Link TL-WDR4310"
302 ;;
303 "44440101"*)
304 model="ANTROUTER-R1"
305 ;;
306 "453000"*)
307 model="Mercury MW4530R"
308 ;;
309 "49000002")
310 model="TP-Link TL-WDR4900"
311 ;;
312 "65000002")
313 model="TP-Link TL-WDR6500"
314 ;;
315 "721000"*)
316 model="TP-Link TL-WA7210N"
317 ;;
318 "750000"*|\
319 "c70000"*)
320 model="TP-Link Archer C7"
321 ;;
322 "751000"*)
323 model="TP-Link TL-WA7510N"
324 ;;
325 "934100"*)
326 model="NC-LINK SMART-300"
327 ;;
328 "c50000"*)
329 model="TP-Link Archer C5"
330 ;;
331 *)
332 hwver=""
333 ;;
334 esac
335
336 AR71XX_MODEL="$model$hwver"
337 }
338
339 tplink_pharos_get_model_string() {
340 local part
341 part=$(find_mtd_part 'product-info')
342 [ -z "$part" ] && return 1
343
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
347 }
348
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"
352
353 local model="${1%%\(*}"
354
355 AR71XX_MODEL="TP-Link $model v$2"
356 }
357
358 ar71xx_board_detect() {
359 local machine
360 local name
361
362 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
363
364 case "$machine" in
365 *"A40")
366 name="a40"
367 ;;
368 *"A60")
369 name="a60"
370 ;;
371 *"AC1750DB")
372 name="f9k1115v2"
373 ;;
374 *"AirGateway")
375 name="airgateway"
376 ;;
377 *"AirGateway Pro")
378 name="airgatewaypro"
379 ;;
380 *"AirRouter")
381 name="airrouter"
382 ;;
383 *"ALFA Network AP120C")
384 name="alfa-ap120c"
385 ;;
386 *"ALFA Network AP96")
387 name="alfa-ap96"
388 ;;
389 *"ALFA Network N2/N5")
390 name="alfa-nx"
391 ;;
392 *"ALL0258N")
393 name="all0258n"
394 ;;
395 *"ALL0305")
396 name="all0305"
397 ;;
398 *"ALL0315N")
399 name="all0315n"
400 ;;
401 *"Antminer-S1")
402 name="antminer-s1"
403 ;;
404 *"Antminer-S3")
405 name="antminer-s3"
406 ;;
407 *"AP121 reference board")
408 name="ap121"
409 ;;
410 *"AP121-MINI")
411 name="ap121-mini"
412 ;;
413 *"AP132 reference board")
414 name="ap132"
415 ;;
416 *"AP135-020 reference board")
417 name="ap135-020"
418 ;;
419 *"AP136-010 reference board")
420 name="ap136-010"
421 ;;
422 *"AP136-020 reference board")
423 name="ap136-020"
424 ;;
425 *"AP143 reference board")
426 name="ap143"
427 ;;
428 *"AP147-010 reference board")
429 name="ap147-010"
430 ;;
431 *"AP152 reference board")
432 name="ap152"
433 ;;
434 *"AP531B0")
435 name="ap531b0"
436 ;;
437 *"AP90Q")
438 name="ap90q"
439 ;;
440 *"Archer C5")
441 name="archer-c5"
442 ;;
443 *"Archer C59 v1")
444 name="archer-c59-v1"
445 ;;
446 *"Archer C60 v1")
447 name="archer-c60-v1"
448 ;;
449 *"Archer C7")
450 name="archer-c7"
451 ;;
452 *"Arduino Yun")
453 name="arduino-yun"
454 ;;
455 *"Atheros AP96")
456 name="ap96"
457 ;;
458 *"AW-NR580")
459 name="aw-nr580"
460 ;;
461 *"BHR-4GRV2")
462 name="bhr-4grv2"
463 ;;
464 *"Black Swift board"*)
465 name="bsb"
466 ;;
467 *"Bullet M")
468 name="bullet-m"
469 ubnt_xm_board_detect
470 ;;
471 *"BXU2000n-2 rev. A1")
472 name="bxu2000n-2-a1"
473 ;;
474 *"C-55")
475 name="c-55"
476 ;;
477 *"C-60")
478 name="c-60"
479 ;;
480 *"CAP324")
481 name="cap324"
482 ;;
483 *"CAP4200AG")
484 name="cap4200ag"
485 ;;
486 *"Carambola2"*)
487 name="carambola2"
488 ;;
489 *"CF-E316N v2")
490 name="cf-e316n-v2"
491 ;;
492 *"CF-E320N v2")
493 name="cf-e320n-v2"
494 ;;
495 *"CF-E380AC v1")
496 name="cf-e380ac-v1"
497 ;;
498 *"CF-E380AC v2")
499 name="cf-e380ac-v2"
500 ;;
501 *"CF-E520N")
502 name="cf-e520n"
503 ;;
504 *"CF-E530N")
505 name="cf-e530n"
506 ;;
507 *"CPE210/220")
508 name="cpe210"
509 tplink_pharos_board_detect
510 ;;
511 *"CPE505N")
512 name="cpe505n"
513 ;;
514 *"CPE510/520")
515 name="cpe510"
516 tplink_pharos_board_detect
517 ;;
518 *"CPE830")
519 name="cpe830"
520 ;;
521 *"CPE870")
522 name="cpe870"
523 ;;
524 *"CR3000")
525 name="cr3000"
526 ;;
527 *"CR5000")
528 name="cr5000"
529 ;;
530 *"DAP-2695 rev. A1")
531 name="dap-2695-a1"
532 ;;
533 *"DB120 reference board")
534 name="db120"
535 ;;
536 *"DGL-5500 rev. A1")
537 name="dgl-5500-a1"
538 ;;
539 *"DHP-1565 rev. A1")
540 name="dhp-1565-a1"
541 ;;
542 *"DIR-505 rev. A1")
543 name="dir-505-a1"
544 dir505_board_detect
545 ;;
546 *"DIR-600 rev. A1")
547 name="dir-600-a1"
548 ;;
549 *"DIR-615 rev. C1")
550 name="dir-615-c1"
551 ;;
552 *"DIR-615 rev. E1")
553 name="dir-615-e1"
554 ;;
555 *"DIR-615 rev. E4")
556 name="dir-615-e4"
557 ;;
558 *"DIR-615 rev. I1")
559 name="dir-615-i1"
560 ;;
561 *"DIR-825 rev. B1")
562 name="dir-825-b1"
563 ;;
564 *"DIR-825 rev. C1")
565 name="dir-825-c1"
566 ;;
567 *"DIR-835 rev. A1")
568 name="dir-835-a1"
569 ;;
570 *"DIR-869 rev. A1")
571 name="dir-869-a1"
572 ;;
573 *"dLAN Hotspot")
574 name="dlan-hotspot"
575 ;;
576 *"dLAN pro 1200+ WiFi ac")
577 name="dlan-pro-1200-ac"
578 ;;
579 *"dLAN pro 500 Wireless+")
580 name="dlan-pro-500-wp"
581 ;;
582 *"Domino Pi")
583 name="gl-domino"
584 ;;
585 *"DR344")
586 name="dr344"
587 ;;
588 *"DR531")
589 name="dr531"
590 ;;
591 *"Dragino v2")
592 name="dragino2"
593 ;;
594 *"DW33D")
595 name="dw33d"
596 ;;
597 *"E2100L")
598 name="e2100l"
599 ;;
600 *"EAP120")
601 name="eap120"
602 tplink_pharos_board_detect
603 ;;
604 *"EAP300 v2")
605 name="eap300v2"
606 ;;
607 *"EAP7660D")
608 name="eap7660d"
609 ;;
610 *"EBR-2310 rev. C1")
611 name="ebr-2310-c1"
612 ;;
613 *"EL-M150")
614 name="el-m150"
615 ;;
616 *"EL-MINI")
617 name="el-mini"
618 ;;
619 *"EmbWir-Dorin")
620 name="ew-dorin"
621 ;;
622 *"EmbWir-Dorin-Router")
623 name="ew-dorin-router"
624 ;;
625 *"EPG5000")
626 name="epg5000"
627 ;;
628 *"ESR1750")
629 name="esr1750"
630 ;;
631 *"ESR900")
632 name="esr900"
633 ;;
634 *"GL AR150")
635 name="gl-ar150"
636 ;;
637 *"GL AR300")
638 name="gl-ar300"
639 ;;
640 *"GL-AR300M")
641 name="gl-ar300m"
642 ;;
643 *"GL-CONNECT INET v1")
644 name="gl-inet"
645
646 local size="$(mtd_get_part_size 'firmware')"
647
648 [ "$size" = "8192000" ] && AR71XX_MODEL="GL-iNet 6408A v1"
649 [ "$size" = "16580608" ] && AR71XX_MODEL="GL-iNet 6416A v1"
650 ;;
651 *"GL-MIFI")
652 name="gl-mifi"
653 ;;
654 *"HiWiFi HC6361")
655 name="hiwifi-hc6361"
656 ;;
657 *"Hornet-UB")
658 local size="$(mtd_get_part_size 'firmware')"
659
660 [ "$size" = "7929856" ] && name="hornet-ub"
661 [ "$size" = "16318464" ] && name="hornet-ub-x2"
662 ;;
663 *"JA76PF")
664 name="ja76pf"
665 ;;
666 *"JA76PF2")
667 name="ja76pf2"
668 ;;
669 *"JWAP003")
670 name="jwap003"
671 ;;
672 *"JWAP230")
673 name="jwap230"
674 ;;
675 *"Lima"*)
676 name="lima"
677 ;;
678 *"Loco M XW")
679 name="loco-m-xw"
680 ;;
681 *"LS-SR71")
682 name="ls-sr71"
683 ;;
684 *"MAC1200R")
685 name="mc-mac1200r"
686 ;;
687 *"MiniBox V1.0")
688 name="minibox-v1"
689 ;;
690 *"MR12")
691 name="mr12"
692 ;;
693 *"MR16")
694 name="mr16"
695 ;;
696 *"MR1750")
697 name="mr1750"
698 ;;
699 *"MR1750v2")
700 name="mr1750v2"
701 ;;
702 *"MR18")
703 name="mr18"
704 ;;
705 *"MR600")
706 name="mr600"
707 ;;
708 *"MR600v2")
709 name="mr600v2"
710 ;;
711 *"MR900")
712 name="mr900"
713 ;;
714 *"MR900v2")
715 name="mr900v2"
716 ;;
717 *"My Net N600")
718 name="mynet-n600"
719 ;;
720 *"My Net N750")
721 name="mynet-n750"
722 ;;
723 *"My Net Wi-Fi Range Extender")
724 name="mynet-rext"
725 ;;
726 *"MZK-W04NU")
727 name="mzk-w04nu"
728 ;;
729 *"MZK-W300NH")
730 name="mzk-w300nh"
731 ;;
732 *"Nanostation M")
733 name="nanostation-m"
734 ubnt_xm_board_detect
735 ;;
736 *"Nanostation M XW")
737 name="nanostation-m-xw"
738 ;;
739 *"NBG460N/550N/550NH")
740 name="nbg460n_550n_550nh"
741 ;;
742 *"NBG6616")
743 name="nbg6616"
744 ;;
745 *"NBG6716")
746 name="nbg6716"
747 ;;
748 *"OM2P")
749 name="om2p"
750 ;;
751 *"OM2P HS")
752 name="om2p-hs"
753 ;;
754 *"OM2P HSv2")
755 name="om2p-hsv2"
756 ;;
757 *"OM2P HSv3")
758 name="om2p-hsv3"
759 ;;
760 *"OM2P HSv4")
761 name="om2p-hsv4"
762 ;;
763 *"OM2P LC")
764 name="om2p-lc"
765 ;;
766 *"OM2Pv2")
767 name="om2pv2"
768 ;;
769 *"OM2Pv4")
770 name="om2pv4"
771 ;;
772 *"OM5P")
773 name="om5p"
774 ;;
775 *"OM5P AC")
776 name="om5p-ac"
777 ;;
778 *"OM5P ACv2")
779 name="om5p-acv2"
780 ;;
781 *"OM5P AN")
782 name="om5p-an"
783 ;;
784 *"OMY-G1")
785 name="omy-g1"
786 ;;
787 *"OMY-X1")
788 name="omy-x1"
789 ;;
790 *"Onion Omega")
791 name="onion-omega"
792 ;;
793 *"Oolite V1.0")
794 name="oolite"
795 ;;
796 *"PB42")
797 name="pb42"
798 ;;
799 *"PB44 reference board")
800 name="pb44"
801 ;;
802 *"PQI Air Pen")
803 name="pqi-air-pen"
804 ;;
805 *"Qihoo 360 C301")
806 name="qihoo-c301"
807 ;;
808 *"R602N")
809 name="r602n"
810 ;;
811 *"R6100")
812 name="r6100"
813 ;;
814 *"RE450")
815 name="re450"
816 ;;
817 *"Rocket M")
818 name="rocket-m"
819 ubnt_xm_board_detect
820 ;;
821 *"Rocket M TI")
822 name="rocket-m-ti"
823 ;;
824 *"Rocket M XW")
825 name="rocket-m-xw"
826 ;;
827 *"RouterBOARD 2011L")
828 name="rb-2011l"
829 ;;
830 *"RouterBOARD 2011UAS")
831 name="rb-2011uas"
832 ;;
833 *"RouterBOARD 2011UAS-2HnD")
834 name="rb-2011uas-2hnd"
835 ;;
836 *"RouterBOARD 2011UiAS")
837 name="rb-2011uias"
838 ;;
839 *"RouterBOARD 2011UiAS-2HnD")
840 name="rb-2011uias-2hnd"
841 ;;
842 *"RouterBOARD 411/A/AH")
843 name="rb-411"
844 ;;
845 *"RouterBOARD 411U")
846 name="rb-411u"
847 ;;
848 *"RouterBOARD 433/AH")
849 name="rb-433"
850 ;;
851 *"RouterBOARD 433UAH")
852 name="rb-433u"
853 ;;
854 *"RouterBOARD 435G")
855 name="rb-435g"
856 ;;
857 *"RouterBOARD 450")
858 name="rb-450"
859 ;;
860 *"RouterBOARD 450G")
861 name="rb-450g"
862 ;;
863 *"RouterBOARD 493/AH")
864 name="rb-493"
865 ;;
866 *"RouterBOARD 493G")
867 name="rb-493g"
868 ;;
869 *"RouterBOARD 750")
870 name="rb-750"
871 ;;
872 *"RouterBOARD 750 r2")
873 name="rb-750-r2"
874 ;;
875 *"RouterBOARD 750GL")
876 name="rb-750gl"
877 ;;
878 *"RouterBOARD 750UP r2")
879 name="rb-750up-r2"
880 ;;
881 *"RouterBOARD 751")
882 name="rb-751"
883 ;;
884 *"RouterBOARD 751G")
885 name="rb-751g"
886 ;;
887 *"RouterBOARD 911G-2HPnD")
888 name="rb-911g-2hpnd"
889 ;;
890 *"RouterBOARD 911G-5HPacD")
891 name="rb-911g-5hpacd"
892 ;;
893 *"RouterBOARD 911G-5HPnD")
894 name="rb-911g-5hpnd"
895 ;;
896 *"RouterBOARD 912UAG-2HPnD")
897 name="rb-912uag-2hpnd"
898 ;;
899 *"RouterBOARD 912UAG-5HPnD")
900 name="rb-912uag-5hpnd"
901 ;;
902 *"RouterBOARD 941-2nD")
903 name="rb-941-2nd"
904 ;;
905 *"RouterBOARD 951G-2HnD")
906 name="rb-951g-2hnd"
907 ;;
908 *"RouterBOARD 951Ui-2HnD")
909 name="rb-951ui-2hnd"
910 ;;
911 *"RouterBOARD 951Ui-2nD")
912 name="rb-951ui-2nd"
913 ;;
914 *"RouterBOARD 952Ui-5ac2nD")
915 name="rb-952ui-5ac2nd"
916 ;;
917 *"RouterBOARD 962UiGS-5HacT2HnT")
918 name="rb-962uigs-5hact2hnt"
919 ;;
920 *"RouterBOARD LHG 5nD")
921 name="rb-lhg-5nd"
922 ;;
923 *"RouterBOARD mAP L-2nD")
924 name="rb-mapl-2nd"
925 ;;
926 *"RouterBOARD SXT Lite2")
927 name="rb-sxt2n"
928 ;;
929 *"RouterBOARD SXT Lite5")
930 name="rb-sxt5n"
931 ;;
932 *"RouterStation")
933 name="routerstation"
934 ;;
935 *"RouterStation Pro")
936 name="routerstation-pro"
937 ;;
938 *"RW2458N")
939 name="rw2458n"
940 ;;
941 *"SC1750")
942 name="sc1750"
943 ;;
944 *"SC300M")
945 name="sc300m"
946 ;;
947 *"SC450")
948 name="sc450"
949 ;;
950 *"SMART-300")
951 name="smart-300"
952 ;;
953 *"SOM9331")
954 name="som9331"
955 ;;
956 *"SR3200")
957 name="sr3200"
958 ;;
959 *"TellStick ZNet Lite")
960 name="tellstick-znet-lite"
961 ;;
962 *"TEW-632BRP")
963 name="tew-632brp"
964 ;;
965 *"TEW-673GRU")
966 name="tew-673gru"
967 ;;
968 *"TEW-712BR")
969 name="tew-712br"
970 ;;
971 *"TEW-732BR")
972 name="tew-732br"
973 ;;
974 *"TEW-823DRU")
975 name="tew-823dru"
976 ;;
977 *"TL-MR10U")
978 name="tl-mr10u"
979 ;;
980 *"TL-MR11U")
981 name="tl-mr11u"
982 ;;
983 *"TL-MR12U")
984 name="tl-mr12u"
985 ;;
986 *"TL-MR13U v1")
987 name="tl-mr13u"
988 ;;
989 *"TL-MR3020")
990 name="tl-mr3020"
991 ;;
992 *"TL-MR3040")
993 name="tl-mr3040"
994 ;;
995 *"TL-MR3040 v2")
996 name="tl-mr3040-v2"
997 ;;
998 *"TL-MR3220")
999 name="tl-mr3220"
1000 ;;
1001 *"TL-MR3220 v2")
1002 name="tl-mr3220-v2"
1003 ;;
1004 *"TL-MR3420")
1005 name="tl-mr3420"
1006 ;;
1007 *"TL-MR3420 v2")
1008 name="tl-mr3420-v2"
1009 ;;
1010 *"TL-WA701ND v2")
1011 name="tl-wa701nd-v2"
1012 ;;
1013 *"TL-WA7210N v2")
1014 name="tl-wa7210n-v2"
1015 ;;
1016 *"TL-WA750RE")
1017 name="tl-wa750re"
1018 ;;
1019 *"TL-WA7510N v1")
1020 name="tl-wa7510n"
1021 ;;
1022 *"TL-WA801ND v2")
1023 name="tl-wa801nd-v2"
1024 ;;
1025 *"TL-WA801ND v3")
1026 name="tl-wa801nd-v3"
1027 ;;
1028 *"TL-WA830RE v2")
1029 name="tl-wa830re-v2"
1030 ;;
1031 *"TL-WA850RE")
1032 name="tl-wa850re"
1033 ;;
1034 *"TL-WA850RE v2")
1035 name="tl-wa850re-v2"
1036 ;;
1037 *"TL-WA860RE")
1038 name="tl-wa860re"
1039 ;;
1040 *"TL-WA901ND")
1041 name="tl-wa901nd"
1042 ;;
1043 *"TL-WA901ND v2")
1044 name="tl-wa901nd-v2"
1045 ;;
1046 *"TL-WA901ND v3")
1047 name="tl-wa901nd-v3"
1048 ;;
1049 *"TL-WA901ND v4")
1050 name="tl-wa901nd-v4"
1051 ;;
1052 *"TL-WDR3320 v2")
1053 name="tl-wdr3320-v2"
1054 ;;
1055 *"TL-WDR3500")
1056 name="tl-wdr3500"
1057 ;;
1058 *"TL-WDR3600/4300/4310")
1059 name="tl-wdr4300"
1060 ;;
1061 *"TL-WDR4900 v2")
1062 name="tl-wdr4900-v2"
1063 ;;
1064 *"TL-WDR6500 v2")
1065 name="tl-wdr6500-v2"
1066 ;;
1067 *"TL-WPA8630")
1068 name="tl-wpa8630"
1069 ;;
1070 *"TL-WR1041N v2")
1071 name="tl-wr1041n-v2"
1072 ;;
1073 *"TL-WR1043ND")
1074 name="tl-wr1043nd"
1075 ;;
1076 *"TL-WR1043ND v2")
1077 name="tl-wr1043nd-v2"
1078 ;;
1079 *"TL-WR1043ND v4")
1080 name="tl-wr1043nd-v4"
1081 ;;
1082 *"TL-WR2543N"*)
1083 name="tl-wr2543n"
1084 ;;
1085 *"TL-WR703N v1")
1086 name="tl-wr703n"
1087 ;;
1088 *"TL-WR710N v1")
1089 name="tl-wr710n"
1090 ;;
1091 *"TL-WR720N"*)
1092 name="tl-wr720n-v3"
1093 ;;
1094 *"TL-WR741ND")
1095 name="tl-wr741nd"
1096 ;;
1097 *"TL-WR741ND v4")
1098 name="tl-wr741nd-v4"
1099 ;;
1100 *"TL-WR802N v1")
1101 name="tl-wr802n-v1"
1102 ;;
1103 *"TL-WR802N v2")
1104 name="tl-wr802n-v2"
1105 ;;
1106 *"TL-WR810N")
1107 name="tl-wr810n"
1108 ;;
1109 *"TL-WR840N v2")
1110 name="tl-wr840n-v2"
1111 ;;
1112 *"TL-WR840N v3")
1113 name="tl-wr840n-v3"
1114 ;;
1115 *"TL-WR841N v1")
1116 name="tl-wr841n-v1"
1117 ;;
1118 *"TL-WR841N/ND v11")
1119 name="tl-wr841n-v11"
1120 ;;
1121 *"TL-WR841N/ND v7")
1122 name="tl-wr841n-v7"
1123 ;;
1124 *"TL-WR841N/ND v8")
1125 name="tl-wr841n-v8"
1126 ;;
1127 *"TL-WR841N/ND v9")
1128 name="tl-wr841n-v9"
1129 ;;
1130 *"TL-WR842N/ND v2")
1131 name="tl-wr842n-v2"
1132 ;;
1133 *"TL-WR842N/ND v3")
1134 name="tl-wr842n-v3"
1135 ;;
1136 *"TL-WR940N v4")
1137 name="tl-wr940n-v4"
1138 ;;
1139 *"TL-WR941N/ND v5")
1140 name="tl-wr941nd-v5"
1141 ;;
1142 *"TL-WR941N/ND v6")
1143 name="tl-wr941nd-v6"
1144 ;;
1145 *"TL-WR941ND")
1146 name="tl-wr941nd"
1147 ;;
1148 *"Tube2H")
1149 name="tube2h"
1150 ;;
1151 *"UniFi")
1152 name="unifi"
1153 ;;
1154 *"UniFi AP Pro")
1155 name="uap-pro"
1156 ;;
1157 *"UniFi-AC-LITE")
1158 name="unifiac-lite"
1159 ;;
1160 *"UniFi-AC-PRO")
1161 name="unifiac-pro"
1162 ;;
1163 *"UniFiAP Outdoor")
1164 name="unifi-outdoor"
1165 ;;
1166 *"UniFiAP Outdoor+")
1167 name="unifi-outdoor-plus"
1168 ;;
1169 *"WBS210")
1170 name="wbs210"
1171 tplink_pharos_board_detect
1172 ;;
1173 *"WBS510")
1174 name="wbs510"
1175 tplink_pharos_board_detect
1176 ;;
1177 "WeIO"*)
1178 name="weio"
1179 ;;
1180 *"WHR-G301N")
1181 name="whr-g301n"
1182 ;;
1183 *"WHR-HP-G300N")
1184 name="whr-hp-g300n"
1185 ;;
1186 *"WHR-HP-GN")
1187 name="whr-hp-gn"
1188 ;;
1189 *"WLAE-AG300N")
1190 name="wlae-ag300n"
1191 ;;
1192 *"WLR-8100")
1193 name="wlr8100"
1194 ;;
1195 *"WNDAP360")
1196 name="wndap360"
1197 ;;
1198 *"WNDR3700/WNDR3800/WNDRMAC")
1199 wndr3700_board_detect "$machine"
1200 ;;
1201 *"WNDR3700v4")
1202 name="wndr3700v4"
1203 ;;
1204 *"WNDR4300")
1205 name="wndr4300"
1206 ;;
1207 *"WNR1000 V2")
1208 name="wnr1000-v2"
1209 ;;
1210 *"WNR2000")
1211 name="wnr2000"
1212 ;;
1213 *"WNR2000 V3")
1214 name="wnr2000-v3"
1215 ;;
1216 *"WNR2000 V4")
1217 name="wnr2000-v4"
1218 ;;
1219 *"WNR2200")
1220 name="wnr2200"
1221 ;;
1222 *"WNR612 V2")
1223 name="wnr612-v2"
1224 ;;
1225 *"WP543")
1226 name="wp543"
1227 ;;
1228 *"WPE72")
1229 name="wpe72"
1230 ;;
1231 *"WPJ342")
1232 name="wpj342"
1233 ;;
1234 *"WPJ344")
1235 name="wpj344"
1236 ;;
1237 *"WPJ531")
1238 name="wpj531"
1239 ;;
1240 *"WPJ558")
1241 name="wpj558"
1242 ;;
1243 *"WPJ563")
1244 name="wpj563"
1245 ;;
1246 *"WPN824N")
1247 name="wpn824n"
1248 ;;
1249 *"WRT160NL")
1250 name="wrt160nl"
1251 ;;
1252 *"WRT400N")
1253 name="wrt400n"
1254 ;;
1255 *"WRTnode2Q"*)
1256 name="wrtnode2q"
1257 ;;
1258 *"WZR-450HP2")
1259 name="wzr-450hp2"
1260 ;;
1261 *"WZR-HP-AG300H/WZR-600DHP")
1262 name="wzr-hp-ag300h"
1263 ;;
1264 *"WZR-HP-G300NH")
1265 name="wzr-hp-g300nh"
1266 ;;
1267 *"WZR-HP-G300NH2")
1268 name="wzr-hp-g300nh2"
1269 ;;
1270 *"WZR-HP-G450H")
1271 name="wzr-hp-g450h"
1272 ;;
1273 *"XD3200")
1274 name="xd3200"
1275 ;;
1276 *"Z1")
1277 name="z1"
1278 ;;
1279 *"ZBT-WE1526")
1280 name="zbt-we1526"
1281 ;;
1282 *"ZCN-1523H-2")
1283 name="zcn-1523h-2"
1284 ;;
1285 *"ZCN-1523H-5")
1286 name="zcn-1523h-5"
1287 ;;
1288 esac
1289
1290 [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1291 tplink_board_detect "$machine"
1292
1293 [ -z "$name" ] && name="unknown"
1294
1295 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1296 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1297
1298 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1299
1300 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1301 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1302 }
1303
1304 ar71xx_board_name() {
1305 local name
1306
1307 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1308 [ -z "$name" ] && name="unknown"
1309
1310 echo "$name"
1311 }