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