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_do_upgrade
() {
64 local board
=$
(board_name
)
84 bananapi
,bpi-r3-mini|\
90 xiaomi
,redmi-router-ax6000-ubootmod
)
91 [ -e /dev
/fit0
] && fitblk
/dev
/fit0
92 [ -e /dev
/fitrw
] && fitblk
/dev
/fitrw
93 bootdev
="$(fitblk_get_bootdev)"
96 EMMC_KERN_DEV
="/dev/$bootdev"
100 PART_NAME
="/dev/mtd${bootdev:8}"
101 default_do_upgrade
"$1"
110 case "$(cmdline_get_var root)" in
112 CI_KERNPART
="production"
124 default_do_upgrade
"$1"
136 mediatek
,mt7981-rfb|\
139 xiaomi
,mi-router-ax3000t-ubootmod|\
140 xiaomi
,mi-router-wr30u-ubootmod
)
149 CI_KERNPART
="kernel0"
150 EMMC_ROOT_DEV
="$(cmdline_get_var root)"
153 xiaomi
,mi-router-ax3000t|\
154 xiaomi
,mi-router-wr30u-stock|\
155 xiaomi
,redmi-router-ax6000-stock
)
156 CI_KERN_UBIPART
=ubi_kernel
160 zyxel
,ex5601-t0-ubootmod
)
162 CI_ROOTPART
="ubi_rootfs"
166 local rootdev
="$(cmdline_get_var root)"
167 rootdev
="${rootdev##*/}"
168 rootdev
="${rootdev%p[0-9]*}"
171 CI_ROOTDEV
="$rootdev"
190 platform_check_image
() {
191 local board
=$
(board_name
)
192 local magic
="$(get_magic_long "$1")"
194 [ "$#" -gt 1 ] && return 1
200 [ "$magic" != "d00dfeed" ] && {
201 echo "Invalid image type."
207 nand_do_platform_check
"$board" "$1"
215 platform_copy_config
() {
216 case "$(board_name)" in
218 case "$(cmdline_get_var root)" in
225 bananapi
,bpi-r3-mini|\
227 case "$(fitblk_get_bootdev)" in
245 platform_pre_upgrade
() {
246 local board
=$
(board_name
)
254 xiaomi
,mi-router-ax3000t|\
255 xiaomi
,mi-router-wr30u-stock|\
256 xiaomi
,redmi-router-ax6000-stock
)