Skip to content

Commit 7ac03cf

Browse files
michallencxiaoxiang781216
authored andcommitted
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]>
1 parent 0e65af6 commit 7ac03cf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

boot/nxboot/loader/boot.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ static enum nxboot_update_type
313313
nxboot_progress(nxboot_progress_end);
314314
return NXBOOT_UPDATE_TYPE_UPDATE;
315315
}
316+
317+
flash_partition_erase_first_sector(update);
316318
}
317319

318320
nxboot_progress(nxboot_progress_end);
@@ -643,12 +645,14 @@ int nxboot_get_state(struct nxboot_state *state)
643645
else if (IS_INTERNAL_MAGIC(primary_header.magic))
644646
{
645647
recovery_pointer = primary_header.magic & NXBOOT_RECOVERY_PTR_MASK;
646-
if (recovery_pointer == NXBOOT_SECONDARY_SLOT_NUM)
648+
if (recovery_pointer == NXBOOT_SECONDARY_SLOT_NUM &&
649+
IS_INTERNAL_MAGIC(secondary_header.magic))
647650
{
648651
state->primary_confirmed =
649652
primary_header.crc == secondary_header.crc;
650653
}
651-
else if (recovery_pointer == NXBOOT_TERTIARY_SLOT_NUM)
654+
else if (recovery_pointer == NXBOOT_TERTIARY_SLOT_NUM &&
655+
IS_INTERNAL_MAGIC(tertiary_header.magic))
652656
{
653657
state->primary_confirmed =
654658
primary_header.crc == tertiary_header.crc;

0 commit comments

Comments
 (0)