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
58 CI_KERN_UBIPART
="rootfs"
59 CI_ROOT_UBIPART
="user_property"
60 buffalo_upgrade_prepare
61 nand_do_flash_file
"$1" || nand_do_upgrade_failed
62 nand_do_restore_config || nand_do_upgrade_failed
63 buffalo_upgrade_optvol
66 active
="$(fw_printenv -n active)"
67 if [ "$active" -eq "1" ]; then
72 # force altbootcmd which handles partition change in u-boot
74 fw_setenv upgrade_available
1
79 boot_part
="$(fw_printenv -n boot_part)"
80 if [ "$boot_part" -eq "1" ]; then
82 CI_KERNPART
="alt_kernel"
83 CI_UBIPART
="alt_rootfs"
88 fw_setenv boot_part_ready
3
89 fw_setenv auto_recovery
yes
101 # Make sure that UART is enabled
102 fw_setenv boot_wait on
105 # Enforce single partition.
106 fw_setenv flag_boot_rootfs
0
107 fw_setenv flag_last_success
0
108 fw_setenv flag_boot_success
1
109 fw_setenv flag_try_sys1_failed
8
110 fw_setenv flag_try_sys2_failed
8
112 # Kernel and rootfs are placed in 2 different UBI
113 CI_KERN_UBIPART
="ubi_kernel"
114 CI_ROOT_UBIPART
="rootfs"
118 active
="$(fw_printenv -n active)"
119 if [ "$active" -eq "1" ]; then
120 CI_UBIPART
="rootfs_1"
124 # force altbootcmd which handles partition change in u-boot
125 fw_setenv bootcount
3
126 fw_setenv upgrade_available
1
130 CI_KERN_UBIPART
="ubi_kernel"
131 CI_ROOT_UBIPART
="rootfs"
135 local config_mtdnum
="$(find_mtd_index 0:bootconfig)"
136 [ -z "$config_mtdnum" ] && reboot
137 part_num
="$(hexdump -e '1/1 "%01x|
"' -n 1 -s 168 -C /dev/mtd$config_mtdnum | cut -f 1 -d "|
" | head -n1)"
138 if [ "$part_num" -eq "0" ]; then
143 kernelname
="0:HLOS_1"
144 rootfsname
="rootfs_1"
149 default_do_upgrade
"$1"