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.
@@ -1566,7 +1566,14 @@ boot_prepare_image_for_update(struct boot_loader_state *state,
* 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));
