45e141de02be257807007810f7f31f9ebafceb93
[openwrt/openwrt.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-16m|\
171 widora,neo-32m|\
172 witi|\
173 wizfi630a|\
174 wl-330n|\
175 wl-330n3g|\
176 wl-341v3|\
177 wl-351|\
178 wl-wn575a3|\
179 wli-tx4-ag300n|\
180 wlr-6000|\
181 wmdr-143n|\
182 wmr-300|\
183 wn3000rpv3|\
184 wnce2001|\
185 wndr3700v5|\
186 wr512-3gn-4M|\
187 wr512-3gn-8M|\
188 wr6202|\
189 wrh-300cr|\
190 wrtnode|\
191 wrtnode2r |\
192 wrtnode2p |\
193 wsr-600|\
194 wt1520-4M|\
195 wt1520-8M|\
196 wt3020-4M|\
197 wt3020-8M|\
198 wzr-agl300nh|\
199 x5|\
200 x8|\
201 y1|\
202 y1s|\
203 we1026-5g-16m|\
204 zbt-ape522ii|\
205 zbt-cpe102|\
206 zbt-wa05|\
207 zbtlink,zbt-we1226|\
208 zbt-we1326|\
209 zbt-we2026|\
210 zbtlink,zbt-we3526|\
211 zbt-we826-16M|\
212 zbt-we826-32M|\
213 zbt-wg2626|\
214 zbt-wg3526-16M|\
215 zbt-wg3526-32M|\
216 zbt-wr8305rt|\
217 zte-q7|\
218 youku-yk1)
219 [ "$magic" != "27051956" ] && {
220 echo "Invalid image type."
221 return 1
222 }
223 return 0
224 ;;
225 3g-6200n|\
226 3g-6200nl|\
227 br-6475nd)
228 [ "$magic" != "43535953" ] && {
229 echo "Invalid image type."
230 return 1
231 }
232 return 0
233 ;;
234
235 ar670w)
236 [ "$magic" != "6d000080" ] && {
237 echo "Invalid image type."
238 return 1
239 }
240 return 0
241 ;;
242 c20i|\
243 c50|\
244 mr200|\
245 tplink,c20-v1|\
246 tplink,c20-v4|\
247 tplink,c50-v3|\
248 tplink,tl-mr3420-v5|\
249 tl-wr840n-v4|\
250 tl-wr840n-v5|\
251 tl-wr841n-v13)
252 [ "$magic" != "03000000" ] && {
253 echo "Invalid image type."
254 return 1
255 }
256 return 0
257 ;;
258 cy-swr1100|\
259 dch-m225|\
260 dir-610-a1|\
261 dir-645|\
262 dir-860l-b1)
263 [ "$magic" != "5ea3a417" ] && {
264 echo "Invalid image type."
265 return 1
266 }
267 return 0
268 ;;
269 hc5962|\
270 mir3g|\
271 r6220|\
272 ubnt-erx|\
273 ubnt-erx-sfp)
274 nand_do_platform_check "$board" "$1"
275 return $?;
276 ;;
277 re350-v1)
278 [ "$magic" != "01000000" ] && {
279 echo "Invalid image type."
280 return 1
281 }
282 return 0
283 ;;
284 wcr-1166ds|\
285 wsr-1166)
286 [ "$magic" != "48445230" ] && {
287 echo "Invalid image type."
288 return 1
289 }
290 return 0
291 ;;
292 esac
293
294 echo "Sysupgrade is not yet supported on $board."
295 return 1
296 }
297
298 platform_nand_pre_upgrade() {
299 local board=$(board_name)
300
301 case "$board" in
302 ubnt-erx|\
303 ubnt-erx-sfp)
304 platform_upgrade_ubnt_erx "$ARGV"
305 ;;
306 esac
307 }
308
309 platform_do_upgrade() {
310 local board=$(board_name)
311
312 case "$board" in
313 hc5962|\
314 mir3g|\
315 r6220|\
316 ubnt-erx|\
317 ubnt-erx-sfp)
318 nand_do_upgrade "$ARGV"
319 ;;
320 *)
321 default_do_upgrade "$ARGV"
322 ;;
323 esac
324 }
325
326 disable_watchdog() {
327 killall watchdog
328 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
329 echo 'Could not disable watchdog'
330 return 1
331 }
332 }
333
334 blink_led() {
335 . /etc/diag.sh; set_state upgrade
336 }
337
338 append sysupgrade_pre_upgrade disable_watchdog
339 append sysupgrade_pre_upgrade blink_led