Twincpu: Add preprocessor option and configuration TFM_MULTI_CORE_TOPOLOGY
Twincpu is a system that runs SPE and NSPE on two separate
CPU cores. It assumes secure and non-secure code to be built
independently with different CPU configurations.
Use preprocessor option TFM_MULTI_CORE_TOPOLOGY to skip unnecessary
operations in multi-core scenario.
Add configuration TFM_MULTI_CORE_TOPOLOGY to skip unnecessary
files, definitions or sections during building.
Change-Id: Ib94908c17d9ce80a33f0f1a33d9bd086bd16c751
Signed-off-by: David Hu <david.hu@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 47b53f3..f08a355 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -56,6 +56,17 @@
include(${PLATFORM_CMAKE_FILE})
endif()
+if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
+ # CMSE is unnecessary in multi-core scenarios.
+ # TODO: Need further discussion about if CMSE is required when an Armv8-M
+ # core acts as secure core in multi-core scenario.
+ set (CMSE_FLAGS "")
+ set (ARM_FEATURE_CMSE 0)
+else()
+ set (CMSE_FLAGS "-mcmse")
+ set (ARM_FEATURE_CMSE 3)
+endif()
+
if(${COMPILER} STREQUAL "ARMCLANG")
#Use any ARMCLANG version found on PATH. Note: Only versions supported by the
#build system will work. A file cmake/Common/CompilerArmClangXY.cmake
@@ -63,7 +74,7 @@
include("Common/FindArmClang")
include("Common/${ARMCLANG_MODULE}")
- set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse -ffunction-sections -fdata-sections)
+ set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none ${CMSE_FLAGS} -ffunction-sections -fdata-sections)
##Shared compiler settings.
function(config_setting_shared_compiler_flags tgt)
embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror)
@@ -80,7 +91,7 @@
include("Common/FindGNUARM")
include("Common/${GNUARM_MODULE}")
- set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse -ffunction-sections -fdata-sections --specs=nano.specs)
+ set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float ${CMSE_FLAGS} -ffunction-sections -fdata-sections --specs=nano.specs)
##Shared compiler and linker settings.
function(config_setting_shared_compiler_flags tgt)
embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror -Wno-format -Wno-return-type -Wno-unused-but-set-variable)
@@ -269,7 +280,7 @@
endif()
##Set Mbed TLS compiler flags and variables for audit log and crypto
-set(MBEDTLS_C_FLAGS_SERVICES "-D__ARM_FEATURE_CMSE=3 -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -I${CMAKE_CURRENT_LIST_DIR}/platform/ext/common")
+set(MBEDTLS_C_FLAGS_SERVICES "-D__ARM_FEATURE_CMSE=${ARM_FEATURE_CMSE} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -I${CMAKE_CURRENT_LIST_DIR}/platform/ext/common")
#Default TF-M secure storage flags.
#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
@@ -311,7 +322,7 @@
endif()
##Set mbedTLS compiler flags for BL2 bootloader
-set(MBEDTLS_C_FLAGS_BL2 "-D__ARM_FEATURE_CMSE=3 -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-boot.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/include")
+set(MBEDTLS_C_FLAGS_BL2 "-D__ARM_FEATURE_CMSE=${ARM_FEATURE_CMSE} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-boot.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/include")
if (MCUBOOT_SIGNATURE_TYPE STREQUAL "RSA-3072")
string(APPEND MBEDTLS_C_FLAGS_BL2 " -DMCUBOOT_SIGN_RSA_LEN=3072")
endif()