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

zephyr: migrate slot 0 validation to Kconfig

Handle CONFIG_BOOT_VALIDATE_SLOT0 in mcuboot_config.h, and switch to
setting it with an OVERLAY_CONFIG fragment in the test Makefile.

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

# If CONF_VALIDATE_SLOT0 is set, the bootloader attempts to validate
# the signature of slot0 every boot.  This adds the signature check
# time to every boot, but can mitigate against some changes that are
# able to modify the flash image itself.
#
# To enable validation (this is the default):
#
#     cmake -DCONF_VALIDATE_SLOT0=YES [...]
#
# To disable validation:
#
#     cmake -DCONF_VALIDATE_SLOT0=NO [...]
if (NOT DEFINED CONF_VALIDATE_SLOT0)
  set(CONF_VALIDATE_SLOT0 YES)
endif()

# 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.
@@ -79,11 +63,6 @@ macro(set_conf_file)
  endif()
endmacro()

# Check if we need to validate slot 0.
if(CONF_VALIDATE_SLOT0 STREQUAL YES)
  list(APPEND MCUBOOT_EXTRA_CFLAGS "-DMCUBOOT_VALIDATE_SLOT0")
endif()

# Enabling this option uses newer flash map APIs. This saves RAM and
# avoids deprecated API usage.
#
+4
Changes for boot/zephyr/include/mcuboot_config/mcuboot_config.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -30,6 +30,10 @@
#define MCUBOOT_USE_TINYCRYPT
#endif

#ifdef CONFIG_BOOT_VALIDATE_SLOT0
#define MCUBOOT_VALIDATE_SLOT0
#endif

#endif /* !__BOOTSIM__ */

#endif /* __MCUBOOT_CONFIG_H__ */
+1 −1
Changes for samples/zephyr/Makefile: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ test-bad-ecdsa-upgrade: clean
# reset: hello1 runs
test-no-bootcheck: clean
	$(MAKE) \
		BOOTLOADER_CONFIG="-DCONF_VALIDATE_SLOT0=NO" \
		BOOTLOADER_OVERLAY_CONFIG=$(PWD)/overlay-skip-slot0-validate.conf \
		SIGNING_KEY=../../root-ec-p256.pem \
		all

+3
Changes for samples/zephyr/overlay-skip-slot0-validate.conf: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Kconfig overlay for building without validating slot 0.

# CONFIG_BOOT_VALIDATE_SLOT0 is not set