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