blob: a4d95adf17f01b2250ba494ccf1fc35ff3438def [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
44#############################################################################
45# linker configuration
46#############################################################################
47
48# Pick up the gateway object file from secure build
49target_link_options(trustzone_nonsecure PRIVATE ${SECURE_GATEWAY_LIB})
50
51target_link_options(trustzone_nonsecure
52 PRIVATE "--predefine=\"-I${CMAKE_CURRENT_SOURCE_DIR}/../${ETHOSU_TARGET}\"")
53
54#############################################################################
55# Helper target to extract non-secure binary
56#############################################################################
57
58add_custom_target(nonsecure_binary ALL COMMAND fromelf --bin
59 ${CMAKE_CURRENT_BINARY_DIR}/trustzone_nonsecure.elf
60 -o ${CMAKE_CURRENT_BINARY_DIR}/ns_bin
61 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/trustzone_nonsecure)