b07f4e94666bdfdfb80033c04d6e217a15018517
[openwrt/svn-archive/archive.git] / target / linux / ramips / base-files / lib / ramips.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010 OpenWrt.org
4 #
5
6 ramips_get_mac_binary()
7 {
8 local mtdname="$1"
9 local seek="$2"
10 local part
11
12 . /lib/functions.sh
13
14 part=$(find_mtd_part "$mtdname")
15 if [ -z "$part" ]; then
16 echo "ramips_get_mac_binary: partition $mtdname not found!" >&2
17 return
18 fi
19
20 dd bs=1 skip=$seek count=6 if=$part 2>/dev/null | /usr/sbin/maccalc bin2mac
21 }
22
23 ramips_get_mac_nvram()
24 {
25 local mtdname="$1"
26 local key="$2"
27 local part
28 local mac_dirty
29
30 . /lib/functions.sh
31
32 part=$(find_mtd_part "$mtdname")
33 if [ -z "$part" ]; then
34 echo "ramips_get_mac_nvram: partition $mtdname not found!" >&2
35 return
36 fi
37
38 mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p')
39 # "canonicalize" mac
40 /usr/sbin/maccalc add "$mac_dirty" 0
41 }
42
43 ramips_board_name() {
44 local machine
45 local name
46
47 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
48
49 case "$machine" in
50 *"Edimax 3g-6200n")
51 name="3g-6200n"
52 ;;
53 *"Allnet ALL0239-3G")
54 name="all0239-3g"
55 ;;
56 *"Allnet ALL0256N")
57 name="all0256n"
58 ;;
59 *"Allnet ALL5002")
60 name="all5002"
61 ;;
62 *"ARC FreeStation5")
63 name="freestation5"
64 ;;
65 *"Argus ATP-52B")
66 name="argus-atp52b"
67 ;;
68 *"Asus WL-330N")
69 name="wl-330n"
70 ;;
71 *"Asus WL-330N3G")
72 name="wl-330n3g"
73 ;;
74 *"Aztech HW550-3G")
75 name="hw550-3g"
76 ;;
77 *"DIR-300 B1")
78 name="dir-300-b1"
79 ;;
80 *"DIR-600 B1")
81 name="dir-600-b1"
82 ;;
83 *"DIR-600 B2")
84 name="dir-600-b2"
85 ;;
86 *"DIR-620 A1")
87 name="dir-620-a1"
88 ;;
89 *"DIR-615 H1")
90 name="dir-615-h1"
91 ;;
92 *"DAP-1350")
93 name="dap-1350"
94 ;;
95 *"ESR-9753")
96 name="esr-9753"
97 ;;
98 *"F5D8235 v1")
99 name="f5d8235-v1"
100 ;;
101 *"F5D8235 v2")
102 name="f5d8235-v2"
103 ;;
104 *"La Fonera 2.0N")
105 name="fonera20n"
106 ;;
107 *"MoFi Network MOFI3500-3GN")
108 name="mofi3500-3gn"
109 ;;
110 *"NBG-419N")
111 name="nbg-419n"
112 ;;
113 *"NexAira BC2")
114 name="bc2"
115 ;;
116 *"NW718")
117 name="nw718"
118 ;;
119 *"Omnima MiniEMBWiFi")
120 name="omni-emb"
121 ;;
122 *"Petatel PSR-680W"*)
123 name="psr-680w"
124 ;;
125 *"PWH2004")
126 name="pwh2004"
127 ;;
128 *"RT-G32 B1")
129 name="rt-g32-b1"
130 ;;
131 *"RT-N10+")
132 name="rt-n10-plus"
133 ;;
134 *"RT-N15")
135 name="rt-n15"
136 ;;
137 *"RT-N56U")
138 name="rt-n56u"
139 ;;
140 *"Skyline SL-R7205"*)
141 name="sl-r7205"
142 ;;
143 *"Sparklan WCR-150GN")
144 name="wcr-150gn"
145 ;;
146 *"V22RW-2X2")
147 name="v22rw-2x2"
148 ;;
149 *"W502U")
150 name="w502u"
151 ;;
152 *"WHR-G300N")
153 name="whr-g300n"
154 ;;
155 *"Sitecom WL-341 v3")
156 name="wl341v3"
157 ;;
158 *"Sitecom WL-351 v1 002")
159 name="wl-351"
160 ;;
161 *"Tenda W306R V2.0")
162 name="w306r-v20"
163 ;;
164 *"Ralink V11ST-FE")
165 name="v11st-fe"
166 ;;
167 *"WLI-TX4-AG300N")
168 name="wli-tx4-ag300n"
169 ;;
170 *"WZR-AGL300NH")
171 name="wzr-agl300nh"
172 ;;
173 *"WR512-3GN-like router")
174 name="wr512-3gn"
175 ;;
176 *"UR-336UN Wireless N router")
177 name="ur-336un"
178 ;;
179 *"AWB WR6202")
180 name="wr6202"
181 ;;
182 *"XDX RN502J")
183 name="xdxrn502j"
184 ;;
185 *)
186 name="generic"
187 ;;
188 esac
189
190 echo $name
191 }