1 REQUIRE_IMAGE_METADATA
=1
2 RAMFS_COPY_BIN
='fitblk'
6 # initialize UBI if it's running on initramfs
7 [ "$(rootfs_type)" = "tmpfs" ] ||
return 0
9 ubirmvol
/dev
/ubi0
-N rootfs
10 ubirmvol
/dev
/ubi0
-N rootfs_data
11 ubirmvol
/dev
/ubi0
-N jffs2
12 ubimkvol
/dev
/ubi0
-N jffs2
-s 0x3e000
15 xiaomi_initial_setup
()
17 # initialize UBI and setup uboot-env if it's running on initramfs
18 [ "$(rootfs_type)" = "tmpfs" ] ||
return 0
20 local mtdnum
="$( find_mtd_index ubi )"
21 if [ ! "$mtdnum" ]; then
22 echo "unable to find mtd partition ubi"
26 local kern_mtdnum
="$( find_mtd_index ubi_kernel )"
27 if [ ! "$kern_mtdnum" ]; then
28 echo "unable to find mtd partition ubi_kernel"
32 ubidetach
-m "$mtdnum"
33 ubiformat
/dev
/mtd
$mtdnum -y
35 ubidetach
-m "$kern_mtdnum"
36 ubiformat
/dev
/mtd
$kern_mtdnum -y
38 if ! fw_printenv
-n flag_try_sys2_failed
&>/dev
/null
; then
39 echo "failed to access u-boot-env. skip env setup."
43 fw_setenv boot_wait on
45 fw_setenv flag_boot_rootfs
0
46 fw_setenv flag_last_success
1
47 fw_setenv flag_boot_success
1
48 fw_setenv flag_try_sys1_failed
8
49 fw_setenv flag_try_sys2_failed
8
51 local board
=$
(board_name
)
53 xiaomi
,mi-router-ax3000t|\
54 xiaomi
,mi-router-wr30u-stock
)
55 fw_setenv mtdparts
"nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),34816k(ubi),34816k(ubi1),32768k(overlay),12288k(data),256k(KF)"
57 xiaomi
,redmi-router-ax6000-stock
)
58 fw_setenv mtdparts
"nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),30720k(ubi),30720k(ubi1),51200k(overlay)"
63 platform_get_bootdev
() {
64 local rootdisk
="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)"
66 for handle
in /sys
/class
/block
/*/of_node
/phandle
/sys
/class
/block
/*/device
/of_node
/phandle
; do
67 [ ! -e "$handle" ] && continue
68 if [ "$rootdisk" = "$(cat $handle)" ]; then
69 bootdev
="${handle%/of_node/phandle}"
70 bootdev
="${bootdev%/device}"
71 bootdev
="${bootdev#/sys/class/block/}"
78 platform_do_upgrade
() {
79 local board
=$
(board_name
)
99 local rootdev
="$(cmdline_get_var root)"
100 rootdev
="${rootdev##*/}"
101 rootdev
="${rootdev%p[0-9]*}"
104 CI_ROOTDEV
="$rootdev"
105 CI_KERNPART
="production"
110 default_do_upgrade
"$1"
119 [ -e /dev
/fit0
] && fitblk
/dev
/fit0
120 [ -e /dev
/fitrw
] && fitblk
/dev
/fitrw
121 bootdev
="$(platform_get_bootdev)"
124 EMMC_KERN_DEV
="/dev/$bootdev"
134 case "$(cmdline_get_var root)" in
136 CI_KERNPART
="production"
147 default_do_upgrade
"$1"
157 mediatek
,mt7981-rfb|\
162 xiaomi
,mi-router-ax3000t-ubootmod|\
163 xiaomi
,mi-router-wr30u-ubootmod|\
164 xiaomi
,redmi-router-ax6000-ubootmod
)
169 CI_KERNPART
="production"
177 CI_KERNPART
="kernel0"
178 EMMC_ROOT_DEV
="$(cmdline_get_var root)"
181 xiaomi
,mi-router-ax3000t|\
182 xiaomi
,mi-router-wr30u-stock|\
183 xiaomi
,redmi-router-ax6000-stock
)
184 CI_KERN_UBIPART
=ubi_kernel
188 zyxel
,ex5601-t0-ubootmod
)
190 CI_ROOTPART
="ubi_rootfs"
201 platform_check_image
() {
202 local board
=$
(board_name
)
203 local magic
="$(get_magic_long "$1")"
205 [ "$#" -gt 1 ] && return 1
211 [ "$magic" != "d00dfeed" ] && {
212 echo "Invalid image type."
218 nand_do_platform_check
"$board" "$1"
226 platform_copy_config
() {
227 case "$(board_name)" in
230 case "$(cmdline_get_var root)" in
237 case "$(platform_get_bootdev)" in
253 platform_pre_upgrade
() {
254 local board
=$
(board_name
)
262 xiaomi
,mi-router-ax3000t|\
263 xiaomi
,mi-router-wr30u-stock|\
264 xiaomi
,redmi-router-ax6000-stock
)