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