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