ramips: Add support for GL-MT300N
[openwrt/svn-archive/archive.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 d105|\
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-600-b2|\
47 dir-615-d|\
48 dir-615-h1|\
49 dir-620-a1|\
50 dir-620-d1|\
51 dir-810l|\
52 e1700|\
53 esr-9753|\
54 ex2700|\
55 f7c027|\
56 firewrt|\
57 fonera20n|\
58 freestation5|\
59 gl-mt300a|\
60 gl-mt300n|\
61 hc5*61|\
62 hg255d|\
63 hlk-rm04|\
64 hpm|\
65 ht-tm02|\
66 hw550-3g|\
67 ip2202|\
68 jhr-n805r|\
69 jhr-n825r|\
70 jhr-n926r|\
71 linkits7688|\
72 linkits7688d|\
73 m2m|\
74 m3|\
75 m4|\
76 microwrt|\
77 miniembplug|\
78 miniembwifi|\
79 miwifi-mini|\
80 mlw221|\
81 mlwg2|\
82 mofi3500-3gn|\
83 mpr-a1|\
84 mpr-a2|\
85 mr-102n|\
86 mt7628|\
87 mzk-dp150n|\
88 mzk-w300nh2|\
89 mzk-wdpr|\
90 nbg-419n|\
91 nw718|\
92 oy-0001|\
93 pbr-m1|\
94 psg1208|\
95 psr-680w|\
96 px-4885|\
97 re6500|\
98 rp-n53|\
99 rt5350f-olinuxino|\
100 rt5350f-olinuxino-evb|\
101 rt-g32-b1|\
102 rt-n10-plus|\
103 rt-n13u|\
104 rt-n14u|\
105 rt-n15|\
106 rt-n56u|\
107 rut5xx|\
108 sap-g3200u3|\
109 sl-r7205|\
110 tew-691gr|\
111 tew-692gr|\
112 tiny-ac|\
113 ur-326n4g|\
114 ur-336un|\
115 v22rw-2x2|\
116 vocore|\
117 w150m|\
118 w306r-v20|\
119 w502u|\
120 wf-2881|\
121 whr-1166d|\
122 whr-300hp2|\
123 whr-600d|\
124 whr-g300n|\
125 witi|\
126 wizfi630a|\
127 wl-330n|\
128 wl-330n3g|\
129 wl-341v3|\
130 wl-351|\
131 wli-tx4-ag300n|\
132 wmr-300|\
133 wnce2001|\
134 wr512-3gn|\
135 wr6202|\
136 wrtnode|\
137 wrtnode2r |\
138 wrtnode2p |\
139 wsr-600|\
140 wt1520|\
141 wt3020|\
142 wzr-agl300nh|\
143 x5|\
144 x8|\
145 y1|\
146 y1s|\
147 zbt-wa05|\
148 zbt-we826|\
149 zbt-wg2626|\
150 zbt-wr8305rt|\
151 zte-q7|\
152 youku-yk1)
153 [ "$magic" != "27051956" ] && {
154 echo "Invalid image type."
155 return 1
156 }
157 return 0
158 ;;
159 ar670w)
160 [ "$magic" != "6d000080" ] && {
161 echo "Invalid image type."
162 return 1
163 }
164 return 0
165 ;;
166 br-6475nd)
167 [ "$magic" != "43535953" ] && {
168 echo "Invalid image type."
169 return 1
170 }
171 return 0
172 ;;
173 c20i)
174 [ "$magic" != "03000000" ] && {
175 echo "Invalid image type."
176 return 1
177 }
178 return 0
179 ;;
180 cy-swr1100|\
181 dir-610-a1|\
182 dir-645|\
183 dir-860l-b1)
184 [ "$magic" != "5ea3a417" ] && {
185 echo "Invalid image type."
186 return 1
187 }
188 return 0
189 ;;
190 wsr-1166)
191 [ "$magic" != "48445230" ] && {
192 echo "Invalid image type."
193 return 1
194 }
195 return 0
196 ;;
197 ubnt-erx)
198 nand_do_platform_check "$board" "$1"
199 return $?;
200 ;;
201 esac
202
203 echo "Sysupgrade is not yet supported on $board."
204 return 1
205 }
206
207 platform_nand_pre_upgrade() {
208 local board=$(ramips_board_name)
209
210 case "$board" in
211 ubnt-erx)
212 platform_upgrade_ubnt_erx "$ARGV"
213 ;;
214 esac
215 }
216
217 platform_pre_upgrade() {
218 local board=$(ramips_board_name)
219
220 case "$board" in
221 ubnt-erx)
222 nand_do_upgrade "$ARGV"
223 ;;
224 esac
225 }
226
227 platform_do_upgrade() {
228 local board=$(ramips_board_name)
229
230 case "$board" in
231 *)
232 default_do_upgrade "$ARGV"
233 ;;
234 esac
235 }
236
237 disable_watchdog() {
238 killall watchdog
239 ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
240 echo 'Could not disable watchdog'
241 return 1
242 }
243 }
244
245 blink_led() {
246 . /etc/diag.sh; set_state upgrade
247 }
248
249 append sysupgrade_pre_upgrade disable_watchdog
250 append sysupgrade_pre_upgrade blink_led