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