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