blob: 09cec83b1164664ff8dddd83de2c80eddb9a729e [file] [log] [blame]
Per Åstrand79929ff2021-01-26 14:42:43 +01001#
2# Copyright (c) 2021 Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the License); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an AS IS BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19#############################################################################
20# Configuration
21#############################################################################
22
23set(TRUSTZONE_BUILD TRUE)
24set(TRUSTZONE_SIDE nonsecure)
25
26#############################################################################
27# TrustZone Nonsecure world
28#############################################################################
29
30add_library(nonsecure_target_startup INTERFACE)
31target_link_libraries(nonsecure_target_startup INTERFACE ethosu_target_link)
32target_link_libraries(nonsecure_target_startup INTERFACE cmsis_startup)
33
34ethosu_add_executable(trustzone_nonsecure PRIVATE
35 TARGET_LIBRARY nonsecure_target_startup
36 SOURCES main_nonsecure.cpp)
37
38target_compile_definitions(trustzone_nonsecure PUBLIC TRUSTZONE_BUILD)
39target_compile_definitions(trustzone_nonsecure PUBLIC TRUSTZONE_NONSECURE)
40
41# Silence warning on cmse attributes
42target_compile_options(trustzone_nonsecure PRIVATE -Wno-ignored-attributes)
43
Jonas Ohlssonf821c612021-06-04 14:58:34 +020044# Add include directory for target application specifics
45target_include_directories(trustzone_nonsecure PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../${ETHOSU_TARGET})
46
Per Åstrand79929ff2021-01-26 14:42:43 +010047#############################################################################
48# linker configuration
49#############################################################################
50
51# Pick up the gateway object file from secure build
52target_link_options(trustzone_nonsecure PRIVATE ${SECURE_GATEWAY_LIB})
53
54target_link_options(trustzone_nonsecure
55 PRIVATE "--predefine=\"-I${CMAKE_CURRENT_SOURCE_DIR}/../${ETHOSU_TARGET}\"")
56
57#############################################################################
58# Helper target to extract non-secure binary
59#############################################################################
60
61add_custom_target(nonsecure_binary ALL COMMAND fromelf --bin
62 ${CMAKE_CURRENT_BINARY_DIR}/trustzone_nonsecure.elf
63 -o ${CMAKE_CURRENT_BINARY_DIR}/ns_bin
64 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/trustzone_nonsecure)