Build: Combine compile time MCUBoot switches
Remove multiple compile time MCUBoot switches and combine their
functionality into the 'MCUBOOT_UPGRADE_STRATEGY' switch.
Change-Id: Ibed68983ca0e2ed3c291d56514e8ad93ac0dbeba
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 8f24174..9d35638 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -9,8 +9,6 @@
message(FATAL_ERROR "ERROR: Incomplete Configuration: REGRESSION not defined, Include this file from a Config*.cmake")
elseif(NOT DEFINED CORE_TEST)
message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_TEST not defined, Include this file from a Config*.cmake")
-elseif(NOT DEFINED BL2)
- message(FATAL_ERROR "ERROR: Incomplete Configuration: BL2 not defined, Include this file from a Config*.cmake")
elseif(NOT DEFINED TFM_LVL)
message(FATAL_ERROR "ERROR: Incomplete Configuration: TFM_LVL not defined, Include this file from a Config*.cmake")
endif()
@@ -21,6 +19,17 @@
message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.")
endif()
+#BL2 bootloader (MCUBoot) related settings
+if(NOT DEFINED BL2)
+ set(BL2 True CACHE BOOL "Configure TF-M to use BL2 and enable building BL2")
+endif()
+if (BL2)
+ if (NOT DEFINED MCUBOOT_UPGRADE_STRATEGY)
+ set (MCUBOOT_UPGRADE_STRATEGY "SWAP" CACHE STRING "Configure BL2 which upgrade strategy to use")
+ set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP;NO_SWAP;RAM_LOADING")
+ endif()
+endif()
+
set(BUILD_CMSIS_CORE Off)
set(BUILD_RETARGET Off)
set(BUILD_NATIVE_DRIVERS Off)
@@ -217,15 +226,19 @@
if (BL2)
add_definitions(-DBL2)
- if (MCUBOOT_NO_SWAP)
+ if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "OVERWRITE_ONLY" AND
+ NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "SWAP" AND
+ NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" AND
+ NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
+ message(FATAL_ERROR "ERROR: MCUBoot supports OVERWRITE_ONLY, SWAP, NO_SWAP and RAM_LOADING upgrade strategies only.")
+ endif()
+ if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP")
set(LINK_TO_BOTH_MEMORY_REGION ON)
endif()
- if (MCUBOOT_NO_SWAP AND MCUBOOT_RAM_LOADING)
- message (FATAL_ERROR "Bootloader: MCUBOOT_RAM_LOADING and MCUBOOT_NO_SWAP are not supported together")
- endif()
-else()
- if (MCUBOOT_NO_SWAP)
- message (FATAL_ERROR "Bootloader build is turned off, not possible to specify bootloader behavior")
+else() #BL2 is turned off
+ if (DEFINED MCUBOOT_UPGRADE_STRATEGY)
+ message (WARNING "Ignoring value of MCUBOOT_UPGRADE_STRATEGY as BL2 option is set to False.")
+ unset (MCUBOOT_UPGRADE_STRATEGY)
endif()
endif()