blob: be11318bbda29ecaa11bf447561c951d73bb32d7 [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)
88
89if (NOT DEFINED BUILD_UART_STDOUT)
90 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
91elseif(BUILD_UART_STDOUT)
92 if (NOT DEFINED SECURE_UART1)
93 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
94 elseif(SECURE_UART1)
95 add_definitions(-DSECURE_UART1)
96 endif()
97 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
98 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
99 set(BUILD_NATIVE_DRIVERS true)
100 set(BUILD_CMSIS_DRIVERS true)
101endif()
102
103if (NOT DEFINED BUILD_NATIVE_DRIVERS)
104 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
105elseif (BUILD_NATIVE_DRIVERS)
106 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/lists/generic_list.c"
107 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/serial_manager/serial_manager.c"
108 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/serial_manager/serial_port_uart.c"
109 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/components/uart/usart_adapter.c"
110 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_casper.c"
111 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_clock.c"
112 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_common.c"
113 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_ctimer.c"
114 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_flexcomm.c"
115 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_gpio.c"
116 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_hashcrypt.c"
117 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_iap.c"
118 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_power.c"
119 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_reset.c"
120 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_rng.c"
121 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/drivers/fsl_usart.c"
122 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/fsl_assert.c"
123 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/fsl_sbrk.c"
124 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/debug_console/fsl_debug_console.c"
125 "${PLATFORM_DIR}/target/nxp/common/Native_Driver/utilities/str/fsl_str.c"
126 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/system_LPC55S69_cm33_core0.c")
127 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/board.c"
128 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/hardware_init.c"
129 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/clock_config.c"
130 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/peripherals.c"
131 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/s/pin_mux.c")
132 list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/board.c"
133 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/hardware_init.c"
134 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/clock_config.c"
135 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/peripherals.c"
136 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Native_Driver/project_template/ns/pin_mux.c")
137
138endif()
139
140if (NOT DEFINED BUILD_TIME)
141 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
142elseif (BUILD_TIME)
143 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver" ABSOLUTE)
144endif()
145
146if (NOT DEFINED BUILD_STARTUP)
147 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
148elseif (BUILD_STARTUP)
149 if (CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
150 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armclang/startup_LPC55S69_cm33_core0_s.s")
151 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armclang/startup_LPC55S69_cm33_core0_ns.s")
152 #list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armclang/startup_LPC55S69_cm33_core0_bl2.s")
153 elseif (CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
154 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armgcc/startup_LPC55S69_cm33_core0_s.S")
155 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armgcc/startup_LPC55S69_cm33_core0_ns.S")
156 #list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/Device/Source/armgcc/startup_LPC55S69_cm33_core0_bl2.S")
157 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}"
158 APPEND PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
159 else()
160 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
161 endif()
162endif()
163
Balint Matyi95f58eb2020-05-22 08:52:32 +0100164#Enable the checks of attestation claims against hard-coded values.
165set(ATTEST_CLAIM_VALUE_CHECK ON)
166
Kevin Townsenda26983f2020-04-06 13:26:21 +0200167if (NOT DEFINED BUILD_TARGET_CFG)
168 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
169elseif(BUILD_TARGET_CFG)
170 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/target_cfg.c")
171 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/spm_hal.c")
172 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
173 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/common/Native_Driver/mpu_armv8m_drv.c")
174 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/Native_Driver" ABSOLUTE)
175 if (TFM_PARTITION_PLATFORM)
176 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/services/src/tfm_platform_system.c")
177 endif()
Chris Brandc47d7102020-02-20 11:12:18 -0800178 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
179 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
Kevin Townsenda26983f2020-04-06 13:26:21 +0200180 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
181 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
182endif()
183
184if (NOT DEFINED BUILD_PLAT_TEST)
185 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
186elseif(BUILD_PLAT_TEST)
187 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/plat_test.c")
188endif()
189
190# TODO: Implement bootloader support!
191if (NOT DEFINED BUILD_BOOT_HAL)
192 message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
193elseif(BUILD_BOOT_HAL)
194 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/boot_hal.c")
195endif()
196
197if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
198 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
199elseif(BUILD_TARGET_HARDWARE_KEYS)
200 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
201 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
202 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c")
203endif()
204
205if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
206 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
207elseif(BUILD_TARGET_NV_COUNTERS)
208 # NOTE: This non-volatile counters implementation is a dummy
209 # implementation. Platform vendors have to implement the
210 # API ONLY if the target has non-volatile counters.
211 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c")
212 set(TARGET_NV_COUNTERS_ENABLE ON)
Kevin Pengc6d74502020-03-04 16:55:37 +0800213 # Sets PS_ROLLBACK_PROTECTION flag to compile in the PS services
Kevin Townsenda26983f2020-04-06 13:26:21 +0200214 # rollback protection code as the target supports nv counters.
Kevin Pengc6d74502020-03-04 16:55:37 +0800215 set (PS_ROLLBACK_PROTECTION ON)
Kevin Townsenda26983f2020-04-06 13:26:21 +0200216endif()
217
218if (NOT DEFINED BUILD_CMSIS_DRIVERS)
219 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
220elseif(BUILD_CMSIS_DRIVERS)
221 #list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/nxp/lpcxpresso55s69/cmsis_drivers/Driver_MPC.c"
222 # "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver/Driver_PPC.c")
223 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver/Driver_USART.c")
224 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver" ABSOLUTE)
225 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
226endif()
227
228if (NOT DEFINED BUILD_FLASH)
229 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
230elseif(BUILD_FLASH)
231 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver/Driver_Flash.c")
232
Kevin Pengc6d74502020-03-04 16:55:37 +0800233 # As the PS area is going to be in RAM, it is required to set
234 # PS_CREATE_FLASH_LAYOUT to be sure the PS service knows that when it
235 # starts the PS area does not contain any valid PS flash layout and it
Kevin Townsenda26983f2020-04-06 13:26:21 +0200236 # needs to create one.
Kevin Pengc6d74502020-03-04 16:55:37 +0800237 set(PS_CREATE_FLASH_LAYOUT ON)
238 set(PS_RAM_FS OFF)
Kevin Townsenda26983f2020-04-06 13:26:21 +0200239 set(ITS_CREATE_FLASH_LAYOUT ON)
240 set(ITS_RAM_FS OFF)
241 embedded_include_directories(PATH "${PLATFORM_DIR}/target/nxp/common/CMSIS_Driver" ABSOLUTE)
242 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
243endif()