ar71xx: add support for Cisco Meraki Z1 Cloud Managed Teleworker Gateway
[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         *CAP4200AG)
486                 name="cap4200ag"
487                 ;;
488         *"COMFAST CF-E316N v2")
489                 name="cf-e316n-v2"
490                 ;;
491         *"CPE210/220")
492                 name="cpe210"
493                 tplink_pharos_board_detect
494                 ;;
495         *"CPE510/520")
496                 name="cpe510"
497                 tplink_pharos_board_detect
498                 ;;
499         *CR3000)
500                 name="cr3000"
501                 ;;
502         *CR5000)
503                 name="cr5000"
504                 ;;
505         *"DB120 reference board")
506                 name="db120"
507                 ;;
508         *"DGL-5500 rev. A1")
509                 name="dgl-5500-a1"
510                 ;;
511         *"DHP-1565 rev. A1")
512                 name="dhp-1565-a1"
513                 ;;
514         *"DIR-505 rev. A1")
515                 name="dir-505-a1"
516                 dir505_board_detect
517                 ;;
518         *"DIR-600 rev. A1")
519                 name="dir-600-a1"
520                 ;;
521         *"DIR-615 rev. E1")
522                 name="dir-615-e1"
523                 ;;
524         *"DIR-615 rev. E4")
525                 name="dir-615-e4"
526                 ;;
527         *"DIR-615 rev. I1")
528                 name="dir-615-i1"
529                 ;;
530         *"DIR-825 rev. B1")
531                 name="dir-825-b1"
532                 ;;
533         *"DIR-825 rev. C1")
534                 name="dir-825-c1"
535                 ;;
536         *"DIR-835 rev. A1")
537                 name="dir-835-a1"
538                 ;;
539         *"dLAN Hotspot")
540                 name="dlan-hotspot"
541                 ;;
542         *"dLAN pro 500 Wireless+")
543                 name="dlan-pro-500-wp"
544                 ;;
545         *"dLAN pro 1200+ WiFi ac")
546                 name="dlan-pro-1200-ac"
547                 ;;
548         *DR344)
549                 name="dr344"
550                 ;;
551         *DR531)
552                 name="dr531"
553                 ;;
554         *"Dragino v2")
555                 name="dragino2"
556                 ;;
557         *"Domino Pi")
558                 name="gl-domino"
559                 ;;
560         *"EAP300 v2")
561                 name="eap300v2"
562                 ;;
563         *EAP7660D)
564                 name="eap7660d"
565                 ;;
566         *EL-M150)
567                 name="el-m150"
568                 ;;
569         *EL-MINI)
570                 name="el-mini"
571                 ;;
572         *"GL-CONNECT INET v1")
573                 name="gl-inet"
574                 gl_inet_board_detect
575                 ;;
576         *"GL AR150")
577                 name="gl-ar150"
578                 ;;
579         *"GL AR300")
580                 name="gl-ar300"
581                 ;;
582         *"GL-AR300M")
583                 name="gl-ar300m"
584                 ;;
585         *"GL-MIFI")
586                 name="gl-mifi"
587                 ;;
588         *"EnGenius EPG5000")
589                 name="epg5000"
590                 ;;
591         *"EnGenius ESR1750")
592                 name="esr1750"
593                 ;;
594         *"EnGenius ESR900")
595                 name="esr900"
596                 ;;
597         *JA76PF)
598                 name="ja76pf"
599                 ;;
600         *JA76PF2)
601                 name="ja76pf2"
602                 ;;
603         *"Bullet M")
604                 name="bullet-m"
605                 ubnt_xm_board_detect
606                 ;;
607         *"Loco M XW")
608                 name="loco-m-xw"
609                 ;;
610         *"Nanostation M")
611                 name="nanostation-m"
612                 ubnt_xm_board_detect
613                 ;;
614         *"Nanostation M XW")
615                 name="nanostation-m-xw"
616                 ;;
617         *JWAP003)
618                 name="jwap003"
619                 ;;
620         *JWAP230)
621                 name="jwap230"
622                 ;;
623         *"Hornet-UB")
624                 local size
625                 size=$(awk '/firmware/ { print $2 }' /proc/mtd)
626
627                 if [ "x$size" = "x00790000" ]; then
628                         name="hornet-ub"
629                 fi
630
631                 if [ "x$size" = "x00f90000" ]; then
632                         name="hornet-ub-x2"
633                 fi
634                 ;;
635         *LS-SR71)
636                 name="ls-sr71"
637                 ;;
638         *"MAC1200R")
639                 name="mc-mac1200r"
640                 ;;
641         *"MiniBox V1.0")
642                 name="minibox-v1"
643                 ;;
644         *MR12)
645                 name="mr12"
646                 ;;
647         *MR16)
648                 name="mr16"
649                 ;;
650         *MR18)
651                 name="mr18"
652                 ;;
653         *MR600v2)
654                 name="mr600v2"
655                 ;;
656         *MR1750)
657                 name="mr1750"
658                 ;;
659         *MR1750v2)
660                 name="mr1750v2"
661                 ;;
662         *MR600)
663                 name="mr600"
664                 ;;
665         *MR900)
666                 name="mr900"
667                 ;;
668         *MR900v2)
669                 name="mr900v2"
670                 ;;
671         *"My Net N600")
672                 name="mynet-n600"
673                 ;;
674         *"My Net N750")
675                 name="mynet-n750"
676                 ;;
677         *"WD My Net Wi-Fi Range Extender")
678                 name="mynet-rext"
679                 ;;
680         *MZK-W04NU)
681                 name="mzk-w04nu"
682                 ;;
683         *MZK-W300NH)
684                 name="mzk-w300nh"
685                 ;;
686         *"NBG460N/550N/550NH")
687                 name="nbg460n_550n_550nh"
688                 ;;
689         *"Zyxel NBG6616")
690                 name="nbg6616"
691                 ;;
692         *"Zyxel NBG6716")
693                 name="nbg6716"
694                 ;;
695         *OM2P)
696                 name="om2p"
697                 ;;
698         *OM2Pv2)
699                 name="om2pv2"
700                 ;;
701         *"OM2P HS")
702                 name="om2p-hs"
703                 ;;
704         *"OM2P HSv2")
705                 name="om2p-hsv2"
706                 ;;
707         *"OM2P HSv3")
708                 name="om2p-hsv3"
709                 ;;
710         *"OM2P LC")
711                 name="om2p-lc"
712                 ;;
713         *OM5P)
714                 name="om5p"
715                 ;;
716         *"OM5P AN")
717                 name="om5p-an"
718                 ;;
719         *"OM5P AC")
720                 name="om5p-ac"
721                 ;;
722         *"OM5P ACv2")
723                 name="om5p-acv2"
724                 ;;
725         *"OMY-X1")
726                 name="omy-x1"
727                 ;;
728         *"OMY-G1")
729                 name="omy-g1"
730                 ;;
731         *"Onion Omega")
732                 name="onion-omega"
733                 ;;
734         *PB42)
735                 name="pb42"
736                 ;;
737         *"PB44 reference board")
738                 name="pb44"
739                 ;;
740         *PB92)
741                 name="pb92"
742                 ;;
743         *"Qihoo 360 C301")
744                 name="qihoo-c301"
745                 ;;
746         *"RouterBOARD 411/A/AH")
747                 name="rb-411"
748                 ;;
749         *"RouterBOARD 411U")
750                 name="rb-411u"
751                 ;;
752         *"RouterBOARD 433/AH")
753                 name="rb-433"
754                 ;;
755         *"RouterBOARD 433UAH")
756                 name="rb-433u"
757                 ;;
758         *"RouterBOARD 435G")
759                 name="rb-435g"
760                 ;;
761         *"RouterBOARD 450")
762                 name="rb-450"
763                 ;;
764         *"RouterBOARD 450G")
765                 name="rb-450g"
766                 ;;
767         *"RouterBOARD 493/AH")
768                 name="rb-493"
769                 ;;
770         *"RouterBOARD 493G")
771                 name="rb-493g"
772                 ;;
773         *"RouterBOARD 750")
774                 name="rb-750"
775                 ;;
776         *"RouterBOARD 750GL")
777                 name="rb-750gl"
778                 ;;
779         *"RouterBOARD 751")
780                 name="rb-751"
781                 ;;
782         *"RouterBOARD 751G")
783                 name="rb-751g"
784                 ;;
785         *"RouterBOARD 911G-2HPnD")
786                 name="rb-911g-2hpnd"
787                 ;;
788         *"RouterBOARD 911G-5HPnD")
789                 name="rb-911g-5hpnd"
790                 ;;
791         *"RouterBOARD 911G-5HPacD")
792                 name="rb-911g-5hpacd"
793                 ;;
794         *"RouterBOARD 912UAG-2HPnD")
795                 name="rb-912uag-2hpnd"
796                 ;;
797         *"RouterBOARD 912UAG-5HPnD")
798                 name="rb-912uag-5hpnd"
799                 ;;
800         *"RouterBOARD 951G-2HnD")
801                 name="rb-951g-2hnd"
802                 ;;
803         *"RouterBOARD 951Ui-2HnD")
804                 name="rb-951ui-2hnd"
805                 ;;
806         *"RouterBOARD 2011L")
807                 name="rb-2011l"
808                 ;;
809         *"RouterBOARD 2011UAS")
810                 name="rb-2011uas"
811                 ;;
812         *"RouterBOARD 2011UiAS")
813                 name="rb-2011uias"
814                 ;;
815         *"RouterBOARD 2011UAS-2HnD")
816                 name="rb-2011uas-2hnd"
817                 ;;
818         *"RouterBOARD 2011UiAS-2HnD")
819                 name="rb-2011uias-2hnd"
820                 ;;
821         *"RouterBOARD SXT Lite2")
822                 name="rb-sxt2n"
823                 ;;
824         *"RouterBOARD SXT Lite5")
825                 name="rb-sxt5n"
826                 ;;
827         *"Rocket M")
828                 name="rocket-m"
829                 ubnt_xm_board_detect
830                 ;;
831         *"Rocket M TI")
832                 name="rocket-m-ti"
833                 ;;
834         *"Rocket M XW")
835                 name="rocket-m-xw"
836                 ;;
837         *RouterStation)
838                 name="routerstation"
839                 ;;
840         *"RouterStation Pro")
841                 name="routerstation-pro"
842                 ;;
843         *RW2458N)
844                 name="rw2458n"
845                 ;;
846         *"SMART-300")
847                 name="smart-300"
848                 ;;
849         "Smart Electronics Black Swift board"*)
850                 name="bsb"
851                 ;;
852         *"Telldus TellStick ZNet Lite")
853                 name="tellstick-znet-lite"
854                 ;;
855         *SOM9331)
856                 name="som9331"
857                 ;;
858         *TEW-632BRP)
859                 name="tew-632brp"
860                 ;;
861         *TEW-673GRU)
862                 name="tew-673gru"
863                 ;;
864         *TEW-712BR)
865                 name="tew-712br"
866                 ;;
867         *TEW-732BR)
868                 name="tew-732br"
869                 ;;
870         *TEW-823DRU)
871                 name="tew-823dru"
872                 ;;
873         *"TL-WR1041N v2")
874                 name="tl-wr1041n-v2"
875                 ;;
876         *TL-WR1043ND)
877                 name="tl-wr1043nd"
878                 ;;
879         *"TL-WR1043ND v2")
880                 name="tl-wr1043nd-v2"
881                 ;;
882         *TL-WR2543N*)
883                 name="tl-wr2543n"
884                 ;;
885         *"DIR-615 rev. C1")
886                 name="dir-615-c1"
887                 ;;
888         *TL-MR3020)
889                 name="tl-mr3020"
890                 ;;
891         *TL-MR3040)
892                 name="tl-mr3040"
893                 ;;
894         *"TL-MR3040 v2")
895                 name="tl-mr3040-v2"
896                 ;;
897         *TL-MR3220)
898                 name="tl-mr3220"
899                 ;;
900         *"TL-MR3220 v2")
901                 name="tl-mr3220-v2"
902                 ;;
903         *TL-MR3420)
904                 name="tl-mr3420"
905                 ;;
906         *"TL-MR3420 v2")
907                 name="tl-mr3420-v2"
908                 ;;
909         *"TL-WA701ND v2")
910                 name="tl-wa701nd-v2"
911                 ;;
912         *"TL-WA7210N v2")
913                 name="tl-wa7210n-v2"
914                 ;;
915         *TL-WA750RE)
916                 name="tl-wa750re"
917                 ;;
918         *"TL-WA7510N v1")
919                 name="tl-wa7510n"
920                 ;;
921         *TL-WA850RE)
922                 name="tl-wa850re"
923                 ;;
924         *TL-WA860RE)
925                 name="tl-wa860re"
926                 ;;
927         *"TL-WA830RE v2")
928                 name="tl-wa830re-v2"
929                 ;;
930         *"TL-WA801ND v2")
931                 name="tl-wa801nd-v2"
932                 ;;
933         *"TL-WA801ND v3")
934                 name="tl-wa801nd-v3"
935                 ;;
936         *TL-WA901ND)
937                 name="tl-wa901nd"
938                 ;;
939         *"TL-WA901ND v2")
940                 name="tl-wa901nd-v2"
941                 ;;
942         *"TL-WA901ND v3")
943                 name="tl-wa901nd-v3"
944                 ;;
945         *"TL-WA901ND v4")
946                 name="tl-wa901nd-v4"
947                 ;;
948         *"TL-WDR3320 v2")
949                 name="tl-wdr3320-v2"
950                 ;;
951         *"TL-WDR3500")
952                 name="tl-wdr3500"
953                 ;;
954         *"TL-WDR3600/4300/4310")
955                 name="tl-wdr4300"
956                 ;;
957         *"TL-WDR4900 v2")
958                 name="tl-wdr4900-v2"
959                 ;;
960         *"TL-WDR6500 v2")
961                 name="tl-wdr6500-v2"
962                 ;;
963         *TL-WR741ND)
964                 name="tl-wr741nd"
965                 ;;
966         *"TL-WR741ND v4")
967                 name="tl-wr741nd-v4"
968                 ;;
969         *"TL-WR841N v1")
970                 name="tl-wr841n-v1"
971                 ;;
972         *"TL-WR841N/ND v7")
973                 name="tl-wr841n-v7"
974                 ;;
975         *"TL-WR841N/ND v8")
976                 name="tl-wr841n-v8"
977                 ;;
978         *"TL-WR841N/ND v9")
979                 name="tl-wr841n-v9"
980                 ;;
981         *"TL-WR841N/ND v11")
982                 name="tl-wr841n-v11"
983                 ;;
984         *"TL-WR842N/ND v2")
985                 name="tl-wr842n-v2"
986                 ;;
987         *"TL-WR842N/ND v3")
988                 name="tl-wr842n-v3"
989                 ;;
990         *TL-WR941ND)
991                 name="tl-wr941nd"
992                 ;;
993         *"TL-WR941N/ND v5")
994                 name="tl-wr941nd-v5"
995                 ;;
996         *"TL-WR941N/ND v6")
997                 name="tl-wr941nd-v6"
998                 ;;
999         *"TL-WR703N v1")
1000                 name="tl-wr703n"
1001                 ;;
1002         *"TL-WR710N v1")
1003                 name="tl-wr710n"
1004                 ;;
1005         *"TL-WR720N"*)
1006                 name="tl-wr720n-v3"
1007                 ;;
1008         *"TL-WR810N")
1009                 name="tl-wr810n"
1010                 ;;
1011         *"TL-MR10U")
1012                 name="tl-mr10u"
1013                 ;;
1014         *"TL-MR11U")
1015                 name="tl-mr11u"
1016                 ;;
1017         *"TL-MR12U")
1018                 name="tl-mr12u"
1019                 ;;
1020         *"TL-MR13U v1")
1021                 name="tl-mr13u"
1022                 ;;
1023         *"Tube2H")
1024                 name="tube2h"
1025                 ;;
1026         *UniFi)
1027                 name="unifi"
1028                 ;;
1029         *"UniFi-AC-LITE")
1030                 name="unifiac-lite"
1031                 ;;
1032         *"UniFi-AC-PRO")
1033                 name="unifiac-pro"
1034                 ;;
1035         *"UniFi AP Pro")
1036                 name="uap-pro"
1037                 ;;
1038         "WeIO"*)
1039                 name="weio"
1040                 ;;
1041         *WHR-G301N)
1042                 name="whr-g301n"
1043                 ;;
1044         *WHR-HP-GN)
1045                 name="whr-hp-gn"
1046                 ;;
1047         *WLAE-AG300N)
1048                 name="wlae-ag300n"
1049                 ;;
1050         *"UniFiAP Outdoor")
1051                 name="unifi-outdoor"
1052                 ;;
1053         *"UniFiAP Outdoor+")
1054                 name="unifi-outdoor-plus"
1055                 ;;
1056         *WP543)
1057                 name="wp543"
1058                 ;;
1059         *WPE72)
1060                 name="wpe72"
1061                 ;;
1062         *WPJ342)
1063                 name="wpj342"
1064                 ;;
1065         *WPJ344)
1066                 name="wpj344"
1067                 ;;
1068         *WPJ531)
1069                 name="wpj531"
1070                 ;;
1071         *WPJ558)
1072                 name="wpj558"
1073                 ;;
1074         *WNDAP360)
1075                 name="wndap360"
1076                 ;;
1077         *"WNDR3700/WNDR3800/WNDRMAC")
1078                 wndr3700_board_detect "$machine"
1079                 ;;
1080         *"R6100")
1081                 name="r6100"
1082                 ;;
1083         *"WNDR3700v4")
1084                 name="wndr3700v4"
1085                 ;;
1086         *"WNDR4300")
1087                 name="wndr4300"
1088                 ;;
1089         *"WNR2000 V4")
1090                 name="wnr2000-v4"
1091                 ;;
1092         *"WNR2000 V3")
1093                 name="wnr2000-v3"
1094                 ;;
1095         *WNR2000)
1096                 name="wnr2000"
1097                 ;;
1098         *WNR2200)
1099                 name="wnr2200"
1100                 ;;
1101         *"WNR612 V2")
1102                 name="wnr612-v2"
1103                 ;;
1104         *"WNR1000 V2")
1105                 name="wnr1000-v2"
1106                 ;;
1107         *WPN824N)
1108                 name="wpn824n"
1109                 ;;
1110         *WRT160NL)
1111                 name="wrt160nl"
1112                 ;;
1113         *WRT400N)
1114                 name="wrt400n"
1115                 ;;
1116         *"WRTnode2Q board")
1117                 name="wrtnode2q"
1118                 ;;
1119         *"WZR-450HP2")
1120                 name="wzr-450hp2"
1121                 ;;
1122         *"WZR-HP-AG300H/WZR-600DHP")
1123                 name="wzr-hp-ag300h"
1124                 ;;
1125         *WZR-HP-G300NH)
1126                 name="wzr-hp-g300nh"
1127                 ;;
1128         *WZR-HP-G450H)
1129                 name="wzr-hp-g450h"
1130                 ;;
1131         *WZR-HP-G300NH2)
1132                 name="wzr-hp-g300nh2"
1133                 ;;
1134         *WHR-HP-G300N)
1135                 name="whr-hp-g300n"
1136                 ;;
1137         *Z1)
1138                 name="z1"
1139                 ;;
1140         *ZBT-WE1526)
1141                 name="zbt-we1526"
1142                 ;;
1143         *ZCN-1523H-2)
1144                 name="zcn-1523h-2"
1145                 ;;
1146         *ZCN-1523H-5)
1147                 name="zcn-1523h-5"
1148                 ;;
1149         *EmbWir-Dorin)
1150                 name="ew-dorin"
1151                 ;;
1152         *EmbWir-Dorin-Router)
1153                 name="ew-dorin-router"
1154                 ;;
1155         "8devices Carambola2"*)
1156                 name="carambola2"
1157                 ;;
1158         *"Sitecom WLR-8100")
1159                 name="wlr8100"
1160                 ;;
1161         *"BHU BXU2000n-2 rev. A1")
1162                 name="bxu2000n-2-a1"
1163                 ;;
1164         *"HiWiFi HC6361")
1165                 name="hiwifi-hc6361"
1166                 ;;
1167         esac
1168
1169         [ -z "$AR71XX_MODEL" ] && [ "${machine:0:8}" = 'TP-LINK ' ] && \
1170                 tplink_board_detect "$machine"
1171
1172         [ -z "$name" ] && name="unknown"
1173
1174         [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
1175         [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
1176
1177         [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
1178
1179         echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
1180         echo "$AR71XX_MODEL" > /tmp/sysinfo/model
1181 }
1182
1183 ar71xx_board_name() {
1184         local name
1185
1186         [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
1187         [ -z "$name" ] && name="unknown"
1188
1189         echo "$name"
1190 }