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