boot: mynewt: add config for swap without scratch
Add Mynewt 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/mynewt/flash_map_backend/src/flash_map_extended.c b/boot/mynewt/flash_map_backend/src/flash_map_extended.c
index ee894dd..2e3e6d3 100644
--- a/boot/mynewt/flash_map_backend/src/flash_map_extended.c
+++ b/boot/mynewt/flash_map_backend/src/flash_map_extended.c
@@ -25,7 +25,9 @@
switch (slot) {
case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
+#if MCUBOOT_SWAP_USING_SCRATCH
case 2: return FLASH_AREA_IMAGE_SCRATCH;
+#endif
}
return 255;
}
diff --git a/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h b/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
index 889fcdd..a67a970 100644
--- a/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
+++ b/boot/mynewt/mcuboot_config/include/mcuboot_config/mcuboot_config.h
@@ -67,6 +67,9 @@
MYNEWT_VAL(BOOTUTIL_ENCRYPT_EC256)
#define MCUBOOT_ENC_IMAGES 1
#endif
+#if MYNEWT_VAL(BOOTUTIL_SWAP_USING_MOVE)
+#define MCUBOOT_SWAP_USING_MOVE 1
+#endif
#if MYNEWT_VAL(BOOTUTIL_OVERWRITE_ONLY)
#define MCUBOOT_OVERWRITE_ONLY 1
#endif
diff --git a/boot/mynewt/mcuboot_config/syscfg.yml b/boot/mynewt/mcuboot_config/syscfg.yml
index 86821d1..ca5a898 100644
--- a/boot/mynewt/mcuboot_config/syscfg.yml
+++ b/boot/mynewt/mcuboot_config/syscfg.yml
@@ -55,6 +55,9 @@
BOOTUTIL_USE_TINYCRYPT:
description: 'Use tinycrypt for crypto operations.'
value: 0
+ BOOTUTIL_SWAP_USING_MOVE:
+ description: 'Perform swap without requiring scratch.'
+ value: 0
BOOTUTIL_OVERWRITE_ONLY:
description: 'Non-swapping upgrades, copy from slot 1 to slot 0 only.'
value: 0