Commit c58842e8 authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

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: default avatarFabio Utzig <utzig@apache.org>
parent 8cecedc1
Loading
Loading
Loading
Loading
+3 −0
Changes for boot/zephyr/CMakeLists.txt: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -92,6 +92,9 @@ endif()
zephyr_library_include_directories(${BOOT_DIR}/bootutil/include)
zephyr_library_sources(
  ${BOOT_DIR}/bootutil/src/loader.c
  ${BOOT_DIR}/bootutil/src/swap_misc.c
  ${BOOT_DIR}/bootutil/src/swap_scratch.c
  ${BOOT_DIR}/bootutil/src/swap_move.c
  ${BOOT_DIR}/bootutil/src/bootutil_misc.c
  ${BOOT_DIR}/bootutil/src/image_validate.c
  ${BOOT_DIR}/bootutil/src/encrypted.c
+13 −0
Changes for boot/zephyr/Kconfig: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -126,6 +126,19 @@ config BOOT_UPGRADE_ONLY
	  of swapping them. This prevents the fallback recovery, but
	  uses a much simpler code path.

config BOOT_SWAP_USING_MOVE
	bool "Swap mode that can run without a scratch partition [EXPERIMENTAL]"
	default n
	help
	  If y, the swap upgrade is done in two steps, where first every
	  sector of the primary slot is moved up one sector, then for
	  each sector X in the secondary slot, it is moved to index X in
	  the primary slot, then the sector at X+1 in the primary is
	  moved to index X in the secondary.
	  This allows a swap upgrade without using a scratch partition,
	  but is currently limited to all sectors in both slots being of
	  the same size.

config BOOT_BOOTSTRAP
	bool "Bootstrap erased the primary slot from the secondary slot"
	default n
+2 −0
Changes for boot/zephyr/flash_map_extended.c: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -58,7 +58,9 @@ int flash_area_id_from_multi_image_slot(int image_index, int slot)
    switch (slot) {
    case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
    case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
#if !defined(CONFIG_BOOT_SWAP_USING_MOVE)
    case 2: return FLASH_AREA_IMAGE_SCRATCH;
#endif
    }

    return -EINVAL; /* flash_area_open will fail on that */
+4 −0
Changes for boot/zephyr/include/mcuboot_config/mcuboot_config.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
+2 −0
Changes for boot/zephyr/include/sysflash/sysflash.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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__ */
Loading