-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
130 lines (111 loc) · 4.77 KB
/
CMakeLists.txt
File metadata and controls
130 lines (111 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#-------------------------------------------------------------------------------
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------
find_package(Python3)
add_subdirectory(lib)
add_subdirectory(shared_lib)
add_executable(bl1_1)
set_target_properties(bl1_1
PROPERTIES
SUFFIX ".axf"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
add_convert_to_bin_target(bl1_1)
target_link_options(bl1_1
PRIVATE
$<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/bl1_1.map>
$<$<C_COMPILER_ID:ARMClang>:--map>
$<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/bl1_1.map>
$<$<C_COMPILER_ID:Clang>:LINKER:-Map=${CMAKE_BINARY_DIR}/bin/bl1_1.map>
)
target_compile_options(bl1_1
PUBLIC
${BL1_COMPILER_CP_FLAG}
)
target_link_options(bl1_1
PUBLIC
${BL1_LINKER_CP_OPTION}
)
target_sources(bl1_1
PRIVATE
main.c
$<$<BOOL:${CONFIG_PICOLIBC}>:${CMAKE_SOURCE_DIR}/platform/ext/common/picolibc.c>
$<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c>
)
target_link_libraries(bl1_1
PRIVATE
bl1_1_lib
bl1_1_shared_lib
platform_bl1_1
$<$<AND:$<BOOL:${TEST_BL1_1}>,$<BOOL:${PLATFORM_DEFAULT_BL1_1_TESTS}>>:bl1_1_tests>
)
target_compile_definitions(bl1_1
PRIVATE
$<$<BOOL:${TEST_BL1_1}>:TEST_BL1_1>
$<$<BOOL:${TEST_BL1_2}>:TEST_BL1_2>
$<$<AND:$<BOOL:${CONFIG_TFM_BOOT_STORE_MEASUREMENTS}>,$<NOT:$<BOOL:${CONFIG_TFM_BOOT_STORE_ENCODED_MEASUREMENTS}>>>:TFM_MEASURED_BOOT_API>
)
if (BL1_1_SHARED_SYMBOLS_PATH)
target_share_symbols(bl1_1
${BL1_1_SHARED_SYMBOLS_PATH}
)
endif()
################################################################################
add_library(signing_layout_bl1_2 OBJECT signing_layout.c)
target_compile_options(signing_layout_bl1_2
PRIVATE
$<$<C_COMPILER_ID:GNU>:-E\;-xc>
$<$<C_COMPILER_ID:ARMClang>:-E\;-xc>
$<$<C_COMPILER_ID:IAR>:--preprocess=ns\;$<TARGET_OBJECTS:signing_layout_bl1_2>>
$<$<C_COMPILER_ID:Clang>:-E\;-xc>
)
target_link_libraries(signing_layout_bl1_2
PRIVATE
platform_region_defs
)
################################################################################
get_target_property(bin_dir bl1_2 RUNTIME_OUTPUT_DIRECTORY)
add_custom_target(bl1_2_padded_bin
ALL
SOURCES bl1_2_padded.bin ${bin_dir}/bl1_2_padded.bin
SOURCES bl1_2_padded_hash.bin ${bin_dir}/bl1_2_padded_hash.bin
)
add_custom_command(OUTPUT bl1_2_padded.bin bl1_2_padded_hash.bin
OUTPUT ${bin_dir}/bl1_2_padded.bin ${bin_dir}/bl1_2_padded_hash.bin
DEPENDS bl1_2_bin signing_layout_bl1_2
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_bl1_2_img.py
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_bl1_2_img.py
--input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2.bin
--img_output_file bl1_2_padded.bin
--hash_alg ${TFM_BL1_1_MEASUREMENT_HASH_ALG}
--hash_output_file bl1_2_padded_hash.bin
--signing_layout_file $<TARGET_OBJECTS:signing_layout_bl1_2>
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_2_padded.bin $<TARGET_FILE_DIR:bl1_2>
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_2_padded_hash.bin $<TARGET_FILE_DIR:bl1_2>
)
################################################################################
if (TFM_BL1_DEFAULT_PROVISIONING)
add_custom_target(bl1_provisioning_bundle
ALL
SOURCES bl1_provisioning_bundle.bin
)
add_custom_command(OUTPUT bl1_provisioning_bundle.bin
DEPENDS ${TFM_BL2_ENCRYPTION_KEY_PATH}
DEPENDS ${TFM_GUK_PATH}
DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin
DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin
bl1_2_padded_bin bl2_signed_bin
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py
--bl2_encryption_key_input_file ${TFM_BL2_ENCRYPTION_KEY_PATH}
--bl2_signing_key_input_file ${TFM_BL1_2_CM_SIGNING_KEY_PATH}
--guk_input_file ${TFM_GUK_PATH}
--bl1_2_padded_hash_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin
--bl1_2_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin
--bundle_output_file bl1_provisioning_bundle.bin
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_provisioning_bundle.bin $<TARGET_FILE_DIR:bl1_1>
)
endif()