Build: Reorganize BL2 configuration in cmake
This commit moves the BL2 related configuration switches from the
CommonConfig.cmake file to a separate MCUBootConfig.cmake file to
make its maintenance easier.
Change-Id: I3869528bdbd2a5a071f3b3cc4b2782d22114b1ca
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/bl2/ext/mcuboot/CMakeLists.txt b/bl2/ext/mcuboot/CMakeLists.txt
index 3b4bf10..6f8cad8 100644
--- a/bl2/ext/mcuboot/CMakeLists.txt
+++ b/bl2/ext/mcuboot/CMakeLists.txt
@@ -129,6 +129,9 @@
#Generate binary file from axf
compiler_generate_binary_output(${PROJECT_NAME})
+message(STATUS "MCUBOOT_UPGRADE_STRATEGY is set to: '${MCUBOOT_UPGRADE_STRATEGY}'.")
+message(STATUS "MCUBOOT_SIGNATURE_TYPE is set to: '${MCUBOOT_SIGNATURE_TYPE}'.")
+
#Set macro definitions for the project.
target_compile_definitions(${PROJECT_NAME} PRIVATE
MCUBOOT_VALIDATE_SLOT0
@@ -153,7 +156,8 @@
elseif (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "SWAP")
#No compile definition needs to be specified for this upgrade strategy
else()
- message(FATAL_ERROR "ERROR: MCUBoot supports OVERWRITE_ONLY, SWAP, NO_SWAP and RAM_LOADING upgrade strategies only.")
+ get_property(_upgrade_strategies CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS)
+ message(FATAL_ERROR "ERROR: MCUBoot supports the ${_upgrade_strategies} upgrade strategies only.")
endif()
#Set install location. Keep original value to avoid overriding command line settings.
diff --git a/bl2/ext/mcuboot/MCUBoot.cmake b/bl2/ext/mcuboot/MCUBoot.cmake
index f685121..5187694 100644
--- a/bl2/ext/mcuboot/MCUBoot.cmake
+++ b/bl2/ext/mcuboot/MCUBoot.cmake
@@ -55,7 +55,7 @@
message(FATAL_ERROR "${MCUBOOT_SIGNATURE_TYPE} is not supported as firmware signing algorithm")
endif()
- if (DEFINED SECURITY_COUNTER)
+ if (SECURITY_COUNTER)
set (ADD_SECURITY_COUNTER "-s ${SECURITY_COUNTER}")
else()
set (ADD_SECURITY_COUNTER "")
diff --git a/bl2/ext/mcuboot/MCUBootConfig.cmake b/bl2/ext/mcuboot/MCUBootConfig.cmake
new file mode 100644
index 0000000..406d214
--- /dev/null
+++ b/bl2/ext/mcuboot/MCUBootConfig.cmake
@@ -0,0 +1,33 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+set(BL2 True CACHE BOOL "Configure TF-M to use BL2 and enable building BL2")
+
+if (BL2)
+ add_definitions(-DBL2)
+
+ set(MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Configure BL2 which upgrade strategy to use")
+ set_property(CACHE MCUBOOT_UPGRADE_STRATEGY PROPERTY STRINGS "OVERWRITE_ONLY;SWAP;NO_SWAP;RAM_LOADING")
+ validate_cache_value(MCUBOOT_UPGRADE_STRATEGY)
+
+ set(MCUBOOT_SIGNATURE_TYPE "RSA-3072" CACHE STRING "Algorithm used by MCUBoot to validate signatures.")
+ set_property(CACHE MCUBOOT_SIGNATURE_TYPE PROPERTY STRINGS "RSA-3072;RSA-2048")
+ validate_cache_value(MCUBOOT_SIGNATURE_TYPE)
+
+else() #BL2 is turned off
+ if (DEFINED MCUBOOT_UPGRADE_STRATEGY OR
+ DEFINED MCUBOOT_SIGNATURE_TYPE)
+ message(WARNING "Ignoring the values of MCUBOOT_* variables as BL2 option is set to False.")
+ set(MCUBOOT_UPGRADE_STRATEGY "")
+ set(MCUBOOT_SIGNATURE_TYPE "")
+ endif()
+
+ if (DEFINED SECURITY_COUNTER)
+ message(WARNING "Ignoring the value of SECURITY_COUNTER variable as BL2 option is set to False.")
+ set(SECURITY_COUNTER "")
+ endif()
+endif()