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