This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 7ac03cfce boot/nxboot/loader/boot.c: avoid unwanted confirm on double
update
7ac03cfce is described below
commit 7ac03cfceff4e7156560c2c972e70904a8790767
Author: Michal Lenc <[email protected]>
AuthorDate: Wed Aug 27 09:58:41 2025 +0200
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 <[email protected]>
---
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;