Commit a8798432 authored by Marti Bolivar's avatar Marti Bolivar Committed by Fabio Utzig
Browse files

zephyr: migrate upgrade-only to Kconfig

Handle CONFIG_BOOT_UPGRADE_ONLY in mcuboot_config.h, and switch the
release test Makefile to using an OVERLAY_CONFIG fragment.

This removes the last user of the Makefile BOOTLOADER_CONFIG variable,
so delete it as well.

Signed-off-by: default avatarMarti Bolivar <marti@opensourcefoundries.com>
parent 15c9b6f9
Loading
Loading
Loading
Loading
−20
Changes for boot/zephyr/CMakeLists.txt: 0 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -12,21 +12,6 @@ set(KCONFIG_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Kconfig)
# Configuration choices.
########################

# If CONF_UPGRADE_ONLY is set, overwrite slot0 with the upgrade image
# instead of swapping them.  This prevents the fallback recovery, but
# uses a much simpler code path.
#
# To enable "upgrade only" mode:
#
#     cmake -DCONF_UPGRADE_ONLY=YES [...]
#
# To disable "upgrade only" mode (this is the default):
#
#     cmake -DCONF_UPGRADE_ONLY=NO [...]
if (NOT DEFINED CONF_UPGRADE_ONLY)
  set(CONF_UPGRADE_ONLY NO)
endif()

# If CONF_ZEPHYR_TRY_MASS_ERASE is set (it is set by default), the
# Zephyr build system configuration attempts to force a mass erase
# before flashing. This ensures the scratch and other partitions are
@@ -70,11 +55,6 @@ endmacro()
# of simply deprecated.)
list(APPEND MCUBOOT_EXTRA_CFLAGS "-DMCUBOOT_USE_FLASH_AREA_GET_SECTORS")

# Check if we're operating in overwrite-only mode.
if(CONF_UPGRADE_ONLY STREQUAL YES)
  list (APPEND MCUBOOT_EXTRA_CFLAGS "-DMCUBOOT_OVERWRITE_ONLY" "-DMCUBOOT_OVERWRITE_ONLY_FAST")
endif()

# Add values in MCUBOOT_EXTRA_CFLAGS_STR to the Zephyr build's
# EXTRA_CFLAGS variable.
string(REPLACE ";" " " MCUBOOT_EXTRA_CFLAGS_STR "${MCUBOOT_EXTRA_CFLAGS}")
+5
Changes for boot/zephyr/include/mcuboot_config/mcuboot_config.h: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -34,6 +34,11 @@
#define MCUBOOT_VALIDATE_SLOT0
#endif

#ifdef CONFIG_BOOT_UPGRADE_ONLY
#define MCUBOOT_OVERWRITE_ONLY
#define MCUBOOT_OVERWRITE_ONLY_FAST
#endif

#endif /* !__BOOTSIM__ */

#endif /* __MCUBOOT_CONFIG_H__ */
+2 −7
Changes for samples/zephyr/Makefile: 2 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -48,10 +48,6 @@
# then revert back to the first app, since we did not mark this image
# as good.

# We can add on to the CMake configuration for the bootloader by
# setting this.
BOOTLOADER_CONFIG ?=

# Extra .conf fragments to merge into the MCUboot .config, as a
# semicolon-separated list (i.e., a CMake list).
BOOTLOADER_OVERLAY_CONFIG ?=
@@ -109,8 +105,7 @@ boot: check
	@rm -f mcuboot.bin
	(mkdir -p $(BUILD_DIR_BOOT) && \
		cd $(BUILD_DIR_BOOT) && \
		cmake $(BOOTLOADER_CONFIG) \
			-DOVERLAY_CONFIG=$(BOOTLOADER_OVERLAY_CONFIG) \
		cmake -DOVERLAY_CONFIG=$(BOOTLOADER_OVERLAY_CONFIG) \
			-G"Unix Makefiles" \
			-DBOARD=$(BOARD) \
			$(SOURCE_DIRECTORY)/../../boot/zephyr && \
@@ -215,7 +210,7 @@ test-good-ecdsa: clean
# reset: hello2 runs
test-overwrite: clean
	$(MAKE) \
		BOOTLOADER_CONFIG="-DCONF_UPGRADE_ONLY=YES" \
		BOOTLOADER_OVERLAY_CONFIG=$(PWD)/overlay-upgrade-only.conf \
		all

# Test that when configured for RSA, a wrong signature in the upgrade
+2
Changes for samples/zephyr/overlay-upgrade-only.conf: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Kconfig overlay for building in upgrade-only mode.
CONFIG_BOOT_UPGRADE_ONLY=y