blob: 6d9a0bdccb1d2fe15659758d17c56650e973f7f4 [file] [log] [blame]
Jianliang Shen7e48bef2022-10-31 16:15:36 +08001#-------------------------------------------------------------------------------
Kevin Penga2b68022023-01-13 13:54:05 +08002# Copyright (c) 2022-2023, Arm Limited. All rights reserved.
Jianliang Shen7e48bef2022-10-31 16:15:36 +08003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Kevin Pengb9c99f02022-12-07 11:23:17 +08008set(ROOT_KCONFIG ${CMAKE_SOURCE_DIR}/Kconfig)
9set(PLATFORM_KCONFIG ${TARGET_PLATFORM_PATH}/Kconfig)
Jianliang Shen7e48bef2022-10-31 16:15:36 +080010
Kevin Pengb9c99f02022-12-07 11:23:17 +080011if(TFM_PROFILE)
12 # Selecting TF-M profiles is not supported yet.
13 message(FATAL_ERROR "Selecting TF-M profiles is not supported yet in Kconfig system!")
Jianliang Shen7e48bef2022-10-31 16:15:36 +080014endif()
15
Kevin Pengb9c99f02022-12-07 11:23:17 +080016if(NOT EXISTS ${PLATFORM_KCONFIG})
17 message(WARNING "The platform does not have Kconfig file! \
18 The Kconfig system cannot get its configuration settings.
19 So it is not guaranteed that the Kconfig system works properly.")
20
21 if(EXISTS ${TARGET_PLATFORM_PATH}/config.cmake)
22 include(${TARGET_PLATFORM_PATH}/config.cmake)
23 endif()
24endif()
Jianliang Shen7e48bef2022-10-31 16:15:36 +080025
26find_package(Python3)
27
28# Call the tfm_kconfig.py
29execute_process(
30 COMMAND
31 ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/kconfig/tfm_kconfig.py
Kevin Penga2b68022023-01-13 13:54:05 +080032 -k ${ROOT_KCONFIG} -o ${CMAKE_BINARY_DIR} -u gui -p ${TARGET_PLATFORM_PATH}
Jianliang Shen7e48bef2022-10-31 16:15:36 +080033 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
34 RESULT_VARIABLE ret
35)
36
37if(NOT ret EQUAL 0)
38 message(FATAL_ERROR "Kconfig tool failed!")
39endif()
40
41# Component configs generated by tfm_kconfig.py
Kevin Pengb9c99f02022-12-07 11:23:17 +080042if(EXISTS "${CMAKE_BINARY_DIR}/project_config.h")
Jianliang Shen7e48bef2022-10-31 16:15:36 +080043 set(PROJECT_CONFIG_HEADER_FILE "${CMAKE_BINARY_DIR}/project_config.h" CACHE STRING "User defined header file for TF-M config")
44endif()
45
46# Load project cmake configs generated by tfm_kconfig.py
Kevin Pengb9c99f02022-12-07 11:23:17 +080047if(EXISTS "${CMAKE_BINARY_DIR}/project_config.cmake")
Jianliang Shen7e48bef2022-10-31 16:15:36 +080048 include("${CMAKE_BINARY_DIR}/project_config.cmake")
49endif()
Kevin Pengb9c99f02022-12-07 11:23:17 +080050
51####################################################################################################
52
53# The Kconfig system does not cover all the config options for the time being.
54# So part of them still use the CMake config system.
55
56# Load regression configs overrided by platform
57if(EXISTS ${TARGET_PLATFORM_PATH}/reg_config_override.cmake)
58 include(${TARGET_PLATFORM_PATH}/reg_config_override.cmake)
59endif()
60
61# Load build type config, setting options not already set
62if(EXISTS ${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
63 include(${CMAKE_SOURCE_DIR}/config/build_type/${CMAKE_BUILD_TYPE_LOWERCASE}.cmake)
64endif()
65
66# Load TF-M model specific default config
67# Load IPC backend config if isolation level is explicitly specified to 2/3 or IPC backend is
68# selected via build command line. Otherwise, load SFN backend config by default.
69# If a pair of invalid settings are passed via command line, it will be captured later via config
70# check.
71# Also select IPC model by default for multi-core platform unless it has already selected SFN model
72if((DEFINED TFM_ISOLATION_LEVEL AND TFM_ISOLATION_LEVEL GREATER 1) OR
73 CONFIG_TFM_SPM_BACKEND STREQUAL "IPC" OR
74 TFM_MULTI_CORE_TOPOLOGY)
75 include(config/tfm_ipc_config_default.cmake)
76else()
77 #The default backend is SFN
78 include(config/tfm_sfn_config_default.cmake)
79endif()
80
81# Load bl1 config
82if(BL1 AND PLATFORM_DEFAULT_BL1)
83 include(${CMAKE_SOURCE_DIR}/bl1/config/bl1_config_default.cmake)
84endif()
85
86# Load MCUboot specific default.cmake
87if(NOT DEFINED BL2 OR BL2)
88 include(${CMAKE_SOURCE_DIR}/bl2/ext/mcuboot/mcuboot_default_config.cmake)
89endif()
90
91# Include FWU partition configs.
92include(config/tfm_fwu_config.cmake)
93
94# Include coprocessor configs
95include(config/cp_config_default.cmake)
96
97# Load defaults, setting options not already set
98include(config/config_base.cmake)
99
100# Set secure log configs
101# It also depends on regression test config.
102include(config/tfm_secure_log.cmake)