Skip to content

Commit 85da97f

Browse files
nvlsianpud3zd3z
authored andcommitted
bootutil/bootutil_public: Treat unreachable image swap state as empty
Treat state of unreachable image device as if it is empty image. This is required for boot the primary image if it is still available. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
1 parent 54b4ad9 commit 85da97f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

boot/bootutil/src/bootutil_public.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,15 @@ boot_swap_type_multi(int image_index)
425425

426426
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SECONDARY(image_index),
427427
&secondary_slot);
428-
if (rc) {
428+
if (rc == BOOT_EFLASH) {
429+
BOOT_LOG_INF("Secondary image of image pair (%d.) "
430+
"is unreachable. Treat it as empty", image_index);
431+
secondary_slot.magic = BOOT_MAGIC_UNSET;
432+
secondary_slot.swap_type = BOOT_SWAP_TYPE_NONE;
433+
secondary_slot.copy_done = BOOT_FLAG_UNSET;
434+
secondary_slot.image_ok = BOOT_FLAG_UNSET;
435+
secondary_slot.image_num = 0;
436+
} else if (rc) {
429437
return BOOT_SWAP_TYPE_PANIC;
430438
}
431439

0 commit comments

Comments
 (0)