1#------------------------------------------------------------------------------- 2# Copyright (c) 2020-2024, Arm Limited. All rights reserved. 3# Copyright (c) 2020, Linaro. All rights reserved. 4# Copyright 2021-2024 NXP. All rights reserved. 5# 6# SPDX-License-Identifier: BSD-3-Clause 7# 8#------------------------------------------------------------------------------- 9 10cmake_policy(SET CMP0076 NEW) 11 12set(NXP_COMMON_DIR ${CMAKE_CURRENT_LIST_DIR}/../common) 13 14# Pull drivers from NXP git 15if (TFM_PLATFORM_NXP_HAL_FILE_PATH STREQUAL "DOWNLOAD") 16 set(NXP_HAL_FILE_PATH ${PLATFORM_DIR}/ext/target/nxp) 17 Message("-- Pulling MCUxpresso NXP SDK drivers from "${NXP_SDK_GIT_REP}/${NXP_SDK_GIT_TAG}) 18 include(pull_drivers.cmake) 19# Use specified path to NXP hal folder provided by user 20else() 21 set(NXP_HAL_FILE_PATH ${TFM_PLATFORM_NXP_HAL_FILE_PATH}) 22endif() 23 24set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) 25 26string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER) 27if (BL2 AND ${BUILD_TYPE_LOWER} STREQUAL "debug") 28 Message(FATAL_ERROR "If BL2 is enabled, \"${CMAKE_BUILD_TYPE}\" build type cannot be selected as it is currently not \ 29 supported on ${TFM_PLATFORM}. For more information please refer to the platform's README file.") 30endif() 31 32#========================= Platform region defs ===============================# 33 34target_include_directories(platform_region_defs 35 INTERFACE 36 partition 37) 38 39#========================= Platform common defs ===============================# 40 41# Specify the location of platform specific build dependencies. 42target_sources(tfm_s 43 PRIVATE 44 ${CMAKE_CURRENT_SOURCE_DIR}/Device/Source/startup_lpcxpresso55s69.c 45) 46target_add_scatter_file(tfm_s 47 $<$<C_COMPILER_ID:ARMClang>:${PLATFORM_DIR}/ext/common/armclang/tfm_common_s.sct> 48 $<$<C_COMPILER_ID:GNU>:${PLATFORM_DIR}/ext/common/gcc/tfm_common_s.ld> 49 $<$<C_COMPILER_ID:IAR>:${PLATFORM_DIR}/ext/common/iar/tfm_common_s.icf> 50) 51 52if(BL2) 53 target_sources(bl2 54 PRIVATE 55 ${CMAKE_CURRENT_SOURCE_DIR}/Device/Source/startup_lpcxpresso55s69.c 56 ) 57 target_add_scatter_file(bl2 58 $<$<C_COMPILER_ID:ARMClang>:${PLATFORM_DIR}/ext/common/armclang/tfm_common_bl2.sct> 59 $<$<C_COMPILER_ID:GNU>:${PLATFORM_DIR}/ext/common/gcc/tfm_common_bl2.ld> 60 $<$<C_COMPILER_ID:IAR>:${PLATFORM_DIR}/ext/common/iar/tfm_common_bl2.icf> 61 ) 62endif() 63 64#========================= Platform Secure ====================================# 65 66target_include_directories(platform_s 67 PUBLIC 68 . 69 Device/Include 70 project_template/s 71 partition 72 ../../arm/drivers/mpu/armv8m 73 ${PLATFORM_DIR}/ext/target/nxp/common 74 ${PLATFORM_DIR}/ext/target/nxp/common/CMSIS_Driver 75 ${PLATFORM_DIR}/ext/target/nxp/common/Device/Config 76 ${PLATFORM_DIR}/ext/target/nxp/common/Device/Include 77 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver 78 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers 79 ${NXP_HAL_FILE_PATH}/common/Native_Driver 80 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers 81 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/lists 82 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/serial_manager 83 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/uart 84 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/debug_console 85 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/str 86) 87 88target_sources(platform_s 89 INTERFACE 90 $<$<STREQUAL:"${TFM_FIH_PROFILE}","HIGH">:${PLATFORM_DIR}/ext/common/template/tfm_fih_rng.c> 91 PRIVATE 92 ${NXP_COMMON_DIR}/CMSIS_Driver/Driver_Flash_iap1.c 93 ${NXP_COMMON_DIR}/CMSIS_Driver/Driver_USART.c 94 ../../arm/drivers/mpu/armv8m/mpu_armv8m_drv.c 95 project_template/s/board.c 96 project_template/s/clock_config.c 97 project_template/s/pin_mux.c 98 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/system_LPC55S69_cm33_core0.c 99 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers/fsl_clock.c 100 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers/fsl_power.c 101 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers/fsl_reset.c 102 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/lists/fsl_component_generic_list.c 103 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/serial_manager/fsl_component_serial_manager.c 104 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/serial_manager/fsl_component_serial_port_uart.c 105 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/uart/fsl_adapter_usart.c 106 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_common.c 107 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_common_arm.c 108 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_ctimer.c 109 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_flexcomm.c 110 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_gpio.c 111 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_iap.c 112 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_usart.c 113 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/fsl_assert.c 114 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/debug_console/fsl_debug_console.c 115 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/str/fsl_str.c 116 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${PLATFORM_DIR}/ext/target/nxp/common/plat_test.c> 117 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${PLATFORM_DIR}/ext/target/nxp/common/services/src/tfm_platform_system.c> 118) 119 120target_link_libraries(platform_s 121 PRIVATE 122 # For attest HAL strnlen 123 tfm_sprt 124) 125 126target_compile_options(platform_s 127 PUBLIC 128 ${COMPILER_CMSE_FLAG} 129) 130 131# GNU ld has some strange behaviour to do with weak functions, and does not deal 132# well with strong functions in static libraries overriding weak functions in 133# object files. For this reason, the file hardware_init is linked directly to 134# the s binary as an object file. This issue does not affect armclang, but the 135# fix is compatible. 136target_sources(tfm_s 137 PRIVATE 138 project_template/s/hardware_init.c 139) 140 141#========================= Platform BL2 =======================================# 142if(BL2) 143 144 target_include_directories(platform_bl2 145 PUBLIC 146 partition 147 Device/Include 148 project_template/bl2 149 ${PLATFORM_DIR}/ext/target/nxp/common 150 ${PLATFORM_DIR}/ext/target/nxp/common/Device/Include 151 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver 152 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers 153 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers 154 PRIVATE 155 . 156 ${PLATFORM_DIR}/ext/target/nxp/common/Device/Config 157 ${PLATFORM_DIR}/ext/target/nxp/common/Device/Include 158 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/serial_manager 159 ${NXP_HAL_FILE_PATH}/common/Native_Driver 160 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/uart 161 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/debug_console 162 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/str 163 ) 164 target_sources(platform_bl2 165 PRIVATE 166 project_template/bl2/board.c 167 project_template/bl2/clock_config.c 168 project_template/bl2/pin_mux.c 169 ${NXP_COMMON_DIR}/CMSIS_Driver/Driver_Flash_iap1.c 170 ${NXP_COMMON_DIR}/CMSIS_Driver/Driver_USART.c 171 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/system_LPC55S69_cm33_core0.c 172 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers/fsl_clock.c 173 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers/fsl_power.c 174 ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver/drivers/fsl_reset.c 175 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/serial_manager/fsl_component_serial_manager.c 176 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/serial_manager/fsl_component_serial_port_uart.c 177 ${NXP_HAL_FILE_PATH}/common/Native_Driver/components/uart/fsl_adapter_usart.c 178 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_common.c 179 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_common_arm.c 180 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_flexcomm.c 181 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_iap.c 182 ${NXP_HAL_FILE_PATH}/common/Native_Driver/drivers/fsl_usart.c 183 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/fsl_assert.c 184 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/debug_console/fsl_debug_console.c 185 ${NXP_HAL_FILE_PATH}/common/Native_Driver/utilities/str/fsl_str.c 186 ) 187 188 # GNU ld has some strange behaviour to do with weak functions, and does not deal 189 # well with strong functions in static libraries overriding weak functions in 190 # object files. For this reason, the file hardware_init is linked directly to 191 # the s binary as an object file. This issue does not affect armclang, but the 192 # fix is compatible. 193 target_sources(bl2 194 PRIVATE 195 project_template/bl2/hardware_init.c 196 ) 197endif() 198 199#========================= tfm_spm ============================================# 200 201target_sources(tfm_spm 202 PRIVATE 203 target_cfg.c 204 ${NXP_COMMON_DIR}/tfm_hal_isolation.c 205 ${NXP_COMMON_DIR}/tfm_hal_platform.c 206) 207 208# If this is not added to the tfm_s it will not correctly override the weak 209# default handlers declared in assemebly, and will instead be discarded as they 210# are not in use. 211target_sources(tfm_s 212 PRIVATE 213 ${NXP_COMMON_DIR}/mpc_ppc_faults.c 214) 215 216#========================= Files for building NS side platform ================# 217 218install(FILES ${TARGET_PLATFORM_PATH}/project_template/ns/board.c 219 ${TARGET_PLATFORM_PATH}/project_template/ns/hardware_init.c 220 ${TARGET_PLATFORM_PATH}/project_template/ns/clock_config.c 221 ${TARGET_PLATFORM_PATH}/project_template/ns/pin_mux.c 222 ${NXP_COMMON_DIR}/CMSIS_Driver/Driver_USART.c 223 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${PLATFORM_DIR}/ext/target/nxp/common/plat_test.c> 224 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 225 226install(DIRECTORY ${NXP_COMMON_DIR}/Device 227 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 228 229install(DIRECTORY ${TARGET_PLATFORM_PATH}/Device 230 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 231 232install(DIRECTORY ${NXP_HAL_FILE_PATH}/lpcxpresso55s69/Native_Driver 233 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 234 235install(DIRECTORY ${NXP_HAL_FILE_PATH}/common/Native_Driver 236 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 237 238install(FILES ${PLATFORM_DIR}/ext/driver/Driver_Common.h 239 ${PLATFORM_DIR}/ext/driver/Driver_Flash.h 240 ${PLATFORM_DIR}/ext/driver/Driver_USART.h 241 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/ext/driver) 242 243install(FILES ${TARGET_PLATFORM_PATH}/project_template/ns/app.h 244 ${TARGET_PLATFORM_PATH}/project_template/ns/board.h 245 ${TARGET_PLATFORM_PATH}/project_template/ns/clock_config.h 246 ${TARGET_PLATFORM_PATH}/project_template/ns/pin_mux.h 247 ${TARGET_PLATFORM_PATH}/config_tfm_target.h 248 ${TARGET_PLATFORM_PATH}/target_cfg.h 249 ${TARGET_PLATFORM_PATH}/tfm_peripherals_def.h 250 ${NXP_COMMON_DIR}/target_cfg_common.h 251 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/include) 252 253install(DIRECTORY ${TARGET_PLATFORM_PATH}/partition 254 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 255 256install(FILES ${PLATFORM_DIR}/ext/common/gcc/tfm_common_ns.ld 257 ${PLATFORM_DIR}/ext/common/armclang/tfm_common_ns.sct 258 ${PLATFORM_DIR}/ext/common/iar/tfm_common_ns.icf 259 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/linker_scripts) 260 261# copy all files from active platform directory 262install(DIRECTORY ${TARGET_PLATFORM_PATH}/ns/ 263 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 264 265install(FILES ${TARGET_PLATFORM_PATH}/cpuarch.cmake 266 ${TARGET_PLATFORM_PATH}/config.cmake 267 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 268