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