bootutil: fix boostrapping in swap-move
Fix boostrapping in swap-move that was being skipped due to the having
an erased header in the primary slot which caused an early return
because of the requirement of having to re-read image headers when
"moving" an image during an upgrade.
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index 94edba6..5d23be3 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -1566,7 +1566,14 @@
* have been updated in the previous function call.
*/
rc = boot_read_image_headers(state, !boot_status_is_reset(bs), bs);
+#ifdef MCUBOOT_BOOTSTRAP
+ /* When bootstrapping it's OK to not have image magic in the primary slot */
+ if (rc != 0 && (BOOT_CURR_IMG(state) != BOOT_PRIMARY_SLOT ||
+ boot_check_header_erased(state, BOOT_PRIMARY_SLOT) != 0)) {
+#else
if (rc != 0) {
+#endif
+
/* Continue with next image if there is one. */
BOOT_LOG_WRN("Failed reading image headers; Image=%u",
BOOT_CURR_IMG(state));