blob: cca3debf3abda27562f9c7820db7e5be8cfb94b9 [file] [log] [blame]
Kevin Townsenda26983f2020-04-06 13:26:21 +02001#-------------------------------------------------------------------------------
2# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3# Copyright (c) 2020, Linaro. All rights reserved.
Chris Brandc47d7102020-02-20 11:12:18 -08004# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
Kevin Townsenda26983f2020-04-06 13:26:21 +02005#
6# SPDX-License-Identifier: BSD-3-Clause
7#
8#-------------------------------------------------------------------------------
9
10#This file gathers all LPCXpresso55S69 specific files in the application.
11
12# LPC55S69 has a Cortex M33 CPU.
13include("Common/CpuM33")
14
15set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
16
17add_definitions(-DCPU_LPC55S69JBD100_cm33_core0)
18add_definitions(-DSERIAL_PORT_TYPE_UART=1)
Kevin Pengc6d74502020-03-04 16:55:37 +080019# set(PS_ENCRYPTION ON)
20set(PS_RAM_FS ON) # Disabled with BUILD_FLASH
21set(PS_CREATE_FLASH_LAYOUT ON)
22set(PS_ROLLBACK_PROTECTION ON)
Kevin Townsenda26983f2020-04-06 13:26:21 +020023set(ITS_RAM_FS ON) # Disabled with BUILD_FLASH
24set(ITS_CREATE_FLASH_LAYOUT ON)
25set(DAUTH_CHIP_DEFAULT ON)
26set(TFM_PARTITION_PLATFORM ON)
27
28#Specify the location of platform specific build dependencies.
29#FIXME use CMAKE_C_COMPILER_ID here instead?
30if(COMPILER STREQUAL "ARMCLANG")
31 # Throw error for ARMCLANG until support can be added/tested.
32 message(FATAL_ERROR "ARMCLANG is not currently supported on this platform. Use GNUARM instead.")
33 #set(BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}target/nxp/lpcxpresso55s69/Device/Source/armclang/LPC55S69_cm33_core0_bl2.sct")
34 #set(S_SCATTER_FILE_NAME "${PLATFORM_DIR}target/nxp/lpcxpresso55s69/Device/Source/armclang/LPC55S69_cm33_core0_s.sct")
35 #set(NS_SCATTER_FILE_NAME "${PLATFORM_DIR}target/nxp/lpcxpresso55s69/Device/Source/armclang/LPC55S69_cm33_core0_ns.sct")
Kevin Peng2131fdb2020-05-21 15:51:36 +080036 if (DEFINED CMSIS_DIR)
37 # Not all projects defines CMSIS_DIR, only the ones that use it.
38 set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib")
Kevin Townsenda26983f2020-04-06 13:26:21 +020039 endif()
40elseif(COMPILER STREQUAL "GNUARM")
41 set(S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld")
42 set(NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armgcc/LPC55S69_cm33_core0_ns.ld")
Kevin Peng2131fdb2020-05-21 15:51:36 +080043 if (DEFINED CMSIS_DIR)
44 # Not all projects define CMSIS_DIR, only the ones that use it.
45 set(RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a")
Kevin Townsenda26983f2020-04-06 13:26:21 +020046 endif()
47else()
48 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
49endif()
50set (FLASH_LAYOUT "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/partition/flash_layout.h")
51set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/partition")
52
53if (BL2)
54 message(FATAL_ERROR "ERROR: BL2 is currently not supported on target '${TARGET_PLATFORM}'.")
55 # Section below maintained for ref. with future BL2 support.
56 set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
57 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
58 message(FATAL_ERROR "ERROR: RAM_LOADING upgrade strategy is not supported on target '${TARGET_PLATFORM}'.")
59 endif()
60 #FixMe: MCUBOOT_SIGN_RSA_LEN can be removed when ROTPK won't be hard coded in platform/ext/common/template/tfm_rotpk.c
61 # instead independently loaded from secure code as a blob.
62 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048")
63 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048)
64 endif()
65 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072")
66 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072)
67 endif()
68endif()
69
70embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
71embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
72embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common" ABSOLUTE)
73embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver" ABSOLUTE)
74embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/lists" ABSOLUTE)
75embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/serial_manager" ABSOLUTE)
76embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/uart" ABSOLUTE)
77embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers" ABSOLUTE)
78embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities" ABSOLUTE)
79embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/debug_console" ABSOLUTE)
80embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/str" ABSOLUTE)
81embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69" ABSOLUTE)
82embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Config" ABSOLUTE)
83embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Include" ABSOLUTE)
84embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver" ABSOLUTE)
85embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s" ABSOLUTE)
86embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/partition" ABSOLUTE)
87embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
Shawn Shan61afaa22020-09-15 16:11:42 +080088embedded_include_directories(PATH "${PLATFORM_DIR}/../../secure_fw/spm/include" ABSOLUTE)
89
90add_definitions(-DTFM_SPM_LOG_LEVEL=1)
Kevin Townsenda26983f2020-04-06 13:26:21 +020091
92if (NOT DEFINED BUILD_UART_STDOUT)
93 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
94elseif(BUILD_UART_STDOUT)
95 if (NOT DEFINED SECURE_UART1)
96 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
97 elseif(SECURE_UART1)
98 add_definitions(-DSECURE_UART1)
99 endif()
Shawn Shan61afaa22020-09-15 16:11:42 +0800100 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c"
101 "${PLATFORM_DIR}/common/tfm_hal_spm_logdev_peripheral.c")
Kevin Townsenda26983f2020-04-06 13:26:21 +0200102 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
103 set(BUILD_NATIVE_DRIVERS true)
104 set(BUILD_CMSIS_DRIVERS true)
105endif()
106
107if (NOT DEFINED BUILD_NATIVE_DRIVERS)
108 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
109elseif (BUILD_NATIVE_DRIVERS)
110 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/lists/generic_list.c"
111 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/serial_manager/serial_manager.c"
112 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/serial_manager/serial_port_uart.c"
113 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/uart/usart_adapter.c"
114 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_casper.c"
115 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_clock.c"
116 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_common.c"
117 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_ctimer.c"
118 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_flexcomm.c"
119 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_gpio.c"
120 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_hashcrypt.c"
121 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_iap.c"
122 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_power.c"
123 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_reset.c"
124 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_rng.c"
125 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_usart.c"
126 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/fsl_assert.c"
127 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/fsl_sbrk.c"
128 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/debug_console/fsl_debug_console.c"
129 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/str/fsl_str.c"
130 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/system_LPC55S69_cm33_core0.c")
131 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/board.c"
132 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/hardware_init.c"
133 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/clock_config.c"
134 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/peripherals.c"
135 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/pin_mux.c")
136 list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/board.c"
137 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/hardware_init.c"
138 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/clock_config.c"
139 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/peripherals.c"
140 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/pin_mux.c")
141
142endif()
143
144if (NOT DEFINED BUILD_TIME)
145 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
146elseif (BUILD_TIME)
147 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver" ABSOLUTE)
148endif()
149
150if (NOT DEFINED BUILD_STARTUP)
151 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
152elseif (BUILD_STARTUP)
153 if (CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
154 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armclang/startup_LPC55S69_cm33_core0_s.s")
155 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armclang/startup_LPC55S69_cm33_core0_ns.s")
156 #list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armclang/startup_LPC55S69_cm33_core0_bl2.s")
157 elseif (CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
158 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armgcc/startup_LPC55S69_cm33_core0_s.S")
159 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armgcc/startup_LPC55S69_cm33_core0_ns.S")
160 #list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armgcc/startup_LPC55S69_cm33_core0_bl2.S")
161 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}"
162 APPEND PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
163 else()
164 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
165 endif()
166endif()
167
Balint Matyi95f58eb2020-05-22 08:52:32 +0100168#Enable the checks of attestation claims against hard-coded values.
169set(ATTEST_CLAIM_VALUE_CHECK ON)
170
Kevin Townsenda26983f2020-04-06 13:26:21 +0200171if (NOT DEFINED BUILD_TARGET_CFG)
172 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
173elseif(BUILD_TARGET_CFG)
174 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/target_cfg.c")
175 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/spm_hal.c")
176 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
177 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/common/Native_Driver/mpu_armv8m_drv.c")
178 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver" ABSOLUTE)
179 if (TFM_PARTITION_PLATFORM)
180 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/services/src/tfm_platform_system.c")
181 endif()
Chris Brandc47d7102020-02-20 11:12:18 -0800182 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
183 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
Kevin Townsenda26983f2020-04-06 13:26:21 +0200184 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
185 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
186endif()
187
188if (NOT DEFINED BUILD_PLAT_TEST)
189 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
190elseif(BUILD_PLAT_TEST)
191 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/plat_test.c")
192endif()
193
194# TODO: Implement bootloader support!
195if (NOT DEFINED BUILD_BOOT_HAL)
196 message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
197elseif(BUILD_BOOT_HAL)
198 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/boot_hal.c")
199endif()
200
201if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
202 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
203elseif(BUILD_TARGET_HARDWARE_KEYS)
204 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
205 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
206 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c")
207endif()
208
209if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
210 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
211elseif(BUILD_TARGET_NV_COUNTERS)
212 # NOTE: This non-volatile counters implementation is a dummy
213 # implementation. Platform vendors have to implement the
214 # API ONLY if the target has non-volatile counters.
215 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c")
216 set(TARGET_NV_COUNTERS_ENABLE ON)
Kevin Pengc6d74502020-03-04 16:55:37 +0800217 # Sets PS_ROLLBACK_PROTECTION flag to compile in the PS services
Kevin Townsenda26983f2020-04-06 13:26:21 +0200218 # rollback protection code as the target supports nv counters.
Kevin Pengc6d74502020-03-04 16:55:37 +0800219 set (PS_ROLLBACK_PROTECTION ON)
Kevin Townsenda26983f2020-04-06 13:26:21 +0200220endif()
221
222if (NOT DEFINED BUILD_CMSIS_DRIVERS)
223 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
224elseif(BUILD_CMSIS_DRIVERS)
225 #list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/cmsis_drivers/Driver_MPC.c"
226 # "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver/Driver_PPC.c")
227 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver/Driver_USART.c")
228 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver" ABSOLUTE)
229 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
230endif()
231
232if (NOT DEFINED BUILD_FLASH)
233 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
234elseif(BUILD_FLASH)
235 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver/Driver_Flash.c")
236
Kevin Pengc6d74502020-03-04 16:55:37 +0800237 # As the PS area is going to be in RAM, it is required to set
238 # PS_CREATE_FLASH_LAYOUT to be sure the PS service knows that when it
239 # starts the PS area does not contain any valid PS flash layout and it
Kevin Townsenda26983f2020-04-06 13:26:21 +0200240 # needs to create one.
Kevin Pengc6d74502020-03-04 16:55:37 +0800241 set(PS_CREATE_FLASH_LAYOUT ON)
242 set(PS_RAM_FS OFF)
Kevin Townsenda26983f2020-04-06 13:26:21 +0200243 set(ITS_CREATE_FLASH_LAYOUT ON)
244 set(ITS_RAM_FS OFF)
245 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver" ABSOLUTE)
246 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
247endif()