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