2 REQUIRE_IMAGE_METADATA
=1
4 RAMFS_COPY_BIN
='fw_printenv fw_setenv head'
5 RAMFS_COPY_DATA
='/etc/fw_env.config /var/lock/fw_printenv.lock'
7 xiaomi_initramfs_prepare
() {
8 # Wipe UBI if running initramfs
9 [ "$(rootfs_type)" = "tmpfs" ] ||
return 0
11 local rootfs_mtdnum
="$( find_mtd_index rootfs )"
12 if [ ! "$rootfs_mtdnum" ]; then
13 echo "unable to find mtd partition rootfs"
17 local kern_mtdnum
="$( find_mtd_index ubi_kernel )"
18 if [ ! "$kern_mtdnum" ]; then
19 echo "unable to find mtd partition ubi_kernel"
23 ubidetach
-m "$rootfs_mtdnum"
24 ubiformat
/dev
/mtd
$rootfs_mtdnum -y
26 ubidetach
-m "$kern_mtdnum"
27 ubiformat
/dev
/mtd
$kern_mtdnum -y
30 platform_check_image
() {
34 platform_pre_upgrade
() {
35 case "$(board_name)" in
39 xiaomi_initramfs_prepare
44 platform_do_upgrade
() {
45 case "$(board_name)" in
57 CI_KERN_UBIPART
="rootfs"
58 CI_ROOT_UBIPART
="user_property"
59 buffalo_upgrade_prepare
60 nand_do_flash_file
"$1" || nand_do_upgrade_failed
61 nand_do_restore_config || nand_do_upgrade_failed
62 buffalo_upgrade_optvol
65 active
="$(fw_printenv -n active)"
66 if [ "$active" -eq "1" ]; then
71 # force altbootcmd which handles partition change in u-boot
73 fw_setenv upgrade_available
1
78 boot_part
="$(fw_printenv -n boot_part)"
79 if [ "$boot_part" -eq "1" ]; then
81 CI_KERNPART
="alt_kernel"
82 CI_UBIPART
="alt_rootfs"
87 fw_setenv boot_part_ready
3
88 fw_setenv auto_recovery
yes
100 # Make sure that UART is enabled
101 fw_setenv boot_wait on
104 # Enforce single partition.
105 fw_setenv flag_boot_rootfs
0
106 fw_setenv flag_last_success
0
107 fw_setenv flag_boot_success
1
108 fw_setenv flag_try_sys1_failed
8
109 fw_setenv flag_try_sys2_failed
8
111 # Kernel and rootfs are placed in 2 different UBI
112 CI_KERN_UBIPART
="ubi_kernel"
113 CI_ROOT_UBIPART
="rootfs"
117 active
="$(fw_printenv -n active)"
118 if [ "$active" -eq "1" ]; then
119 CI_UBIPART
="rootfs_1"
123 # force altbootcmd which handles partition change in u-boot
124 fw_setenv bootcount
3
125 fw_setenv upgrade_available
1
129 CI_KERN_UBIPART
="ubi_kernel"
130 CI_ROOT_UBIPART
="rootfs"
134 local config_mtdnum
="$(find_mtd_index 0:bootconfig)"
135 [ -z "$config_mtdnum" ] && reboot
136 part_num
="$(hexdump -e '1/1 "%01x|
"' -n 1 -s 168 -C /dev/mtd$config_mtdnum | cut -f 1 -d "|
" | head -n1)"
137 if [ "$part_num" -eq "0" ]; then
142 kernelname
="0:HLOS_1"
143 rootfsname
="rootfs_1"
148 default_do_upgrade
"$1"