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