Remove trailer management for overwrite-only
When building in overwrite-only, there is no status/trailer management.
This commit fixes an issue where there was a write to image_ok/copy_done
where those flags where already set (copied from slot 1) which would
cause a write over non-erased flash.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index 6250050..0bd2cf2 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -1112,6 +1112,7 @@
/**
* Marks the image in slot 0 as fully copied.
*/
+#ifndef MCUBOOT_OVERWRITE_ONLY
static int
boot_set_copy_done(void)
{
@@ -1127,6 +1128,7 @@
flash_area_close(fap);
return rc;
}
+#endif /* !MCUBOOT_OVERWRITE_ONLY */
/**
* Marks a reverted image in slot 0 as confirmed. This is necessary to ensure
@@ -1137,6 +1139,7 @@
* image installed on slot0 and the new image to be upgrade to has a bad sig,
* image_ok would be overwritten.
*/
+#ifndef MCUBOOT_OVERWRITE_ONLY
static int
boot_set_image_ok(void)
{
@@ -1163,6 +1166,7 @@
flash_area_close(fap);
return rc;
}
+#endif /* !MCUBOOT_OVERWRITE_ONLY */
/**
* Performs an image swap if one is required.
@@ -1283,10 +1287,12 @@
* swap was finished to avoid a new revert.
*/
if (swap_type == BOOT_SWAP_TYPE_REVERT || swap_type == BOOT_SWAP_TYPE_FAIL) {
+#ifndef MCUBOOT_OVERWRITE_ONLY
rc = boot_set_image_ok();
if (rc != 0) {
swap_type = BOOT_SWAP_TYPE_PANIC;
}
+#endif /* !MCUBOOT_OVERWRITE_ONLY */
}
} else {
swap_type = BOOT_SWAP_TYPE_NONE;
@@ -1302,10 +1308,12 @@
case BOOT_SWAP_TYPE_REVERT:
slot = 1;
reload_headers = true;
+#ifndef MCUBOOT_OVERWRITE_ONLY
rc = boot_set_copy_done();
if (rc != 0) {
swap_type = BOOT_SWAP_TYPE_PANIC;
}
+#endif /* !MCUBOOT_OVERWRITE_ONLY */
break;
case BOOT_SWAP_TYPE_FAIL: