Jianliang Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Kevin Peng | a2b6802 | 2023-01-13 13:54:05 +0800 | [diff] [blame] | 2 | # Copyright (c) 2022-2023, Arm Limited. All rights reserved. |
Jianliang Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
Kevin Peng | b9c99f0 | 2022-12-07 11:23:17 +0800 | [diff] [blame^] | 8 | set(ROOT_KCONFIG ${CMAKE_SOURCE_DIR}/Kconfig) |
| 9 | set(PLATFORM_KCONFIG ${TARGET_PLATFORM_PATH}/Kconfig) |
Jianliang Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 10 | |
Kevin Peng | b9c99f0 | 2022-12-07 11:23:17 +0800 | [diff] [blame^] | 11 | if(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 Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 14 | endif() |
| 15 | |
Kevin Peng | b9c99f0 | 2022-12-07 11:23:17 +0800 | [diff] [blame^] | 16 | if(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() |
| 24 | endif() |
Jianliang Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 25 | |
| 26 | find_package(Python3) |
| 27 | |
| 28 | # Call the tfm_kconfig.py |
| 29 | execute_process( |
| 30 | COMMAND |
| 31 | ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/kconfig/tfm_kconfig.py |
Kevin Peng | a2b6802 | 2023-01-13 13:54:05 +0800 | [diff] [blame] | 32 | -k ${ROOT_KCONFIG} -o ${CMAKE_BINARY_DIR} -u gui -p ${TARGET_PLATFORM_PATH} |
Jianliang Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 33 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 34 | RESULT_VARIABLE ret |
| 35 | ) |
| 36 | |
| 37 | if(NOT ret EQUAL 0) |
| 38 | message(FATAL_ERROR "Kconfig tool failed!") |
| 39 | endif() |
| 40 | |
| 41 | # Component configs generated by tfm_kconfig.py |
Kevin Peng | b9c99f0 | 2022-12-07 11:23:17 +0800 | [diff] [blame^] | 42 | if(EXISTS "${CMAKE_BINARY_DIR}/project_config.h") |
Jianliang Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 43 | set(PROJECT_CONFIG_HEADER_FILE "${CMAKE_BINARY_DIR}/project_config.h" CACHE STRING "User defined header file for TF-M config") |
| 44 | endif() |
| 45 | |
| 46 | # Load project cmake configs generated by tfm_kconfig.py |
Kevin Peng | b9c99f0 | 2022-12-07 11:23:17 +0800 | [diff] [blame^] | 47 | if(EXISTS "${CMAKE_BINARY_DIR}/project_config.cmake") |
Jianliang Shen | 7e48bef | 2022-10-31 16:15:36 +0800 | [diff] [blame] | 48 | include("${CMAKE_BINARY_DIR}/project_config.cmake") |
| 49 | endif() |
Kevin Peng | b9c99f0 | 2022-12-07 11:23:17 +0800 | [diff] [blame^] | 50 | |
| 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 |
| 57 | if(EXISTS ${TARGET_PLATFORM_PATH}/reg_config_override.cmake) |
| 58 | include(${TARGET_PLATFORM_PATH}/reg_config_override.cmake) |
| 59 | endif() |
| 60 | |
| 61 | # Load build type config, setting options not already set |
| 62 | if(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) |
| 64 | endif() |
| 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 |
| 72 | if((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) |
| 76 | else() |
| 77 | #The default backend is SFN |
| 78 | include(config/tfm_sfn_config_default.cmake) |
| 79 | endif() |
| 80 | |
| 81 | # Load bl1 config |
| 82 | if(BL1 AND PLATFORM_DEFAULT_BL1) |
| 83 | include(${CMAKE_SOURCE_DIR}/bl1/config/bl1_config_default.cmake) |
| 84 | endif() |
| 85 | |
| 86 | # Load MCUboot specific default.cmake |
| 87 | if(NOT DEFINED BL2 OR BL2) |
| 88 | include(${CMAKE_SOURCE_DIR}/bl2/ext/mcuboot/mcuboot_default_config.cmake) |
| 89 | endif() |
| 90 | |
| 91 | # Include FWU partition configs. |
| 92 | include(config/tfm_fwu_config.cmake) |
| 93 | |
| 94 | # Include coprocessor configs |
| 95 | include(config/cp_config_default.cmake) |
| 96 | |
| 97 | # Load defaults, setting options not already set |
| 98 | include(config/config_base.cmake) |
| 99 | |
| 100 | # Set secure log configs |
| 101 | # It also depends on regression test config. |
| 102 | include(config/tfm_secure_log.cmake) |