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