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