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