Per Åstrand | 79929ff | 2021-01-26 14:42:43 +0100 | [diff] [blame] | 1 | # |
| 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 | |
| 23 | set(TRUSTZONE_BUILD TRUE) |
| 24 | set(TRUSTZONE_SIDE nonsecure) |
| 25 | |
| 26 | ############################################################################# |
| 27 | # TrustZone Nonsecure world |
| 28 | ############################################################################# |
| 29 | |
| 30 | add_library(nonsecure_target_startup INTERFACE) |
| 31 | target_link_libraries(nonsecure_target_startup INTERFACE ethosu_target_link) |
| 32 | target_link_libraries(nonsecure_target_startup INTERFACE cmsis_startup) |
| 33 | |
| 34 | ethosu_add_executable(trustzone_nonsecure PRIVATE |
| 35 | TARGET_LIBRARY nonsecure_target_startup |
| 36 | SOURCES main_nonsecure.cpp) |
| 37 | |
| 38 | target_compile_definitions(trustzone_nonsecure PUBLIC TRUSTZONE_BUILD) |
| 39 | target_compile_definitions(trustzone_nonsecure PUBLIC TRUSTZONE_NONSECURE) |
| 40 | |
| 41 | # Silence warning on cmse attributes |
| 42 | target_compile_options(trustzone_nonsecure PRIVATE -Wno-ignored-attributes) |
| 43 | |
Jonas Ohlsson | f821c61 | 2021-06-04 14:58:34 +0200 | [diff] [blame^] | 44 | # Add include directory for target application specifics |
| 45 | target_include_directories(trustzone_nonsecure PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../${ETHOSU_TARGET}) |
| 46 | |
Per Åstrand | 79929ff | 2021-01-26 14:42:43 +0100 | [diff] [blame] | 47 | ############################################################################# |
| 48 | # linker configuration |
| 49 | ############################################################################# |
| 50 | |
| 51 | # Pick up the gateway object file from secure build |
| 52 | target_link_options(trustzone_nonsecure PRIVATE ${SECURE_GATEWAY_LIB}) |
| 53 | |
| 54 | target_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 | |
| 61 | add_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) |