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