ipq40xx: add support for Wallystech DR40x9
[openwrt/staging/wigyori.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 wallys,dr40x9)
124 nand_do_upgrade "$1"
125 ;;
126 glinet,gl-b2200)
127 CI_KERNPART="0:HLOS"
128 CI_ROOTPART="rootfs"
129 CI_DATAPART="rootfs_data"
130 emmc_do_upgrade "$1"
131 ;;
132 alfa-network,ap120c-ac)
133 part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
134 if [ "$part" = "rootfs1" ]; then
135 fw_setenv active 2 || exit 1
136 CI_UBIPART="rootfs2"
137 else
138 fw_setenv active 1 || exit 1
139 CI_UBIPART="rootfs1"
140 fi
141 nand_do_upgrade "$1"
142 ;;
143 asus,map-ac2200)
144 CI_KERNPART="linux"
145 nand_do_upgrade "$1"
146 ;;
147 asus,rt-ac42u |\
148 asus,rt-ac58u)
149 CI_KERNPART="linux"
150 nand_do_upgrade "$1"
151 ;;
152 cellc,rtl30vw)
153 CI_UBIPART="ubifs"
154 askey_do_upgrade "$1"
155 ;;
156 compex,wpj419)
157 nand_do_upgrade "$1"
158 ;;
159 google,wifi)
160 export_bootdevice
161 export_partdevice CI_ROOTDEV 0
162 CI_KERNPART="kernel"
163 CI_ROOTPART="rootfs"
164 emmc_do_upgrade "$1"
165 ;;
166 linksys,ea6350v3 |\
167 linksys,ea8300 |\
168 linksys,mr8300 |\
169 linksys,whw01 |\
170 linksys,whw03v2)
171 platform_do_upgrade_linksys "$1"
172 ;;
173 meraki,mr33 |\
174 meraki,mr74)
175 CI_KERNPART="part.safe"
176 nand_do_upgrade "$1"
177 ;;
178 mikrotik,cap-ac|\
179 mikrotik,hap-ac2|\
180 mikrotik,hap-ac3-lte6-kit|\
181 mikrotik,lhgg-60ad|\
182 mikrotik,sxtsq-5-ac|\
183 mikrotik,wap-ac|\
184 mikrotik,wap-ac-lte|\
185 mikrotik,wap-r-ac)
186 [ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
187 default_do_upgrade "$1"
188 ;;
189 mikrotik,hap-ac3)
190 platform_do_upgrade_mikrotik_nand "$1"
191 ;;
192 netgear,rbr50 |\
193 netgear,rbs50 |\
194 netgear,srr60 |\
195 netgear,srs60)
196 platform_do_upgrade_netgear_orbi_upgrade "$1"
197 ;;
198 openmesh,a42 |\
199 openmesh,a62 |\
200 plasmacloud,pa1200 |\
201 plasmacloud,pa2200)
202 PART_NAME="inactive"
203 platform_do_upgrade_dualboot_datachk "$1"
204 ;;
205 sony,ncp-hg100-cellular)
206 sony_emmc_do_upgrade "$1"
207 ;;
208 teltonika,rutx10 |\
209 zte,mf18a |\
210 zte,mf286d |\
211 zte,mf289f)
212 CI_UBIPART="rootfs"
213 nand_do_upgrade "$1"
214 ;;
215 zyxel,nbg6617)
216 zyxel_do_upgrade "$1"
217 ;;
218 *)
219 default_do_upgrade "$1"
220 ;;
221 esac
222 }
223
224 platform_copy_config() {
225 case "$(board_name)" in
226 glinet,gl-b2200 |\
227 google,wifi)
228 emmc_copy_config
229 ;;
230 esac
231 return 0;
232 }