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