5f2c4a043a69d4999741a15cd14f460984b3fbe8
[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 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 m2m|\
85 m3|\
86 m4-4M|\
87 m4-8M|\
88 mac1200rv2|\
89 microwrt|\
90 miniembplug|\
91 miniembwifi|\
92 miwifi-mini|\
93 miwifi-nano|\
94 mlw221|\
95 mlwg2|\
96 mofi3500-3gn|\
97 mpr-a1|\
98 mpr-a2|\
99 mr-102n|\
100 mt7628|\
101 mzk-750dhp|\
102 mzk-dp150n|\
103 mzk-ex300np|\
104 mzk-ex750np|\
105 mzk-w300nh2|\
106 mzk-wdpr|\
107 nbg-419n|\
108 nbg-419n2|\
109 newifi-d1|\
110 nixcore-x1-8M|\
111 nixcore-x1-16M|\
112 nw718|\
113 omega2|\
114 omega2p|\
115 oy-0001|\
116 pbr-d1|\
117 pbr-m1|\
118 psg1208|\
119 psg1218a|\
120 psg1218b|\
121 psr-680w|\
122 px-4885-4M|\
123 px-4885-8M|\
124 rb750gr3|\
125 re6500|\
126 rp-n53|\
127 rt5350f-olinuxino|\
128 rt5350f-olinuxino-evb|\
129 rt-ac51u|\
130 rt-g32-b1|\
131 rt-n10-plus|\
132 rt-n12p|\
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 u25awf-h1|\
148 u7621-06-256M-16M|\
149 u7628-01-128M-16M|\
150 ur-326n4g|\
151 ur-336un|\
152 v22rw-2x2|\
153 vocore-8M|\
154 vocore-16M|\
155 vocore2|\
156 vocore2lite|\
157 vr500|\
158 w150m|\
159 w2914nsv2|\
160 w306r-v20|\
161 w502u|\
162 wf-2881|\
163 whr-1166d|\
164 whr-300hp2|\
165 whr-600d|\
166 whr-g300n|\
167 widora-neo|\
168 witi|\
169 wizfi630a|\
170 wl-330n|\
171 wl-330n3g|\
172 wl-341v3|\
173 wl-351|\
174 wl-wn575a3|\
175 wli-tx4-ag300n|\
176 wlr-6000|\
177 wmdr-143n|\
178 wmr-300|\
179 wn3000rpv3|\
180 wnce2001|\
181 wndr3700v5|\
182 wr512-3gn-4M|\
183 wr512-3gn-8M|\
184 wr6202|\
185 wrh-300cr|\
186 wrtnode|\
187 wrtnode2r |\
188 wrtnode2p |\
189 wsr-600|\
190 wt1520-4M|\
191 wt1520-8M|\
192 wt3020-4M|\
193 wt3020-8M|\
194 wzr-agl300nh|\
195 x5|\
196 x8|\
197 y1|\
198 y1s|\
199 we1026-5g-16m|\
200 zbt-ape522ii|\
201 zbt-cpe102|\
202 zbt-wa05|\
203 zbt-we1326|\
204 zbt-we2026|\
205 zbtlink,zbt-we3526|\
206 zbt-we826-16M|\
207 zbt-we826-32M|\
208 zbt-wg2626|\
209 zbt-wg3526-16M|\
210 zbt-wg3526-32M|\
211 zbt-wr8305rt|\
212 zte-q7|\
213 youku-yk1)
214 [ "$magic" != "27051956" ] && {
215 echo "Invalid image type."
216 return 1
217 }
218 return 0
219 ;;
220 3g-6200n|\
221 3g-6200nl|\
222 br-6475nd)
223 [ "$magic" != "43535953" ] && {
224 echo "Invalid image type."
225 return 1
226 }
227 return 0
228 ;;
229
230 ar670w)
231 [ "$magic" != "6d000080" ] && {
232 echo "Invalid image type."
233 return 1
234 }
235 return 0
236 ;;
237 c20|\
238 c20i|\
239 c50|\
240 mr200|\
241 tl-wr840n-v4|\
242 tl-wr840n-v5|\
243 tl-wr841n-v13)
244 [ "$magic" != "03000000" ] && {
245 echo "Invalid image type."
246 return 1
247 }
248 return 0
249 ;;
250 cy-swr1100|\
251 dch-m225|\
252 dir-610-a1|\
253 dir-645|\
254 dir-860l-b1)
255 [ "$magic" != "5ea3a417" ] && {
256 echo "Invalid image type."
257 return 1
258 }
259 return 0
260 ;;
261 hc5962|\
262 mir3g|\
263 r6220)
264 # these boards use metadata images
265 return 0
266 ;;
267 re350-v1)
268 [ "$magic" != "01000000" ] && {
269 echo "Invalid image type."
270 return 1
271 }
272 return 0
273 ;;
274 ubnt-erx|\
275 ubnt-erx-sfp)
276 nand_do_platform_check "$board" "$1"
277 return $?;
278 ;;
279 wcr-1166ds|\
280 wsr-1166)
281 [ "$magic" != "48445230" ] && {
282 echo "Invalid image type."
283 return 1
284 }
285 return 0
286 ;;
287 esac
288
289 echo "Sysupgrade is not yet supported on $board."
290 return 1
291 }
292
293 platform_nand_pre_upgrade() {
294 local board=$(board_name)
295
296 case "$board" in
297 ubnt-erx|\
298 ubnt-erx-sfp)
299 platform_upgrade_ubnt_erx "$ARGV"
300 ;;
301 esac
302 }
303
304 platform_do_upgrade() {
305 local board=$(board_name)
306
307 case "$board" in
308 hc5962|\
309 mir3g|\
310 r6220|\
311 ubnt-erx|\
312 ubnt-erx-sfp)
313 nand_do_upgrade "$ARGV"
314 ;;
315 *)
316 default_do_upgrade "$ARGV"
317 ;;
318 esac
319 }
320
321 disable_watchdog() {
322 killall watchdog
323 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
324 echo 'Could not disable watchdog'
325 return 1
326 }
327 }
328
329 blink_led() {
330 . /etc/diag.sh; set_state upgrade
331 }
332
333 append sysupgrade_pre_upgrade disable_watchdog
334 append sysupgrade_pre_upgrade blink_led