1#------------------------------------------------------------------------------- 2# Copyright (c) 2021-2022, Arm Limited. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6#------------------------------------------------------------------------------- 7 8find_package(Python3) 9 10add_subdirectory(lib) 11add_subdirectory(shared_lib) 12add_executable(bl1_1) 13 14set_target_properties(bl1_1 15 PROPERTIES 16 SUFFIX ".axf" 17 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" 18) 19 20add_convert_to_bin_target(bl1_1) 21 22target_link_options(bl1_1 23 PRIVATE 24 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/bl1_1.map> 25 $<$<C_COMPILER_ID:ARMClang>:--map> 26 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/bl1_1.map> 27) 28 29target_sources(bl1_1 30 PRIVATE 31 main.c 32) 33 34target_link_libraries(bl1_1 35 PRIVATE 36 bl1_1_lib 37 bl1_1_shared_lib 38 platform_bl1 39 $<$<BOOL:${TEST_BL1_1}>:bl1_1_tests> 40) 41 42target_compile_definitions(bl1_1 43 PRIVATE 44 $<$<BOOL:${TEST_BL1_1}>:TEST_BL1_1> 45) 46 47target_share_symbols(bl1_1 ${CMAKE_CURRENT_SOURCE_DIR}/bl1_1_shared_symbols.txt) 48 49################################################################################ 50 51add_library(signing_layout_bl1_2 OBJECT signing_layout.c) 52target_compile_options(signing_layout_bl1_2 53 PRIVATE 54 $<$<C_COMPILER_ID:GNU>:-E\;-xc> 55 $<$<C_COMPILER_ID:ARMClang>:-E\;-xc> 56 $<$<C_COMPILER_ID:IAR>:--preprocess=ns\;$<TARGET_OBJECTS:signing_layout_bl1_2>> 57) 58target_link_libraries(signing_layout_bl1_2 59 PRIVATE 60 platform_region_defs 61) 62 63################################################################################ 64get_target_property(bin_dir bl1_2 RUNTIME_OUTPUT_DIRECTORY) 65 66add_custom_target(bl1_2_padded_bin 67 ALL 68 SOURCES bl1_2_padded.bin ${bin_dir}/bl1_2_padded.bin 69 SOURCES bl1_2_padded_hash.bin ${bin_dir}/bl1_2_padded_hash.bin 70) 71 72add_custom_command(OUTPUT bl1_2_padded.bin bl1_2_padded_hash.bin 73 OUTPUT ${bin_dir}/bl1_2_padded.bin ${bin_dir}/bl1_2_padded_hash.bin 74 DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2.bin bl1_2_bin signing_layout_bl1_2 75 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_bl1_2_img.py 76 COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_bl1_2_img.py 77 --input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2.bin 78 --img_output_file bl1_2_padded.bin 79 --hash_output_file bl1_2_padded_hash.bin 80 --signing_layout_file $<TARGET_OBJECTS:signing_layout_bl1_2> 81 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_2_padded.bin $<TARGET_FILE_DIR:bl1_2> 82 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_2_padded_hash.bin $<TARGET_FILE_DIR:bl1_2> 83) 84 85################################################################################ 86 87add_custom_target(bl1_provisioning_bundle 88 ALL 89 SOURCES bl1_provisioning_bundle.bin 90) 91 92add_custom_command(OUTPUT bl1_provisioning_bundle.bin 93 DEPENDS ${TFM_BL2_ENCRYPTION_KEY_PATH} 94 DEPENDS ${TFM_GUK_PATH} 95 DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin 96 DEPENDS $<TARGET_FILE_DIR:bl2>/bl2_signed_hash.bin 97 DEPENDS $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin 98 bl1_2_padded_bin bl2_signed_bin 99 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py 100 COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_provisioning_bundle.py 101 --bl2_encryption_key_input_file ${TFM_BL2_ENCRYPTION_KEY_PATH} 102 --bl2_signing_key_input_file ${TFM_BL2_SIGNING_KEY_PATH} 103 --guk_input_file ${TFM_GUK_PATH} 104 --bl1_2_padded_hash_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded_hash.bin 105 --bl2_signed_hash_input_file $<TARGET_FILE_DIR:bl2>/bl2_signed_hash.bin 106 --bl1_2_input_file $<TARGET_FILE_DIR:bl1_2>/bl1_2_padded.bin 107 --bundle_output_file bl1_provisioning_bundle.bin 108 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl1_provisioning_bundle.bin $<TARGET_FILE_DIR:bl1_1> 109) 110