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