Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Andrei Narkevitch | b0be461 | 2020-01-27 17:26:19 -0800 | [diff] [blame] | 2 | # Copyright (c) 2018-2020, Arm Limited. All rights reserved. |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #This file gathers all MPS2/AN519 specific files in the application. |
| 9 | |
| 10 | #MPS2/AN519 has a Cortex M23 CPU. |
| 11 | include("Common/CpuM23") |
| 12 | |
| 13 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 14 | |
| 15 | #Specify the location of platform specific build dependencies. |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 16 | if(COMPILER STREQUAL "ARMCLANG") |
Miklos Balint | 8fb9100 | 2019-05-24 14:17:44 +0200 | [diff] [blame] | 17 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct") |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 18 | set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_bl2.sct") |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 19 | set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_ns.sct") |
| 20 | if (DEFINED CMSIS_5_DIR) |
| 21 | # not all project defines CMSIS_5_DIR, only the ones that use it. |
| 22 | set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib") |
| 23 | endif() |
| 24 | elseif(COMPILER STREQUAL "GNUARM") |
Miklos Balint | 8fb9100 | 2019-05-24 14:17:44 +0200 | [diff] [blame] | 25 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld") |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 26 | set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_bl2.ld") |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 27 | set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_ns.ld") |
| 28 | if (DEFINED CMSIS_5_DIR) |
| 29 | # not all project defines CMSIS_5_DIR, only the ones that use it. |
| 30 | set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MBN.a") |
| 31 | endif() |
| 32 | else() |
| 33 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 34 | endif() |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 35 | set (FLASH_LAYOUT "${PLATFORM_DIR}/target/mps2/an519/partition/flash_layout.h") |
| 36 | set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/mps2/an519/partition/") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 37 | |
| 38 | if (BL2) |
| 39 | set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME}) |
David Vincze | 4638b2a | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 40 | if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING") |
| 41 | message(FATAL_ERROR "ERROR: RAM_LOADING upgrade strategy is not supported on target '${TARGET_PLATFORM}'.") |
| 42 | endif() |
David Hu | 086ffe3 | 2019-12-06 10:36:56 +0800 | [diff] [blame] | 43 | #FixMe: MCUBOOT_SIGN_RSA_LEN can be removed when ROTPK won't be hard coded in platform/ext/common/template/tfm_rotpk.c |
Tamas Ban | 5db5753 | 2019-07-17 10:59:02 +0100 | [diff] [blame] | 44 | # instead independently loaded from secure code as a blob. |
| 45 | if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048") |
| 46 | add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048) |
| 47 | endif() |
| 48 | if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072") |
| 49 | add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072) |
| 50 | endif() |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 51 | endif() |
| 52 | |
| 53 | embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE) |
| 54 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2" ABSOLUTE) |
| 55 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519" ABSOLUTE) |
| 56 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_core" ABSOLUTE) |
| 57 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/retarget" ABSOLUTE) |
| 58 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers" ABSOLUTE) |
| 59 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/partition" ABSOLUTE) |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 60 | embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE) |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 61 | |
| 62 | #Gather all source files we need. |
| 63 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 64 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 65 | elseif(BUILD_CMSIS_CORE) |
| 66 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_core/system_cmsdk_mps2_an519.c") |
| 67 | endif() |
| 68 | |
| 69 | if (NOT DEFINED BUILD_RETARGET) |
| 70 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 71 | elseif(BUILD_RETARGET) |
| 72 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/retarget/platform_retarget_dev.c") |
| 73 | endif() |
| 74 | |
| 75 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 76 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 77 | elseif(BUILD_UART_STDOUT) |
Miklos Balint | 6cbeba6 | 2018-04-12 17:31:34 +0200 | [diff] [blame] | 78 | if (NOT DEFINED SECURE_UART1) |
| 79 | message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!") |
| 80 | elseif(SECURE_UART1) |
| 81 | add_definitions(-DSECURE_UART1) |
| 82 | endif() |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 83 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c") |
| 84 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 85 | set(BUILD_NATIVE_DRIVERS true) |
| 86 | set(BUILD_CMSIS_DRIVERS true) |
| 87 | endif() |
| 88 | |
| 89 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 90 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 91 | elseif(BUILD_NATIVE_DRIVERS) |
| 92 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/arm_uart_drv.c") |
| 93 | |
| 94 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpc_sie200_drv.c" |
| 95 | "${PLATFORM_DIR}/target/mps2/an519/native_drivers/ppc_sse200_drv.c" |
| 96 | ) |
| 97 | endif() |
| 98 | |
| 99 | if (NOT DEFINED BUILD_TIME) |
| 100 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 101 | elseif(BUILD_TIME) |
| 102 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk/timer_cmsdk.c") |
| 103 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk" ABSOLUTE) |
| 104 | endif() |
| 105 | |
| 106 | if (NOT DEFINED BUILD_STARTUP) |
| 107 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 108 | elseif(BUILD_STARTUP) |
| 109 | if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG") |
| 110 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_s.s") |
| 111 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_ns.s") |
| 112 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_bl2.s") |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 113 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM") |
| 114 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_s.S") |
| 115 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_ns.S") |
| 116 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_bl2.S") |
| 117 | set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND |
| 118 | PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 119 | else() |
| 120 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 121 | endif() |
| 122 | endif() |
| 123 | |
| 124 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 125 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 126 | elseif(BUILD_TARGET_CFG) |
| 127 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/target_cfg.c") |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 128 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/spm_hal.c") |
David Hu | a6ceeb6 | 2019-12-05 17:48:05 +0800 | [diff] [blame] | 129 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c") |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 130 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpu_armv8m_drv.c") |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 131 | if (TFM_PARTITION_PLATFORM) |
Miklos Balint | c7b1b6c | 2019-04-24 12:38:36 +0200 | [diff] [blame] | 132 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/services/src/tfm_platform_system.c") |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 133 | endif() |
Andrei Narkevitch | 5bba54c | 2019-09-23 14:09:13 -0700 | [diff] [blame] | 134 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c") |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 135 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 136 | endif() |
| 137 | |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 138 | if (NOT DEFINED BUILD_PLAT_TEST) |
| 139 | message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!") |
| 140 | elseif(BUILD_PLAT_TEST) |
Mate Toth-Pal | a9f8e9e | 2019-03-05 16:11:14 +0100 | [diff] [blame] | 141 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/plat_test.c") |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 142 | endif() |
| 143 | |
Tamas Ban | d4bf347 | 2019-09-06 12:59:56 +0100 | [diff] [blame] | 144 | if (NOT DEFINED BUILD_BOOT_HAL) |
| 145 | message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!") |
| 146 | elseif(BUILD_BOOT_HAL) |
Andrei Narkevitch | b0be461 | 2020-01-27 17:26:19 -0800 | [diff] [blame] | 147 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c") |
Tamas Ban | d4bf347 | 2019-09-06 12:59:56 +0100 | [diff] [blame] | 148 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/boot_hal.c") |
| 149 | endif() |
| 150 | |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 151 | if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS) |
| 152 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!") |
| 153 | elseif(BUILD_TARGET_HARDWARE_KEYS) |
David Hu | b3d2d62 | 2019-12-06 10:24:44 +0800 | [diff] [blame] | 154 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c") |
David Hu | 086ffe3 | 2019-12-06 10:36:56 +0800 | [diff] [blame] | 155 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c") |
David Hu | 31c574dc | 2019-12-05 18:25:44 +0800 | [diff] [blame] | 156 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 157 | endif() |
| 158 | |
Marc Moreno Berengue | b2c17ae | 2018-08-10 15:47:42 +0100 | [diff] [blame] | 159 | if (NOT DEFINED BUILD_TARGET_NV_COUNTERS) |
| 160 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!") |
| 161 | elseif(BUILD_TARGET_NV_COUNTERS) |
| 162 | # NOTE: This non-volatile counters implementation is a dummy |
| 163 | # implementation. Platform vendors have to implement the |
| 164 | # API ONLY if the target has non-volatile counters. |
David Hu | 2fa0738 | 2019-12-06 10:09:28 +0800 | [diff] [blame] | 165 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c") |
Marc Moreno Berengue | b2c17ae | 2018-08-10 15:47:42 +0100 | [diff] [blame] | 166 | set(TARGET_NV_COUNTERS_ENABLE ON) |
Marc Moreno Berengue | 184d203 | 2018-08-14 12:51:43 +0100 | [diff] [blame] | 167 | # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services |
| 168 | # rollback protection code as the target supports nv counters. |
| 169 | set (SST_ROLLBACK_PROTECTION ON) |
Marc Moreno Berengue | b2c17ae | 2018-08-10 15:47:42 +0100 | [diff] [blame] | 170 | endif() |
| 171 | |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 172 | if (NOT DEFINED BUILD_CMSIS_DRIVERS) |
| 173 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!") |
| 174 | elseif(BUILD_CMSIS_DRIVERS) |
| 175 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_MPC.c" |
| 176 | "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_PPC.c") |
| 177 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_USART.c") |
| 178 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE) |
| 179 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 180 | endif() |
| 181 | |
| 182 | if (NOT DEFINED BUILD_FLASH) |
| 183 | message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!") |
| 184 | elseif(BUILD_FLASH) |
Tamas Ban | c382885 | 2018-02-01 12:24:16 +0000 | [diff] [blame] | 185 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_Flash.c") |
Marc Moreno Berengue | 792fc68 | 2018-02-20 11:53:30 +0000 | [diff] [blame] | 186 | # There is no real flash memory for code on MPS2 board. Instead a code SRAM is |
| 187 | # used for code storage: ZBT SSRAM1. The Driver_Flash driver just emulates a flash |
| 188 | # interface and behaviour on top of the SRAM memory. |
Marc Moreno Berengue | 95d6572 | 2018-07-26 17:24:02 +0100 | [diff] [blame] | 189 | # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT |
| 190 | # to be sure the SST service knows that when it starts the SST area does not contain any |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 191 | # valid SST flash layout and it needs to create one. The same for ITS. |
Marc Moreno Berengue | 95d6572 | 2018-07-26 17:24:02 +0100 | [diff] [blame] | 192 | set(SST_CREATE_FLASH_LAYOUT ON) |
Marc Moreno Berengue | 02a2344 | 2018-08-15 14:28:45 +0100 | [diff] [blame] | 193 | set(SST_RAM_FS OFF) |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 194 | set(ITS_CREATE_FLASH_LAYOUT ON) |
| 195 | set(ITS_RAM_FS OFF) |
Tamas Ban | c382885 | 2018-02-01 12:24:16 +0000 | [diff] [blame] | 196 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE) |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 197 | endif() |