boot: zephyr: add config for swap without scratch
Add Zephyr option to enable building a bootloader that uses an
alternative swap algorithm, that first moves up all sectors in slot1 and
then directly swaps between slot0 and slot1.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_config.h b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
index f517b7e..4fff4b1 100644
--- a/boot/zephyr/include/mcuboot_config/mcuboot_config.h
+++ b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
@@ -53,6 +53,10 @@
#define MCUBOOT_OVERWRITE_ONLY_FAST
#endif
+#ifdef CONFIG_BOOT_SWAP_USING_MOVE
+#define MCUBOOT_SWAP_USING_MOVE 1
+#endif
+
#ifdef CONFIG_LOG
#define MCUBOOT_HAVE_LOGGING 1
#endif
diff --git a/boot/zephyr/include/sysflash/sysflash.h b/boot/zephyr/include/sysflash/sysflash.h
index c422efd..25487ee 100644
--- a/boot/zephyr/include/sysflash/sysflash.h
+++ b/boot/zephyr/include/sysflash/sysflash.h
@@ -37,6 +37,8 @@
#error "Image slot and flash area mapping is not defined"
#endif
+#if !defined(CONFIG_BOOT_SWAP_USING_MOVE)
#define FLASH_AREA_IMAGE_SCRATCH DT_FLASH_AREA_IMAGE_SCRATCH_ID
+#endif
#endif /* __SYSFLASH_H__ */
diff --git a/boot/zephyr/include/target.h b/boot/zephyr/include/target.h
index 99f6361..f156c32 100644
--- a/boot/zephyr/include/target.h
+++ b/boot/zephyr/include/target.h
@@ -35,8 +35,8 @@
!defined(FLASH_AREA_IMAGE_0_SIZE) || \
!defined(FLASH_AREA_IMAGE_1_OFFSET) || \
!defined(FLASH_AREA_IMAGE_1_SIZE) || \
- !defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET) || \
- !defined(FLASH_AREA_IMAGE_SCRATCH_SIZE)
+ (!defined(CONFIG_BOOT_SWAP_USING_MOVE) && !defined(FLASH_AREA_IMAGE_SCRATCH_OFFSET)) || \
+ (!defined(CONFIG_BOOT_SWAP_USING_MOVE) && !defined(FLASH_AREA_IMAGE_SCRATCH_SIZE))
#error "Target support is incomplete; cannot build mcuboot."
#endif