cd210013248d1ef63dc9463ea588bd64fb670866
[openwrt/staging/wigyori.git] / target / linux / ramips / base-files / lib / upgrade / platform.sh
1 #
2 # Copyright (C) 2010 OpenWrt.org
3 #
4
5 PART_NAME=firmware
6
7 platform_check_image() {
8 local board=$(board_name)
9 local magic="$(get_magic_long "$1")"
10
11 [ "$#" -gt 1 ] && return 1
12
13 case "$board" in
14 3g150b|\
15 3g300m|\
16 a5-v11|\
17 ai-br100|\
18 air3gii|\
19 alfa-network,ac1200rm|\
20 all0239-3g|\
21 all0256n-4M|\
22 all0256n-8M|\
23 all5002|\
24 all5003|\
25 ar725w|\
26 asl26555-8M|\
27 asl26555-16M|\
28 awapn2403|\
29 awm002-evb-4M|\
30 awm002-evb-8M|\
31 bc2|\
32 broadway|\
33 c108|\
34 carambola|\
35 cf-wr800n|\
36 cs-qr10|\
37 d105|\
38 d240|\
39 dap-1350|\
40 db-wrt01|\
41 dcs-930|\
42 dcs-930l-b1|\
43 dir-300-b1|\
44 dir-300-b7|\
45 dir-320-b1|\
46 dir-600-b1|\
47 dir-615-d|\
48 dir-615-h1|\
49 dir-620-a1|\
50 dir-620-d1|\
51 dir-810l|\
52 duzun-dm06|\
53 dwr-512-b|\
54 e1700|\
55 esr-9753|\
56 ew1200|\
57 ex2700|\
58 ex3700|\
59 f7c027|\
60 firewrt|\
61 fonera20n|\
62 freestation5|\
63 gb-pc1|\
64 gl-mt300a|\
65 gl-mt300n|\
66 gl-mt750|\
67 gl-mt300n-v2|\
68 hc5*61|\
69 hc5661a|\
70 hg255d|\
71 hlk-rm04|\
72 hpm|\
73 ht-tm02|\
74 hw550-3g|\
75 ip2202|\
76 jhr-n805r|\
77 jhr-n825r|\
78 jhr-n926r|\
79 k2p|\
80 kn|\
81 kn_rc|\
82 kn_rf|\
83 kng_rc|\
84 linkits7688|\
85 m2m|\
86 m3|\
87 m4-4M|\
88 m4-8M|\
89 mac1200rv2|\
90 microwrt|\
91 miniembplug|\
92 miniembwifi|\
93 miwifi-mini|\
94 miwifi-nano|\
95 mlw221|\
96 mlwg2|\
97 mofi3500-3gn|\
98 mpr-a1|\
99 mpr-a2|\
100 mr-102n|\
101 mt7628|\
102 mzk-750dhp|\
103 mzk-dp150n|\
104 mzk-ex300np|\
105 mzk-ex750np|\
106 mzk-w300nh2|\
107 mzk-wdpr|\
108 nbg-419n|\
109 nbg-419n2|\
110 newifi-d1|\
111 d-team,newifi-d2|\
112 nixcore-x1-8M|\
113 nixcore-x1-16M|\
114 nw718|\
115 omega2|\
116 omega2p|\
117 oy-0001|\
118 pbr-d1|\
119 pbr-m1|\
120 psg1208|\
121 psg1218a|\
122 psg1218b|\
123 psr-680w|\
124 px-4885-4M|\
125 px-4885-8M|\
126 rb750gr3|\
127 re6500|\
128 rp-n53|\
129 rt5350f-olinuxino|\
130 rt5350f-olinuxino-evb|\
131 rt-ac51u|\
132 rt-g32-b1|\
133 rt-n10-plus|\
134 rt-n12p|\
135 rt-n13u|\
136 rt-n14u|\
137 rt-n15|\
138 rt-n56u|\
139 rut5xx|\
140 sap-g3200u3|\
141 sk-wb8|\
142 sl-r7205|\
143 tew-638apb-v2|\
144 tew-691gr|\
145 tew-692gr|\
146 tew-714tru|\
147 timecloud|\
148 tiny-ac|\
149 u25awf-h1|\
150 u7621-06-256M-16M|\
151 u7628-01-128M-16M|\
152 ur-326n4g|\
153 ur-336un|\
154 v22rw-2x2|\
155 vonets,var11n-300|\
156 vocore-8M|\
157 vocore-16M|\
158 vocore2|\
159 vocore2lite|\
160 vr500|\
161 w150m|\
162 w2914nsv2|\
163 w306r-v20|\
164 w502u|\
165 wf-2881|\
166 whr-1166d|\
167 whr-300hp2|\
168 whr-600d|\
169 whr-g300n|\
170 widora-neo|\
171 witi|\
172 wizfi630a|\
173 wl-330n|\
174 wl-330n3g|\
175 wl-341v3|\
176 wl-351|\
177 wl-wn575a3|\
178 wli-tx4-ag300n|\
179 wlr-6000|\
180 wmdr-143n|\
181 wmr-300|\
182 wn3000rpv3|\
183 wnce2001|\
184 wndr3700v5|\
185 wr512-3gn-4M|\
186 wr512-3gn-8M|\
187 wr6202|\
188 wrh-300cr|\
189 wrtnode|\
190 wrtnode2r |\
191 wrtnode2p |\
192 wsr-600|\
193 wt1520-4M|\
194 wt1520-8M|\
195 wt3020-4M|\
196 wt3020-8M|\
197 wzr-agl300nh|\
198 x5|\
199 x8|\
200 y1|\
201 y1s|\
202 we1026-5g-16m|\
203 zbt-ape522ii|\
204 zbt-cpe102|\
205 zbt-wa05|\
206 zbt-we1326|\
207 zbt-we2026|\
208 zbtlink,zbt-we3526|\
209 zbt-we826-16M|\
210 zbt-we826-32M|\
211 zbt-wg2626|\
212 zbt-wg3526-16M|\
213 zbt-wg3526-32M|\
214 zbt-wr8305rt|\
215 zte-q7|\
216 youku-yk1)
217 [ "$magic" != "27051956" ] && {
218 echo "Invalid image type."
219 return 1
220 }
221 return 0
222 ;;
223 3g-6200n|\
224 3g-6200nl|\
225 br-6475nd)
226 [ "$magic" != "43535953" ] && {
227 echo "Invalid image type."
228 return 1
229 }
230 return 0
231 ;;
232
233 ar670w)
234 [ "$magic" != "6d000080" ] && {
235 echo "Invalid image type."
236 return 1
237 }
238 return 0
239 ;;
240 c20|\
241 c20i|\
242 c50|\
243 mr200|\
244 tplink,tl-mr3420-v5|\
245 tl-wr840n-v4|\
246 tl-wr840n-v5|\
247 tl-wr841n-v13)
248 [ "$magic" != "03000000" ] && {
249 echo "Invalid image type."
250 return 1
251 }
252 return 0
253 ;;
254 cy-swr1100|\
255 dch-m225|\
256 dir-610-a1|\
257 dir-645|\
258 dir-860l-b1)
259 [ "$magic" != "5ea3a417" ] && {
260 echo "Invalid image type."
261 return 1
262 }
263 return 0
264 ;;
265 hc5962|\
266 mir3g|\
267 r6220)
268 # these boards use metadata images
269 return 0
270 ;;
271 re350-v1)
272 [ "$magic" != "01000000" ] && {
273 echo "Invalid image type."
274 return 1
275 }
276 return 0
277 ;;
278 ubnt-erx|\
279 ubnt-erx-sfp)
280 nand_do_platform_check "$board" "$1"
281 return $?;
282 ;;
283 wcr-1166ds|\
284 wsr-1166)
285 [ "$magic" != "48445230" ] && {
286 echo "Invalid image type."
287 return 1
288 }
289 return 0
290 ;;
291 esac
292
293 echo "Sysupgrade is not yet supported on $board."
294 return 1
295 }
296
297 platform_nand_pre_upgrade() {
298 local board=$(board_name)
299
300 case "$board" in
301 ubnt-erx|\
302 ubnt-erx-sfp)
303 platform_upgrade_ubnt_erx "$ARGV"
304 ;;
305 esac
306 }
307
308 platform_do_upgrade() {
309 local board=$(board_name)
310
311 case "$board" in
312 hc5962|\
313 mir3g|\
314 r6220|\
315 ubnt-erx|\
316 ubnt-erx-sfp)
317 nand_do_upgrade "$ARGV"
318 ;;
319 *)
320 default_do_upgrade "$ARGV"
321 ;;
322 esac
323 }
324
325 disable_watchdog() {
326 killall watchdog
327 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
328 echo 'Could not disable watchdog'
329 return 1
330 }
331 }
332
333 blink_led() {
334 . /etc/diag.sh; set_state upgrade
335 }
336
337 append sysupgrade_pre_upgrade disable_watchdog
338 append sysupgrade_pre_upgrade blink_led