ar71xx: remove an unused header file
[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 local model
41 model=$(ar71xx_get_mtd_offset_size_format art 56 10 %c)
42 if [ -z "$model" ] || [ "$model" = $'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' ]; then
43 machine="NETGEAR WNDR3700v2"
44 else
45 machine="NETGEAR $model"
46 fi
47 ;;
48 esac
49
50 AR71XX_BOARD_NAME="$name"
51 AR71XX_MODEL="$machine"
52 }
53
54 tplink_get_hwid() {
55 local part
56
57 part=$(find_mtd_part firmware)
58 [ -z "$part" ] && return 1
59
60 dd if=$part bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
61 }
62
63 tplink_board_detect() {
64 local model="$1"
65 local hwid
66 local hwver
67
68 hwid=$(tplink_get_hwid)
69 hwver=${hwid:6:2}
70 hwver="v${hwver#0}"
71
72 case "$hwid" in
73 "070300"*)
74 model="TP-Link TL-WR703N"
75 ;;
76 "070100"*)
77 model="TP-Link TL-WA701N/ND"
78 ;;
79 "074000"*)
80 model="TP-Link TL-WR740N/ND"
81 ;;
82 "074100"*)
83 model="TP-Link TL-WR741N/ND"
84 ;;
85 "074300"*)
86 model="TP-Link TL-WR743N/ND"
87 ;;
88 "084100"*)
89 model="TP-Link TL-WR841N/ND"
90 ;;
91 "090100"*)
92 model="TP-Link TL-WA901N/ND"
93 ;;
94 "094100"*)
95 model="TP-Link TL-WR941N/ND"
96 ;;
97 "104300"*)
98 model="TP-Link TL-WR1043N/ND"
99 ;;
100 "254300"*)
101 model="TP-Link TL-WR2543N/ND"
102 ;;
103 "302000"*)
104 model="TP-Link TL-MR3020"
105 ;;
106 "322000"*)
107 model="TP-Link TL-MR3220"
108 ;;
109 "342000"*)
110 model="TP-Link TL-MR3420"
111 ;;
112 *)
113 hwver=""
114 ;;
115 esac
116
117 AR71XX_MODEL="$model $hwver"
118 }
119
120 ar71xx_board_detect() {
121 local machine
122 local name
123
124 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
125
126 case "$machine" in
127 *"AirRouter")
128 name="airrouter"
129 ;;
130 *"ALFA Network AP96")
131 name="alfa-ap96"
132 ;;
133 *"ALFA Network N2/N5")
134 name="alfa-nx"
135 ;;
136 *ALL0258N)
137 name="all0258n"
138 ;;
139 *AP121)
140 name="ap121"
141 ;;
142 *AP121-MINI)
143 name="ap121-mini"
144 ;;
145 *AP81)
146 name="ap81"
147 ;;
148 *AP83)
149 name="ap83"
150 ;;
151 *"Atheros AP96")
152 name="ap96"
153 ;;
154 *AW-NR580)
155 name="aw-nr580"
156 ;;
157 *DB120)
158 name="db120"
159 ;;
160 *"DIR-600 rev. A1")
161 name="dir-600-a1"
162 ;;
163 *"DIR-825 rev. B1")
164 name="dir-825-b1"
165 ;;
166 *EAP7660D)
167 name="eap7660d"
168 ;;
169 *JA76PF)
170 name="ja76pf"
171 ;;
172 *"Bullet M")
173 name="bullet-m"
174 ;;
175 *"Nanostation M")
176 name="nanostation-m"
177 ;;
178 *JWAP003)
179 name="jwap003"
180 ;;
181 *"Hornet-UB")
182 name="hornet-ub"
183 ;;
184 *LS-SR71)
185 name="ls-sr71"
186 ;;
187 *MZK-W04NU)
188 name="mzk-w04nu"
189 ;;
190 *MZK-W300NH)
191 name="mzk-w300nh"
192 ;;
193 *"NBG460N/550N/550NH")
194 name="nbg460n_550n_550nh"
195 ;;
196 *OM2P)
197 name="om2p"
198 ;;
199 *PB42)
200 name="pb42"
201 ;;
202 *PB44)
203 name="pb44"
204 ;;
205 *PB92)
206 name="pb92"
207 ;;
208 *"RouterBOARD 411/A/AH")
209 name="rb-411"
210 ;;
211 *"RouterBOARD 411U")
212 name="rb-411u"
213 ;;
214 *"RouterBOARD 433/AH")
215 name="rb-433"
216 ;;
217 *"RouterBOARD 433UAH")
218 name="rb-433u"
219 ;;
220 *"RouterBOARD 450")
221 name="rb-450"
222 ;;
223 *"RouterBOARD 450G")
224 name="rb-450g"
225 ;;
226 *"RouterBOARD 493/AH")
227 name="rb-493"
228 ;;
229 *"RouterBOARD 493G")
230 name="rb-493g"
231 ;;
232 *"RouterBOARD 750")
233 name="rb-750"
234 ;;
235 *"Rocket M")
236 name="rocket-m"
237 ;;
238 *RouterStation)
239 name="routerstation"
240 ;;
241 *"RouterStation Pro")
242 name="routerstation-pro"
243 ;;
244 *RW2458N)
245 name="rw2458n"
246 ;;
247 *TEW-632BRP)
248 name="tew-632brp"
249 ;;
250 *TL-WR1043ND)
251 name="tl-wr1043nd"
252 ;;
253 *TL-WR2543N*)
254 name="tl-wr2543n"
255 ;;
256 *"DIR-615 rev. C1")
257 name="dir-615-c1"
258 ;;
259 *TL-MR3020)
260 name="tl-mr3020"
261 ;;
262 *TL-MR3220)
263 name="tl-mr3220"
264 ;;
265 *TL-MR3420)
266 name="tl-mr3420"
267 ;;
268 *TL-WA901ND)
269 name="tl-wa901nd"
270 ;;
271 *"TL-WA901ND v2")
272 name="tl-wa901nd-v2"
273 ;;
274 *TL-WR741ND)
275 name="tl-wr741nd"
276 ;;
277 *"TL-WR741ND v4")
278 name="tl-wr741nd-v4"
279 ;;
280 *"TL-WR841N v1")
281 name="tl-wr841n-v1"
282 ;;
283 *"TL-WR841N/ND v7")
284 name="tl-wr841n-v7"
285 ;;
286 *TL-WR941ND)
287 name="tl-wr941nd"
288 ;;
289 *"TL-WR703N v1")
290 name="tl-wr703n"
291 ;;
292 *UniFi)
293 name="unifi"
294 ;;
295 *WHR-G301N)
296 name="whr-g301n"
297 ;;
298 *WHR-HP-GN)
299 name="whr-hp-gn"
300 ;;
301 *WP543)
302 name="wp543"
303 ;;
304 *"WNDR3700/WNDR3800/WNDRMAC")
305 wndr3700_board_detect "$machine"
306 ;;
307 *WNR2000)
308 name="wnr2000"
309 ;;
310 *WRT160NL)
311 name="wrt160nl"
312 ;;
313 *WRT400N)
314 name="wrt400n"
315 ;;
316 *WZR-HP-AG300H)
317 name="wzr-hp-ag300h"
318 ;;
319 *WZR-HP-G300NH)
320 name="wzr-hp-g300nh"
321 ;;
322 *WZR-HP-G450H)
323 name="wzr-hp-g450h"
324 ;;
325 *WZR-HP-G300NH2)
326 name="wzr-hp-g300nh2"
327 ;;
328 *WHR-HP-G300N)
329 name="whr-hp-g300n"
330 ;;
331 *ZCN-1523H-2)
332 name="zcn-1523h-2"
333 ;;
334 *ZCN-1523H-5)
335 name="zcn-1523h-5"
336 ;;
337 esac
338
339 case "$machine" in
340 *TL-WR* | *TL-WA* | *TL-MR*)
341 tplink_board_detect "$machine"
342 ;;
343 esac
344
345 [ -z "$name" ] && name="unknown"
346
347 [ -z "$AR71XX_BOARD_NAME" ] && AR71XX_BOARD_NAME="$name"
348 [ -z "$AR71XX_MODEL" ] && AR71XX_MODEL="$machine"
349
350 [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
351
352 echo "$AR71XX_BOARD_NAME" > /tmp/sysinfo/board_name
353 echo "$AR71XX_MODEL" > /tmp/sysinfo/model
354 }
355
356 ar71xx_board_name() {
357 local name
358
359 [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
360 [ -z "$name" ] && name="unknown"
361
362 echo "$name"
363 }
This page took 0.063633 seconds and 5 git commands to generate.