diff --git a/target/linux/mvebu/cortexa53/base-files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa53/base-files/lib/upgrade/platform.sh index 7ddb516762b..8b8149c96b2 100755 --- a/target/linux/mvebu/cortexa53/base-files/lib/upgrade/platform.sh +++ b/target/linux/mvebu/cortexa53/base-files/lib/upgrade/platform.sh @@ -7,6 +7,40 @@ RAMFS_COPY_BIN='fw_printenv fw_setenv mkfs.f2fs fdisk' RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' REQUIRE_IMAGE_METADATA=1 +# U-Boot loads the first boot.scr it finds, so keep the active slot's script in +# sync even when the full upgrade is written to the inactive slot. +methode_update_active_bootscript() { + local active_part="$1" + local updated_part="$2" + local active_dev + local updated_dev + local ret=0 + + [ "$active_part" -a "$updated_part" ] || return 0 + + active_dev="$(find_mmc_part "$active_part" "$CI_ROOTDEV")" + updated_dev="$(find_mmc_part "$updated_part" "$CI_ROOTDEV")" + [ "$active_dev" -a "$updated_dev" ] || return 1 + + mkdir -p /tmp/bootpart-new + mount -o ro "$updated_dev" /tmp/bootpart-new || return 1 + + cp /tmp/bootpart-new/boot.scr /tmp/boot.scr + ret=$? + umount /tmp/bootpart-new + [ $ret -eq 0 ] || return 1 + + mkdir -p /tmp/bootpart-active + mount "$active_dev" /tmp/bootpart-active || return 1 + + cp /tmp/boot.scr /tmp/bootpart-active/boot.scr || ret=1 + sync + + umount /tmp/bootpart-active + + return $ret +} + platform_check_image() { case "$(board_name)" in glinet,gl-mv1000|\ @@ -35,15 +69,19 @@ platform_do_upgrade() { ;; methode,udpu|\ methode,edpu) + local active_kernpart + [ "$(rootfs_type)" = "tmpfs" ] && { local firmware_active="$(fw_printenv -n bootactive)" case "$firmware_active" in 1) + active_kernpart="kernel_1" CI_KERNPART="kernel_2" CI_ROOTPART="rootfs_2" fw_setenv bootactive 2 ;; 2) + active_kernpart="kernel_2" CI_KERNPART="kernel_1" CI_ROOTPART="rootfs_1" fw_setenv bootactive 1 @@ -54,11 +92,13 @@ platform_do_upgrade() { local root="$(cmdline_get_var root)" case "$root" in /dev/mmcblk*p2) + active_kernpart="kernel_1" CI_KERNPART="kernel_2" CI_ROOTPART="rootfs_2" fw_setenv bootactive 2 ;; /dev/mmcblk*p4) + active_kernpart="kernel_2" CI_KERNPART="kernel_1" CI_ROOTPART="rootfs_1" fw_setenv bootactive 1 @@ -66,6 +106,9 @@ platform_do_upgrade() { esac emmc_do_upgrade "$1" + + methode_update_active_bootscript "$active_kernpart" "$CI_KERNPART" || \ + echo "Failed to update active boot script" ;; *) default_do_upgrade "$1"