add chaos_calmer branch
[15.05/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         3g-6200n | \
18         3g-6200nl | \
19         3g150b | \
20         3g300m | \
21         a5-v11 | \
22         air3gii | \
23         ai-br100 |\
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         dcs-930 | \
40         dir-300-b1 | \
41         dir-300-b7 | \
42         dir-320-b1 | \
43         dir-600-b1 | \
44         dir-600-b2 | \
45         dir-615-d | \
46         dir-615-h1 | \
47         dir-620-a1 | \
48         dir-620-d1 | \
49         dir-810l | \
50         e1700 | \
51         esr-9753 | \
52         f7c027 | \
53         fonera20n | \
54         freestation5 | \
55         firewrt |\
56         hg255d | \
57         hlk-rm04 | \
58         ht-tm02 | \
59         hw550-3g | \
60         ip2202 | \
61         m2m | \
62         m3 | \
63         m4 | \
64         microwrt | \
65         mlw221 | \
66         mlwg2 | \
67         mofi3500-3gn | \
68         mpr-a1 | \
69         mpr-a2 | \
70         mr-102n | \
71         mzk-w300nh2 | \
72         nbg-419n | \
73         nw718 | \
74         omni-emb | \
75         omni-emb-hpm | \
76         omni-plug | \
77         olinuxino-rt5350f | \
78         olinuxino-rt5350f-evb | \
79         psr-680w | \
80         px4885 | \
81         rp-n53 | \
82         rt-g32-b1 | \
83         rt-n10-plus | \
84         rt-n13u | \
85         rt-n14u | \
86         rt-n15 | \
87         rt-n56u | \
88         rut5xx | \
89         sl-r7205 | \
90         tew-691gr | \
91         tew-692gr | \
92         ur-326n4g |\
93         ur-336un |\
94         v22rw-2x2 | \
95         vocore | \
96         w150m | \
97         w306r-v20 |\
98         w502u |\
99         whr-g300n |\
100         whr-300hp2 |\
101         whr-600d |\
102         whr-1166d |\
103         wsr-600 |\
104         wl-330n | \
105         wl-330n3g | \
106         wl-351 | \
107         wl341v3 | \
108         wli-tx4-ag300n | \
109         wzr-agl300nh | \
110         wmr300 |\
111         wnce2001 | \
112         wr512-3gn |\
113         wr6202 |\
114         wr8305rt |\
115         wrtnode |\
116         wt1520 |\
117         wt3020 |\
118         x5 |\
119         x8 |\
120         xiaomi-miwifi-mini |\
121         y1 |\
122         y1s |\
123         zte-q7 |\
124         zbt-wa05)
125                 [ "$magic" != "27051956" ] && {
126                         echo "Invalid image type."
127                         return 1
128                 }
129                 return 0
130                 ;;
131         wsr-1166)
132                 [ "$magic" != "48445230" ] && {
133                         echo "Invalid image type."
134                         return 1
135                 }
136                 return 0
137                 ;;
138         ar670w)
139                 [ "$magic" != "6d000080" ] && {
140                         echo "Invalid image type."
141                         return 1
142                 }
143                 return 0
144                 ;;
145         cy-swr1100 |\
146         dir-610-a1 |\
147         dir-645 |\
148         dir-860l-b1)
149                 [ "$magic" != "5ea3a417" ] && {
150                         echo "Invalid image type."
151                         return 1
152                 }
153                 return 0
154                 ;;
155         br-6475nd)
156                 [ "$magic" != "43535953" ] && {
157                         echo "Invalid image type."
158                         return 1
159                 }
160                 return 0
161                 ;;
162         c20i)
163                 [ "$magic" != "03000000" ] && {
164                         echo "Invalid image type."
165                         return 1
166                 }
167                 return 0
168                 ;;
169         esac
170
171         echo "Sysupgrade is not yet supported on $board."
172         return 1
173 }
174
175 platform_do_upgrade() {
176         local board=$(ramips_board_name)
177
178         case "$board" in
179         *)
180                 default_do_upgrade "$ARGV"
181                 ;;
182         esac
183 }
184
185 disable_watchdog() {
186         killall watchdog
187         ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
188                 echo 'Could not disable watchdog'
189                 return 1
190         }
191 }
192
193 append sysupgrade_pre_upgrade disable_watchdog