ipq4019: add support for ZTE MF287 Pro aka DreiNeo Pro
[openwrt/staging/neocturne.git] / target / linux / ipq40xx / base-files / lib / upgrade / platform.sh
1 PART_NAME=firmware
2 REQUIRE_IMAGE_METADATA=1
3
4 RAMFS_COPY_BIN='fw_printenv fw_setenv'
5 RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
6
7 platform_check_image() {
8 case "$(board_name)" in
9 asus,rt-ac42u |\
10 asus,rt-ac58u)
11 local ubidev=$(nand_find_ubi $CI_UBIPART)
12 local asus_root=$(nand_find_volume $ubidev jffs2)
13
14 [ -n "$asus_root" ] || return 0
15
16 cat << EOF
17 jffs2 partition is still present.
18 There's probably no space left
19 to install the filesystem.
20
21 You need to delete the jffs2 partition first:
22 # ubirmvol /dev/ubi0 --name=jffs2
23
24 Once this is done. Retry.
25 EOF
26 return 1
27 ;;
28 zte,mf18a |\
29 zte,mf286d |\
30 zte,mf287plus |\
31 zte,mf287pro |\
32 zte,mf289f)
33 CI_UBIPART="rootfs"
34 local mtdnum="$( find_mtd_index $CI_UBIPART )"
35 [ ! "$mtdnum" ] && return 1
36 ubiattach -m "$mtdnum" || true
37 local ubidev="$( nand_find_ubi $CI_UBIPART )"
38 local ubi_rootfs=$(nand_find_volume $ubidev ubi_rootfs)
39 local ubi_rootfs_data=$(nand_find_volume $ubidev ubi_rootfs_data)
40
41 [ -n "$ubi_rootfs" ] || [ -n "$ubi_rootfs_data" ] || return 0
42
43 cat << EOF
44 ubi_rootfs partition is still present.
45
46 You need to delete the stock partition first:
47 # ubirmvol /dev/ubi0 -N ubi_rootfs
48 Please also delete ubi_rootfs_data, if exist:
49 # ubirmvol /dev/ubi0 -N ubi_rootfs_data
50
51 Once this is done. Retry.
52 EOF
53 return 1
54 ;;
55 esac
56 return 0;
57 }
58
59 askey_do_upgrade() {
60 local tar_file="$1"
61
62 local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
63 board_dir=${board_dir%/}
64
65 tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
66
67 nand_do_upgrade "$1"
68 }
69
70 zyxel_do_upgrade() {
71 local tar_file="$1"
72
73 local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
74 board_dir=${board_dir%/}
75
76 tar Oxf $tar_file ${board_dir}/kernel | mtd write - kernel
77
78 if [ -n "$UPGRADE_BACKUP" ]; then
79 tar Oxf $tar_file ${board_dir}/root | mtd -j "$UPGRADE_BACKUP" write - rootfs
80 else
81 tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
82 fi
83 }
84
85 platform_do_upgrade_mikrotik_nand() {
86 local fw_mtd=$(find_mtd_part kernel)
87 fw_mtd="${fw_mtd/block/}"
88 [ -n "$fw_mtd" ] || return
89
90 local board_dir=$(tar tf "$1" | grep -m 1 '^sysupgrade-.*/$')
91 board_dir=${board_dir%/}
92 [ -n "$board_dir" ] || return
93
94 local kernel_len=$(tar xf "$1" ${board_dir}/kernel -O | wc -c)
95 [ -n "$kernel_len" ] || return
96
97 tar xf "$1" ${board_dir}/kernel -O | ubiformat "$fw_mtd" -y -S $kernel_len -f -
98
99 CI_KERNPART="none"
100 nand_do_upgrade "$1"
101 }
102
103 platform_do_upgrade() {
104 case "$(board_name)" in
105 8dev,jalapeno |\
106 aruba,ap-303 |\
107 aruba,ap-303h |\
108 aruba,ap-365 |\
109 avm,fritzbox-7530 |\
110 avm,fritzrepeater-1200 |\
111 avm,fritzrepeater-3000 |\
112 buffalo,wtr-m2133hp |\
113 cilab,meshpoint-one |\
114 edgecore,ecw5211 |\
115 edgecore,oap100 |\
116 engenius,eap2200 |\
117 glinet,gl-a1300 |\
118 glinet,gl-ap1300 |\
119 luma,wrtq-329acn |\
120 mobipromo,cm520-79f |\
121 netgear,wac510 |\
122 p2w,r619ac-64m |\
123 p2w,r619ac-128m |\
124 qxwlan,e2600ac-c2 |\
125 wallys,dr40x9)
126 nand_do_upgrade "$1"
127 ;;
128 glinet,gl-b2200)
129 CI_KERNPART="0:HLOS"
130 CI_ROOTPART="rootfs"
131 CI_DATAPART="rootfs_data"
132 emmc_do_upgrade "$1"
133 ;;
134 alfa-network,ap120c-ac)
135 part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
136 if [ "$part" = "rootfs1" ]; then
137 fw_setenv active 2 || exit 1
138 CI_UBIPART="rootfs2"
139 else
140 fw_setenv active 1 || exit 1
141 CI_UBIPART="rootfs1"
142 fi
143 nand_do_upgrade "$1"
144 ;;
145 asus,map-ac2200)
146 CI_KERNPART="linux"
147 nand_do_upgrade "$1"
148 ;;
149 asus,rt-ac42u |\
150 asus,rt-ac58u)
151 CI_KERNPART="linux"
152 nand_do_upgrade "$1"
153 ;;
154 cellc,rtl30vw)
155 CI_UBIPART="ubifs"
156 askey_do_upgrade "$1"
157 ;;
158 compex,wpj419)
159 nand_do_upgrade "$1"
160 ;;
161 google,wifi)
162 export_bootdevice
163 export_partdevice CI_ROOTDEV 0
164 CI_KERNPART="kernel"
165 CI_ROOTPART="rootfs"
166 emmc_do_upgrade "$1"
167 ;;
168 linksys,ea6350v3 |\
169 linksys,ea8300 |\
170 linksys,mr8300 |\
171 linksys,whw01 |\
172 linksys,whw03v2)
173 platform_do_upgrade_linksys "$1"
174 ;;
175 meraki,mr33 |\
176 meraki,mr74)
177 CI_KERNPART="part.safe"
178 nand_do_upgrade "$1"
179 ;;
180 mikrotik,cap-ac|\
181 mikrotik,hap-ac2|\
182 mikrotik,hap-ac3-lte6-kit|\
183 mikrotik,lhgg-60ad|\
184 mikrotik,sxtsq-5-ac|\
185 mikrotik,wap-ac|\
186 mikrotik,wap-ac-lte|\
187 mikrotik,wap-r-ac)
188 [ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
189 default_do_upgrade "$1"
190 ;;
191 mikrotik,hap-ac3)
192 platform_do_upgrade_mikrotik_nand "$1"
193 ;;
194 netgear,rbr50 |\
195 netgear,rbs50 |\
196 netgear,srr60 |\
197 netgear,srs60)
198 platform_do_upgrade_netgear_orbi_upgrade "$1"
199 ;;
200 openmesh,a42 |\
201 openmesh,a62 |\
202 plasmacloud,pa1200 |\
203 plasmacloud,pa2200)
204 PART_NAME="inactive"
205 platform_do_upgrade_dualboot_datachk "$1"
206 ;;
207 sony,ncp-hg100-cellular)
208 sony_emmc_do_upgrade "$1"
209 ;;
210 teltonika,rutx10 |\
211 teltonika,rutx50 |\
212 zte,mf18a |\
213 zte,mf286d |\
214 zte,mf287plus |\
215 zte,mf287pro |\
216 zte,mf289f)
217 CI_UBIPART="rootfs"
218 nand_do_upgrade "$1"
219 ;;
220 zyxel,nbg6617)
221 zyxel_do_upgrade "$1"
222 ;;
223 *)
224 default_do_upgrade "$1"
225 ;;
226 esac
227 }
228
229 platform_copy_config() {
230 case "$(board_name)" in
231 glinet,gl-b2200 |\
232 google,wifi)
233 emmc_copy_config
234 ;;
235 esac
236 return 0;
237 }