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