From 7ac03cfceff4e7156560c2c972e70904a8790767 Mon Sep 17 00:00:00 2001 From: Michal Lenc Date: Wed, 27 Aug 2025 09:58:41 +0200 Subject: [PATCH] boot/nxboot/loader/boot.c: avoid unwanted confirm on double update Following steps led to incorrect behavior: - upload update image - restart device and perform the update - upload the same update image again without confirming This led to the unwanted confirm of the update image. This change ensures the update image is not confirmed by uploading the same image to the update slot. The correct behavior is to perform revert to the last stable image if this occurs. Signed-off-by: Michal Lenc --- boot/nxboot/loader/boot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/boot/nxboot/loader/boot.c b/boot/nxboot/loader/boot.c index f7a24c7cd..6de9659ac 100644 --- a/boot/nxboot/loader/boot.c +++ b/boot/nxboot/loader/boot.c @@ -313,6 +313,8 @@ static enum nxboot_update_type nxboot_progress(nxboot_progress_end); return NXBOOT_UPDATE_TYPE_UPDATE; } + + flash_partition_erase_first_sector(update); } nxboot_progress(nxboot_progress_end); @@ -643,12 +645,14 @@ int nxboot_get_state(struct nxboot_state *state) else if (IS_INTERNAL_MAGIC(primary_header.magic)) { recovery_pointer = primary_header.magic & NXBOOT_RECOVERY_PTR_MASK; - if (recovery_pointer == NXBOOT_SECONDARY_SLOT_NUM) + if (recovery_pointer == NXBOOT_SECONDARY_SLOT_NUM && + IS_INTERNAL_MAGIC(secondary_header.magic)) { state->primary_confirmed = primary_header.crc == secondary_header.crc; } - else if (recovery_pointer == NXBOOT_TERTIARY_SLOT_NUM) + else if (recovery_pointer == NXBOOT_TERTIARY_SLOT_NUM && + IS_INTERNAL_MAGIC(tertiary_header.magic)) { state->primary_confirmed = primary_header.crc == tertiary_header.crc;