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