Build: Check MCUboot strategy configuration
Validate the value of the MCUBOOT_UPGRADE_STRATEGY variable and
set the accepted values for its cache entry.
It helps to avoid misconfiguration which can remain hidden.
Remove unused UPGRADE_STRATEGY string variable and unnecessary check.
Change-Id: I6b8529dafe51cbaf2b26a5ac56a710c9687812ae
Signed-off-by: David Vincze <david.vincze@linaro.org>
diff --git a/config/check_config.cmake b/config/check_config.cmake
index 502642a..d72154b 100644
--- a/config/check_config.cmake
+++ b/config/check_config.cmake
@@ -46,3 +46,9 @@
tfm_invalid_config(CRYPTO_HW_ACCELERATOR_OTP_STATE AND NOT CRYPTO_HW_ACCELERATOR)
tfm_invalid_config(CRYPTO_HW_ACCELERATOR_OTP_STATE AND NOT (CRYPTO_HW_ACCELERATOR_OTP_STATE STREQUAL "ENABLED" OR CRYPTO_HW_ACCELERATOR_OTP_STATE STREQUAL "PROVISIONING"))
+
+########################## BL2 #################################################
+
+get_property(MCUBOOT_STRATEGY_LIST CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS)
+tfm_invalid_config(NOT MCUBOOT_UPGRADE_STRATEGY IN_LIST MCUBOOT_STRATEGY_LIST)
+
diff --git a/config/config_default.cmake b/config/config_default.cmake
index ade7c35..73edfd0 100644
--- a/config/config_default.cmake
+++ b/config/config_default.cmake
@@ -34,7 +34,7 @@
set(MCUBOOT_EXECUTION_SLOT 1 CACHE STRING "Slot from which to execute the image, used for XIP mode")
set(MCUBOOT_LOG_LEVEL "INFO" CACHE STRING "Level of logging to use for MCUboot [OFF, ERROR, WARNING, INFO, DEBUG]")
set(MCUBOOT_HW_KEY ON CACHE BOOL "Whether to embed the entire public key in the image metadata instead of the hash only")
-set(MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Upgrade strategy for images [OVERWRITE_ONLY, SWAP, DIRECT_XIP, RAM_LOAD]")
+set(MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Upgrade strategy for images")
set(MCUBOOT_MEASURED_BOOT ON CACHE BOOL "Add boot measurement values to boot status. Used for initial attestation token")
set(MCUBOOT_HW_ROLLBACK_PROT ON CACHE BOOL "Enable security counter validation against non-volatile HW counters")
set(MCUBOOT_ENC_IMAGES OFF CACHE BOOL "Enable encrypted image upgrade support")
@@ -149,3 +149,13 @@
set(PSA_ARCH_TESTS_PATH "DOWNLOAD" CACHE PATH "Path to PSA arch tests (or DOWNLOAD to fetch automatically")
set(PSA_ARCH_TESTS_VERSION "90c8e680" CACHE STRING "The version of PSA arch tests to use")
+
+################################################################################
+################################################################################
+
+# Specifying the accepted values for certain configuration options to facilitate
+# their later validation.
+
+########################## BL2 #################################################
+
+set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP;DIRECT_XIP;RAM_LOAD")
diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt
index f73bd9d..37ce6e5 100755
--- a/platform/CMakeLists.txt
+++ b/platform/CMakeLists.txt
@@ -129,12 +129,6 @@
tfm_arch
)
- if (NOT DEFINED MCUBOOT_UPGRADE_STRATEGY)
- message(FATAL_ERROR "MCUBOOT_UPGRADE_STRATEGY is undefined")
- else()
- string(CONCAT UPGRADE_STRATEGY "MCUBOOT_" ${MCUBOOT_UPGRADE_STRATEGY})
- endif()
-
target_compile_definitions(platform_bl2
PUBLIC
BL2