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