b90a591ded19b4b5c868d93c60ca150ec98bf379
[openwrt/openwrt.git] / target / linux / ramips / base-files / lib / upgrade / platform.sh
1 #
2 # Copyright (C) 2010 OpenWrt.org
3 #
4
5 . /lib/ramips.sh
6
7 PART_NAME=firmware
8 RAMFS_COPY_DATA=/lib/ramips.sh
9
10 platform_check_image() {
11 local board=$(ramips_board_name)
12 local magic="$(get_magic_long "$1")"
13
14 [ "$#" -gt 1 ] && return 1
15
16 case "$board" in
17 3g150b|\
18 3g300m|\
19 3g-6200n|\
20 3g-6200nl|\
21 a5-v11|\
22 ai-br100|\
23 air3gii|\
24 all0239-3g|\
25 all0256n|\
26 all5002|\
27 all5003|\
28 ar725w|\
29 asl26555|\
30 awapn2403|\
31 awm002-evb|\
32 awm003-evb|\
33 bc2|\
34 broadway|\
35 carambola|\
36 cf-wr800n|\
37 cs-qr10|\
38 d105|\
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-600-b2|\
48 dir-615-d|\
49 dir-615-h1|\
50 dir-620-a1|\
51 dir-620-d1|\
52 dir-810l|\
53 duzun-dm06|\
54 e1700|\
55 esr-9753|\
56 ex2700|\
57 f7c027|\
58 firewrt|\
59 fonera20n|\
60 freestation5|\
61 gl-mt300a|\
62 gl-mt300n|\
63 gl-mt750|\
64 hc5*61|\
65 hg255d|\
66 hlk-rm04|\
67 hpm|\
68 ht-tm02|\
69 hw550-3g|\
70 ip2202|\
71 jhr-n805r|\
72 jhr-n825r|\
73 jhr-n926r|\
74 linkits7688|\
75 linkits7688d|\
76 m2m|\
77 m3|\
78 m4|\
79 mac1200rv2|\
80 microwrt|\
81 miniembplug|\
82 miniembwifi|\
83 miwifi-mini|\
84 miwifi-nano|\
85 mlw221|\
86 mlwg2|\
87 mofi3500-3gn|\
88 mpr-a1|\
89 mpr-a2|\
90 mr-102n|\
91 mt7628|\
92 mzk-750dhp|\
93 mzk-dp150n|\
94 mzk-ex300np|\
95 mzk-ex750np|\
96 mzk-w300nh2|\
97 mzk-wdpr|\
98 nbg-419n|\
99 nbg-419n2|\
100 newifi-d1|\
101 nixcore|\
102 nw718|\
103 oy-0001|\
104 pbr-d1|\
105 pbr-m1|\
106 psg1208|\
107 psg1218|\
108 psr-680w|\
109 px-4885|\
110 re6500|\
111 rp-n53|\
112 rt5350f-olinuxino|\
113 rt5350f-olinuxino-evb|\
114 rt-g32-b1|\
115 rt-n10-plus|\
116 rt-n13u|\
117 rt-n14u|\
118 rt-n15|\
119 rt-n56u|\
120 rut5xx|\
121 sap-g3200u3|\
122 sk-wb8|\
123 sl-r7205|\
124 tew-691gr|\
125 tew-692gr|\
126 tew-714tru|\
127 timecloud|\
128 tiny-ac|\
129 ur-326n4g|\
130 ur-336un|\
131 v22rw-2x2|\
132 vocore|\
133 w150m|\
134 w306r-v20|\
135 w502u|\
136 wf-2881|\
137 whr-1166d|\
138 whr-300hp2|\
139 whr-600d|\
140 whr-g300n|\
141 widora-neo|\
142 witi|\
143 wizfi630a|\
144 wl-330n|\
145 wl-330n3g|\
146 wl-341v3|\
147 wl-351|\
148 wli-tx4-ag300n|\
149 wmr-300|\
150 wnce2001|\
151 wndr3700v5|\
152 wr512-3gn|\
153 wr6202|\
154 wrh-300cr|\
155 wrtnode|\
156 wrtnode2r |\
157 wrtnode2p |\
158 wsr-600|\
159 wt1520|\
160 wt3020|\
161 wzr-agl300nh|\
162 x5|\
163 x8|\
164 y1|\
165 y1s|\
166 zbt-ape522ii|\
167 zbt-cpe102|\
168 zbt-wa05|\
169 zbt-we826|\
170 zbt-wg2626|\
171 zbt-wg3526|\
172 zbt-wr8305rt|\
173 zte-q7|\
174 youku-yk1)
175 [ "$magic" != "27051956" ] && {
176 echo "Invalid image type."
177 return 1
178 }
179 return 0
180 ;;
181 ar670w)
182 [ "$magic" != "6d000080" ] && {
183 echo "Invalid image type."
184 return 1
185 }
186 return 0
187 ;;
188 br-6475nd)
189 [ "$magic" != "43535953" ] && {
190 echo "Invalid image type."
191 return 1
192 }
193 return 0
194 ;;
195 c20i|\
196 c50)
197 [ "$magic" != "03000000" ] && {
198 echo "Invalid image type."
199 return 1
200 }
201 return 0
202 ;;
203 cy-swr1100|\
204 dch-m225|\
205 dir-610-a1|\
206 dir-645|\
207 dir-860l-b1)
208 [ "$magic" != "5ea3a417" ] && {
209 echo "Invalid image type."
210 return 1
211 }
212 return 0
213 ;;
214 wsr-1166)
215 [ "$magic" != "48445230" ] && {
216 echo "Invalid image type."
217 return 1
218 }
219 return 0
220 ;;
221 ubnt-erx)
222 nand_do_platform_check "$board" "$1"
223 return $?;
224 ;;
225 esac
226
227 echo "Sysupgrade is not yet supported on $board."
228 return 1
229 }
230
231 platform_nand_pre_upgrade() {
232 local board=$(ramips_board_name)
233
234 case "$board" in
235 ubnt-erx)
236 platform_upgrade_ubnt_erx "$ARGV"
237 ;;
238 esac
239 }
240
241 platform_pre_upgrade() {
242 local board=$(ramips_board_name)
243
244 case "$board" in
245 ubnt-erx)
246 nand_do_upgrade "$ARGV"
247 ;;
248 esac
249 }
250
251 platform_do_upgrade() {
252 local board=$(ramips_board_name)
253
254 case "$board" in
255 *)
256 default_do_upgrade "$ARGV"
257 ;;
258 esac
259 }
260
261 disable_watchdog() {
262 killall watchdog
263 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
264 echo 'Could not disable watchdog'
265 return 1
266 }
267 }
268
269 blink_led() {
270 . /etc/diag.sh; set_state upgrade
271 }
272
273 append sysupgrade_pre_upgrade disable_watchdog
274 append sysupgrade_pre_upgrade blink_led