Bence Kaposzta | 9076e82 | 2019-10-08 09:44:17 +0200 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | # This file gathers all Musca-S1 specific files in the application. |
| 9 | |
| 10 | # Musca-S1 has a Cortex-M33 CPU. |
| 11 | include("Common/CpuM33") |
| 12 | |
| 13 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 14 | |
| 15 | # Specify the location of platform specific build dependencies. |
| 16 | if (COMPILER STREQUAL "ARMCLANG") |
| 17 | set(S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct") |
| 18 | set(BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/musca_bl2.sct") |
| 19 | set(NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/musca_ns.sct") |
| 20 | if (DEFINED CMSIS_5_DIR) |
| 21 | # Not all projects define CMSIS_5_DIR, only the ones that use it. |
| 22 | set(RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib") |
| 23 | endif() |
| 24 | elseif (COMPILER STREQUAL "GNUARM") |
| 25 | set(S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld") |
| 26 | set(BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/musca_bl2.ld") |
| 27 | set(NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/musca_ns.ld") |
| 28 | if (DEFINED CMSIS_5_DIR) |
| 29 | # Not all projects define CMSIS_5_DIR, only the ones that use it. |
| 30 | set(RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a") |
| 31 | endif() |
| 32 | else() |
| 33 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 34 | endif() |
| 35 | set(FLASH_LAYOUT "${PLATFORM_DIR}/target/musca_s1/partition/flash_layout.h") |
| 36 | set(PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/musca_s1/partition") |
| 37 | |
| 38 | if (BL2) |
| 39 | set(BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME}) |
| 40 | if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP") |
| 41 | message(WARNING "NO_SWAP upgrade strategy is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.") |
| 42 | mcuboot_override_upgrade_strategy("NO_SWAP") |
| 43 | endif() |
| 44 | |
| 45 | #FixMe: MCUBOOT_SIGN_RSA_LEN can be removed when ROTPK won't be hard coded in platform/ext/common/tfm_rotpk.c |
| 46 | # instead independently loaded from secure code as a blob. |
| 47 | if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048") |
| 48 | add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048) |
| 49 | endif() |
| 50 | if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072") |
| 51 | add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072) |
| 52 | endif() |
| 53 | endif() |
| 54 | |
| 55 | embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE) |
| 56 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1" ABSOLUTE) |
| 57 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Config" ABSOLUTE) |
| 58 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Device/Config" ABSOLUTE) |
| 59 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Device/Include" ABSOLUTE) |
| 60 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Native_Driver" ABSOLUTE) |
| 61 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/partition" ABSOLUTE) |
| 62 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/services/include" ABSOLUTE) |
| 63 | embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE) |
| 64 | |
| 65 | # Gather all source files we need. |
| 66 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 67 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 68 | elseif (BUILD_CMSIS_CORE) |
| 69 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Device/Source/system_core_init.c") |
| 70 | endif() |
| 71 | |
| 72 | if (NOT DEFINED BUILD_RETARGET) |
| 73 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 74 | elseif (BUILD_RETARGET) |
| 75 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Device/Source/device_definition.c") |
| 76 | endif() |
| 77 | |
| 78 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 79 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 80 | elseif (BUILD_UART_STDOUT) |
| 81 | if (NOT DEFINED SECURE_UART1) |
| 82 | message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!") |
| 83 | elseif (SECURE_UART1) |
| 84 | message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!") |
| 85 | endif() |
| 86 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c") |
| 87 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 88 | set(BUILD_NATIVE_DRIVERS True) |
| 89 | set(BUILD_CMSIS_DRIVERS True) |
| 90 | endif() |
| 91 | |
| 92 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 93 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 94 | elseif (BUILD_NATIVE_DRIVERS) |
| 95 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Native_Driver/uart_pl011_drv.c") |
| 96 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/Native_Driver/mpc_sie200_drv.c") |
| 97 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Native_Driver/ppc_sse200_drv.c") |
| 98 | endif() |
| 99 | |
| 100 | if (NOT DEFINED BUILD_TIME) |
| 101 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 102 | elseif (BUILD_TIME) |
| 103 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Native_Driver/timer_cmsdk_drv.c") |
| 104 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Native_Driver" ABSOLUTE) |
| 105 | endif() |
| 106 | |
| 107 | if (NOT DEFINED BUILD_STARTUP) |
| 108 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 109 | elseif (BUILD_STARTUP) |
| 110 | if (CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG") |
| 111 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/startup_cmsdk_musca_s.s") |
| 112 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/startup_cmsdk_musca_ns.s") |
| 113 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/startup_cmsdk_musca_bl2.s") |
| 114 | elseif (CMAKE_C_COMPILER_ID STREQUAL "GNUARM") |
| 115 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/startup_cmsdk_musca_s.S") |
| 116 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/startup_cmsdk_musca_ns.S") |
| 117 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/startup_cmsdk_musca_bl2.S") |
| 118 | set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND |
| 119 | PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE") |
| 120 | else() |
| 121 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 122 | endif() |
| 123 | endif() |
| 124 | |
| 125 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 126 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 127 | elseif (BUILD_TARGET_CFG) |
| 128 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/target_cfg.c") |
| 129 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/spm_hal.c") |
David Hu | a6ceeb6 | 2019-12-05 17:48:05 +0800 | [diff] [blame^] | 130 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c") |
Bence Kaposzta | 9076e82 | 2019-10-08 09:44:17 +0200 | [diff] [blame] | 131 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/Native_Driver/mpu_armv8m_drv.c") |
| 132 | if (TFM_PARTITION_PLATFORM) |
| 133 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/services/src/tfm_platform_system.c") |
| 134 | endif() |
Andrei Narkevitch | 5bba54c | 2019-09-23 14:09:13 -0700 | [diff] [blame] | 135 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c") |
Bence Kaposzta | 9076e82 | 2019-10-08 09:44:17 +0200 | [diff] [blame] | 136 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 137 | endif() |
| 138 | |
| 139 | if (NOT DEFINED BUILD_PLAT_TEST) |
| 140 | message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!") |
| 141 | elseif(BUILD_PLAT_TEST) |
| 142 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/plat_test.c") |
| 143 | endif() |
| 144 | |
| 145 | if (NOT DEFINED BUILD_BOOT_HAL) |
| 146 | message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!") |
| 147 | elseif(BUILD_BOOT_HAL) |
| 148 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/boot_hal.c") |
| 149 | endif() |
| 150 | |
| 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) |
| 154 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_initial_attestation_key_material.c") |
| 155 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_rotpk.c") |
| 156 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_crypto_keys.c") |
| 157 | endif() |
| 158 | |
| 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. |
| 165 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_nv_counters.c") |
| 166 | set(TARGET_NV_COUNTERS_ENABLE ON) |
| 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) |
| 170 | endif() |
| 171 | |
| 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/musca_s1/CMSIS_Driver/Driver_MPC.c" |
| 176 | "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Driver_PPC.c") |
| 177 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Driver_USART.c") |
| 178 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver" 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) |
| 185 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Driver_Flash_MRAM.c") |
| 186 | # As the SST area is going to be in RAM, it is required to set |
| 187 | # SST_CREATE_FLASH_LAYOUT to be sure the SST service knows that when it |
| 188 | # starts the SST area does not contain any valid SST flash layout and it |
| 189 | # needs to create one. The same for ITS. |
| 190 | set(SST_CREATE_FLASH_LAYOUT ON) |
| 191 | set(ITS_CREATE_FLASH_LAYOUT ON) |
| 192 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver" ABSOLUTE) |
| 193 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 194 | endif() |
| 195 | |
| 196 | if (NOT DEFINED BUILD_BOOT_SEED) |
| 197 | message(FATAL_ERROR "Configuration variable BUILD_BOOT_SEED (true|false) is undefined!") |
| 198 | elseif (BUILD_BOOT_SEED) |
| 199 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_boot_seed.c") |
| 200 | endif() |
| 201 | |
| 202 | if (NOT DEFINED BUILD_DEVICE_ID) |
| 203 | message(FATAL_ERROR "Configuration variable BUILD_DEVICE_ID (true|false) is undefined!") |
| 204 | elseif (BUILD_DEVICE_ID) |
| 205 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_device_id.c") |
| 206 | endif() |