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