]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
mvebu: cortexa53: uDPU/eDPU: update active bootscript as well 23017/head
authorRobert Marko <robert.marko@sartura.hr>
Mon, 25 May 2026 19:26:14 +0000 (21:26 +0200)
committerRobert Marko <robert.marko@sartura.hr>
Tue, 26 May 2026 17:35:42 +0000 (19:35 +0200)
Currently, sysupgrade will only upgrade the unused slot, however since the
whole dual firmware logic is in the bootscript U-boot will just use the
first bootscript it finds.

So, in a case that you are running slot A it will upgrade slot B, however
that means that slot B will be still booted by the old bootscript that came
with the previous firmware version.

This is an issue if you need to change anything, so lets add a custom
function that upgrades the active bootscript as well after flashing the
slot firmware.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
target/linux/mvebu/cortexa53/base-files/lib/upgrade/platform.sh

index 7ddb516762b0f51683e3d68dceae9bed5dae465b..8b8149c96b24432fef8f7097e92a3bab5cabd2aa 100755 (executable)
@@ -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"