0b3d8c74066a54ad8f3a448f89463218213efaca
[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 microwrt|\
80 miniembplug|\
81 miniembwifi|\
82 miwifi-mini|\
83 miwifi-nano|\
84 mlw221|\
85 mlwg2|\
86 mofi3500-3gn|\
87 mpr-a1|\
88 mpr-a2|\
89 mr-102n|\
90 mt7628|\
91 mzk-750dhp|\
92 mzk-dp150n|\
93 mzk-ex300np|\
94 mzk-ex750np|\
95 mzk-w300nh2|\
96 mzk-wdpr|\
97 nbg-419n|\
98 nw718|\
99 oy-0001|\
100 pbr-m1|\
101 psg1208|\
102 psr-680w|\
103 px-4885|\
104 re6500|\
105 rp-n53|\
106 rt5350f-olinuxino|\
107 rt5350f-olinuxino-evb|\
108 rt-g32-b1|\
109 rt-n10-plus|\
110 rt-n13u|\
111 rt-n14u|\
112 rt-n15|\
113 rt-n56u|\
114 rut5xx|\
115 sap-g3200u3|\
116 sk-wb8|\
117 sl-r7205|\
118 tew-691gr|\
119 tew-692gr|\
120 tiny-ac|\
121 ur-326n4g|\
122 ur-336un|\
123 v22rw-2x2|\
124 vocore|\
125 w150m|\
126 w306r-v20|\
127 w502u|\
128 wf-2881|\
129 whr-1166d|\
130 whr-300hp2|\
131 whr-600d|\
132 whr-g300n|\
133 widora-neo|\
134 witi|\
135 wizfi630a|\
136 wl-330n|\
137 wl-330n3g|\
138 wl-341v3|\
139 wl-351|\
140 wli-tx4-ag300n|\
141 wmr-300|\
142 wnce2001|\
143 wndr3700v5|\
144 wr512-3gn|\
145 wr6202|\
146 wrh-300cr|\
147 wrtnode|\
148 wrtnode2r |\
149 wrtnode2p |\
150 wsr-600|\
151 wt1520|\
152 wt3020|\
153 wzr-agl300nh|\
154 x5|\
155 x8|\
156 y1|\
157 y1s|\
158 zbt-wa05|\
159 zbt-we826|\
160 zbt-wg2626|\
161 zbt-wg3526|\
162 zbt-wr8305rt|\
163 zte-q7|\
164 youku-yk1)
165 [ "$magic" != "27051956" ] && {
166 echo "Invalid image type."
167 return 1
168 }
169 return 0
170 ;;
171 ar670w)
172 [ "$magic" != "6d000080" ] && {
173 echo "Invalid image type."
174 return 1
175 }
176 return 0
177 ;;
178 br-6475nd)
179 [ "$magic" != "43535953" ] && {
180 echo "Invalid image type."
181 return 1
182 }
183 return 0
184 ;;
185 c20i|\
186 c50)
187 [ "$magic" != "03000000" ] && {
188 echo "Invalid image type."
189 return 1
190 }
191 return 0
192 ;;
193 cy-swr1100|\
194 dir-610-a1|\
195 dir-645|\
196 dir-860l-b1)
197 [ "$magic" != "5ea3a417" ] && {
198 echo "Invalid image type."
199 return 1
200 }
201 return 0
202 ;;
203 wsr-1166)
204 [ "$magic" != "48445230" ] && {
205 echo "Invalid image type."
206 return 1
207 }
208 return 0
209 ;;
210 ubnt-erx)
211 nand_do_platform_check "$board" "$1"
212 return $?;
213 ;;
214 esac
215
216 echo "Sysupgrade is not yet supported on $board."
217 return 1
218 }
219
220 platform_nand_pre_upgrade() {
221 local board=$(ramips_board_name)
222
223 case "$board" in
224 ubnt-erx)
225 platform_upgrade_ubnt_erx "$ARGV"
226 ;;
227 esac
228 }
229
230 platform_pre_upgrade() {
231 local board=$(ramips_board_name)
232
233 case "$board" in
234 ubnt-erx)
235 nand_do_upgrade "$ARGV"
236 ;;
237 esac
238 }
239
240 platform_do_upgrade() {
241 local board=$(ramips_board_name)
242
243 case "$board" in
244 *)
245 default_do_upgrade "$ARGV"
246 ;;
247 esac
248 }
249
250 disable_watchdog() {
251 killall watchdog
252 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
253 echo 'Could not disable watchdog'
254 return 1
255 }
256 }
257
258 blink_led() {
259 . /etc/diag.sh; set_state upgrade
260 }
261
262 append sysupgrade_pre_upgrade disable_watchdog
263 append sysupgrade_pre_upgrade blink_led