13d325dbbca7c593b76a674e8dcd75d0f627e081
[openwrt.git] / target / linux / ramips / base-files / lib / ramips.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010-2013 OpenWrt.org
4 #
5
6 RAMIPS_BOARD_NAME=
7 RAMIPS_MODEL=
8
9 ramips_board_detect() {
10         local machine
11         local name
12
13         machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
14
15         case "$machine" in
16         *"3G150B")
17                 name="3g150b"
18                 ;;
19         *"3G300M")
20                 name="3g300m"
21                 ;;
22         *"3g-6200n")
23                 name="3g-6200n"
24                 ;;
25         *"3g-6200nl")
26                 name="3g-6200nl"
27                 ;;
28         *"A5-V11")
29                 name="a5-v11"
30                 ;;
31         *"Ai-BR100")
32                 name="ai-br100"
33                 ;;
34         *"Air3GII")
35                 name="air3gii"
36                 ;;
37         *"ALL0239-3G")
38                 name="all0239-3g"
39                 ;;
40         *"ALL0256N")
41                 name="all0256n"
42                 ;;
43         *"ALL5002")
44                 name="all5002"
45                 ;;
46         *"ALL5003")
47                 name="all5003"
48                 ;;
49         *"AR670W")
50                 name="ar670w"
51                 ;;
52         *"AR725W")
53                 name="ar725w"
54                 ;;
55         *"ASL26555")
56                 name="asl26555"
57                 ;;
58         *"ATP-52B")
59                 name="atp-52b"
60                 ;;
61         *"AWAPN2403")
62                 name="awapn2403"
63                 ;;
64         *"AWM002 EVB")
65                 name="awm002-evb"
66                 ;;
67         *"AWM003 EVB")
68                 name="awm003-evb"
69                 ;;
70         *"BC2")
71                 name="bc2"
72                 ;;
73         *"BR-6425")
74                 name="br-6425"
75                 ;;
76         *"BR-6475nD")
77                 name="br-6475nd"
78                 ;;
79         *"Broadway")
80                 name="broadway"
81                 ;;
82         *"C20i")
83                 name="c20i"
84                 ;;
85         *"Carambola")
86                 name="carambola"
87                 ;;
88         *"CF-WR800N")
89                 name="cf-wr800n"
90                 ;;
91         *"CS-QR10")
92                 name="cs-qr10"
93                 ;;
94         *"CY-SWR1100")
95                 name="cy-swr1100"
96                 ;;
97         *"D105")
98                 name="d105"
99                 ;;
100         *"DAP-1350")
101                 name="dap-1350"
102                 ;;
103         *"DB-WRT01")
104                 name="db-wrt01"
105                 ;;
106         *"DCS-930")
107                 name="dcs-930"
108                 ;;
109         *"DCS-930L B1")
110                 name="dcs-930l-b1"
111                 ;;
112         *"DIR-300 B1")
113                 name="dir-300-b1"
114                 ;;
115         *"DIR-300 B7")
116                 name="dir-300-b7"
117                 ;;
118         *"DIR-320 B1")
119                 name="dir-320-b1"
120                 ;;
121         *"DIR-600 B1")
122                 name="dir-600-b1"
123                 ;;
124         *"DIR-600 B2")
125                 name="dir-600-b2"
126                 ;;
127         *"DIR-610 A1")
128                 name="dir-610-a1"
129                 ;;
130         *"DIR-615 D")
131                 name="dir-615-d"
132                 ;;
133         *"DIR-615 H1")
134                 name="dir-615-h1"
135                 ;;
136         *"DIR-620 A1")
137                 name="dir-620-a1"
138                 ;;
139         *"DIR-620 D1")
140                 name="dir-620-d1"
141                 ;;
142         *"DIR-645")
143                 name="dir-645"
144                 ;;
145         *"DIR-810L")
146                 name="dir-810l"
147                 ;;
148         *"DIR-860L B1")
149                 name="dir-860l-b1"
150                 ;;
151         *"Dovado Tiny AC")
152                 name="tiny-ac"
153                 ;;
154         *"E1700")
155                 name="e1700"
156                 ;;
157         *"ESR-9753")
158                 name="esr-9753"
159                 ;;
160         *"EX2700")
161                 name="ex2700";
162                 ;;
163         *"F5D8235 v1")
164                 name="f5d8235-v1"
165                 ;;
166         *"F5D8235 v2")
167                 name="f5d8235-v2"
168                 ;;
169         *"F7C027")
170                 name="f7c027"
171                 ;;
172         *"FireWRT")
173                 name="firewrt"
174                 ;;
175         *"Fonera 2.0N")
176                 name="fonera20n"
177                 ;;
178         *"FreeStation5")
179                 name="freestation5"
180                 ;;
181         *"GL-MT300A")
182                 name="gl-mt300a"
183                 ;;
184         *"GL-MT300N")
185                 name="gl-mt300n"
186                 ;;
187         *"GL-MT750")
188                 name="gl-mt750"
189                 ;;
190         *"HC5661")
191                 name="hc5661"
192                 ;;
193         *"HC5761")
194                 name="hc5761"
195                 ;;
196         *"HC5861")
197                 name="hc5861"
198                 ;;
199         *"HG255D")
200                 name="hg255d"
201                 ;;
202         *"HLK-RM04")
203                 name="hlk-rm04"
204                 ;;
205         *"HPM")
206                 name="hpm"
207                 ;;
208         *"HT-TM02")
209                 name="ht-tm02"
210                 ;;
211         *"HW550-3G")
212                 name="hw550-3g"
213                 ;;
214         *"IP2202")
215                 name="ip2202"
216                 ;;
217         *"JHR-N805R")
218                 name="jhr-n805r"
219                 ;;
220         *"JHR-N825R")
221                 name="jhr-n825r"
222                 ;;
223         *"JHR-N926R")
224                 name="jhr-n926r"
225                 ;;
226         *"M3")
227                 name="m3"
228                 ;;
229         *"M4")
230                 name="m4"
231                 ;;
232         *"MediaTek LinkIt Smart 7688")
233                 linkit="$(dd bs=1 skip=1024 count=12 if=/dev/mtd2 2> /dev/null)"
234                 if [ "${linkit}" = "LINKITS7688D" ]; then
235                         name="linkits7688d"
236                         RAMIPS_MODEL="${machine} DUO"
237                 else
238                         name="linkits7688"
239                 fi
240                 ;;
241         *"Memory 2 Move")
242                 name="m2m"
243                 ;;
244         *"MicroWRT")
245                 name="microwrt"
246                 ;;
247         *"MiniEMBPlug")
248                 name="miniembplug"
249                 ;;
250         *"MiniEMBWiFi")
251                 name="miniembwifi"
252                 ;;
253         *"MiWiFi Mini")
254                 name="miwifi-mini"
255                 ;;
256         *"MiWiFi Nano")
257                 name="miwifi-nano"
258                 ;;
259         *"MLW221")
260                 name="mlw221"
261                 ;;
262         *"MLWG2")
263                 name="mlwg2"
264                 ;;
265         *"MOFI3500-3GN")
266                 name="mofi3500-3gn"
267                 ;;
268         *"MPR-A1")
269                 name="mpr-a1"
270                 ;;
271         *"MPR-A2")
272                 name="mpr-a2"
273                 ;;
274         *"MR-102N")
275                 name="mr-102n"
276                 ;;
277         *"MT7620a + MT7530 evaluation"*)
278                 name="mt7620a_mt7530"
279                 ;;
280         *"MT7620a V22SG"*)
281                 name="mt7620a_v22sg"
282                 ;;
283         *"MT7621 evaluation"*)
284                 name="mt7621"
285                 ;;
286         *"MT7628AN evaluation"*)
287                 name="mt7628"
288                 ;;
289         *"MT7688 evaluation"*)
290                 name="mt7688"
291                 ;;
292         *"MZK-750DHP")
293                 name="mzk-750dhp"
294                 ;;
295         *"MZK-DP150N")
296                 name="mzk-dp150n"
297                 ;;
298         *"MZK-EX300NP")
299                 name="mzk-ex300np"
300                 ;;
301         *"MZK-W300NH2"*)
302                 name="mzk-w300nh2"
303                 ;;
304         *"MZK-WDPR"*)
305                 name="mzk-wdpr"
306                 ;;
307         *"NA930")
308                 name="na930"
309                 ;;
310         *"NBG-419N")
311                 name="nbg-419n"
312                 ;;
313         *"NCS601W")
314                 name="ncs601w"
315                 ;;
316         *"NW718")
317                 name="nw718"
318                 ;;
319         *"OY-0001")
320                 name="oy-0001"
321                 ;;
322         *"PBR-M1")
323                 name="pbr-m1"
324                 ;;
325         *"PSG1208")
326                 name="psg1208"
327                 ;;
328         *"PSR-680W"*)
329                 name="psr-680w"
330                 ;;
331         *"PWH2004")
332                 name="pwh2004"
333                 ;;
334         *"PX-4885")
335                 name="px-4885"
336                 ;;
337         *"Q7")
338                 name="zte-q7"
339                 ;;
340         *"RE6500")
341                 name="re6500"
342                 ;;
343         *"RN502J")
344                 name="xdxrn502j"
345                 ;;
346         *"RP-N53")
347                 name="rp-n53"
348                 ;;
349         *"RT5350F-OLinuXino")
350                 name="rt5350f-olinuxino"
351                 ;;
352         *"RT5350F-OLinuXino-EVB")
353                 name="rt5350f-olinuxino-evb"
354                 ;;
355         *"RT-G32 B1")
356                 name="rt-g32-b1"
357                 ;;
358         *"RT-N10+")
359                 name="rt-n10-plus"
360                 ;;
361         *"RT-N13U")
362                 name="rt-n13u"
363                 ;;
364         *"RT-N14U")
365                 name="rt-n14u"
366                 ;;
367         *"RT-N15")
368                 name="rt-n15"
369                 ;;
370         *"RT-N56U")
371                 name="rt-n56u"
372                 ;;
373         *"RUT5XX")
374                 name="rut5xx"
375                 ;;
376         *"SAP-G3200U3")
377                 name="sap-g3200u3"
378                 ;;
379         *"SL-R7205"*)
380                 name="sl-r7205"
381                 ;;
382         *"TEW-691GR")
383                 name="tew-691gr"
384                 ;;
385         *"TEW-692GR")
386                 name="tew-692gr"
387                 ;;
388         *"UBNT-ERX")
389                 name="ubnt-erx"
390                 ;;
391         *"UR-326N4G")
392                 name="ur-326n4g"
393                 ;;
394         *"UR-336UN")
395                 name="ur-336un"
396                 ;;
397         *"V11ST-FE")
398                 name="v11st-fe"
399                 ;;
400         *"V22RW-2X2")
401                 name="v22rw-2x2"
402                 ;;
403         *"VoCore")
404                 name="vocore"
405                 ;;
406         *"W150M")
407                 name="w150m"
408                 ;;
409         *"W306R V2.0")
410                 name="w306r-v20"
411                 ;;
412         *"W502U")
413                 name="w502u"
414                 ;;
415         *"WCR-150GN")
416                 name="wcr-150gn"
417                 ;;
418         *"WF-2881")
419                 name="wf-2881"
420                 ;;
421         *"WHR-1166D")
422                 name="whr-1166d"
423                 ;;
424         *"WHR-300HP2")
425                 name="whr-300hp2"
426                 ;;
427         *"WHR-600D")
428                 name="whr-600d"
429                 ;;
430         *"WHR-G300N")
431                 name="whr-g300n"
432                 ;;
433         *"WiTi")
434                 name="witi"
435                 ;;
436         *"WIZARD 8800")
437                 name="wizard8800"
438                 ;;
439         *"WizFi630A")
440                 name="wizfi630a"
441                 ;;
442         *"WL-330N")
443                 name="wl-330n"
444                 ;;
445         *"WL-330N3G")
446                 name="wl-330n3g"
447                 ;;
448         *"WL-341 v3")
449                 name="wl-341v3"
450                 ;;
451         *"WL-351 v1 002")
452                 name="wl-351"
453                 ;;
454         *"WLI-TX4-AG300N")
455                 name="wli-tx4-ag300n"
456                 ;;
457         *"WMR-300")
458                 name="wmr-300"
459                 ;;
460         *"WNCE2001")
461                 name="wnce2001"
462                 ;;
463         *"WR512-3GN-like"*)
464                 name="wr512-3gn"
465                 ;;
466         *"WR6202")
467                 name="wr6202"
468                 ;;
469         *"WRH-300CR")
470                 name="wrh-300cr"
471                 ;;
472         *"WRTNODE")
473                 name="wrtnode"
474                 ;;
475         *"WRTnode2R")
476                 name="wrtnode2r"
477                 ;;
478         *"WRTnode2P")
479                 name="wrtnode2p"
480                 ;;
481         *"WSR-1166DHP")
482                 name="wsr-1166"
483                 ;;
484         *"WSR-600DHP")
485                 name="wsr-600"
486                 ;;
487         *"WT1520")
488                 name="wt1520"
489                 ;;
490         *"WT3020")
491                 name="wt3020"
492                 ;;
493         *"WZR-AGL300NH")
494                 name="wzr-agl300nh"
495                 ;;
496         *"X5")
497                 name="x5"
498                 ;;
499         *"X8")
500                 name="x8"
501                 ;;
502         *"Y1")
503                 name="y1"
504                 ;;
505         *"Y1S")
506                 name="y1s"
507                 ;;
508         *"ZBT-WA05")
509                 name="zbt-wa05"
510                 ;;
511         *"ZBT-WE826")
512                 name="zbt-we826"
513                 ;;
514         *"ZBT-WG2626")
515                 name="zbt-wg2626"
516                 ;;
517         *"ZBT-WG3526")
518                 name="zbt-wg3526"
519                 ;;
520         *"ZBT-WR8305RT")
521                 name="zbt-wr8305rt"
522                 ;;
523         *"YK1")
524                 name="youku-yk1"
525                 ;;
526         *)
527                 name="generic"
528                 ;;
529         esac
530
531         [ -z "$RAMIPS_BOARD_NAME" ] && RAMIPS_BOARD_NAME="$name"
532         [ -z "$RAMIPS_MODEL" ] && RAMIPS_MODEL="$machine"
533
534         [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
535
536         echo "$RAMIPS_BOARD_NAME" > /tmp/sysinfo/board_name
537         echo "$RAMIPS_MODEL" > /tmp/sysinfo/model
538 }
539
540 ramips_board_name() {
541         local name
542
543         [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
544         [ -z "$name" ] && name="unknown"
545
546         echo "$name"
547 }