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