1#------------------------------------------------------------------------------- 2# Copyright (c) 2021-2023, Arm Limited. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6#------------------------------------------------------------------------------- 7 8find_package(Python3) 9 10set(CMAKE_BUILD_TYPE ${BL1_2_BUILD_TYPE}) 11 12add_subdirectory(lib) 13 14add_executable(bl1_2) 15 16set_target_properties(bl1_2 17 PROPERTIES 18 SUFFIX ".axf" 19 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" 20) 21 22add_convert_to_bin_target(bl1_2) 23 24target_link_options(bl1_2 25 PRIVATE 26 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/bl1_2.map> 27 $<$<C_COMPILER_ID:ARMClang>:--map> 28 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/bl1_2.map> 29) 30 31target_sources(bl1_2 32 PRIVATE 33 main.c 34 $<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:${CMAKE_SOURCE_DIR}/platform/ext/common/syscalls_stub.c> 35) 36 37target_link_libraries(bl1_2 38 PRIVATE 39 bl1_1_shared_lib_interface 40 bl1_2_lib 41 platform_bl1_1_interface 42 platform_bl1_2 43 $<$<BOOL:${TEST_BL1_2}>:bl1_2_tests> 44) 45 46target_compile_definitions(bl1_2 47 PRIVATE 48 $<$<BOOL:${TFM_BL1_MEMORY_MAPPED_FLASH}>:TFM_BL1_MEMORY_MAPPED_FLASH> 49 $<$<BOOL:${TEST_BL1_2}>:TEST_BL1_2> 50 $<$<BOOL:${TFM_BL1_PQ_CRYPTO}>:TFM_BL1_PQ_CRYPTO> 51 $<$<AND:$<BOOL:${CONFIG_TFM_BOOT_STORE_MEASUREMENTS}>,$<NOT:$<BOOL:${CONFIG_TFM_BOOT_STORE_ENCODED_MEASUREMENTS}>>>:TFM_MEASURED_BOOT_API> 52) 53 54target_link_shared_code(bl1_2 55 bl1_1 56) 57 58add_dependencies(bl1_2 59 bl1_1_shared_lib 60) 61 62################################################################################ 63 64set(FLASH_AREA_NUM ${TFM_BL2_IMAGE_FLASH_AREA_NUM}) 65configure_file(signing_layout.c.in signing_layout_bl2.c @ONLY) 66 67add_library(signing_layout_bl2 OBJECT ${CMAKE_CURRENT_BINARY_DIR}/signing_layout_bl2.c) 68target_compile_options(signing_layout_bl2 69 PRIVATE 70 $<$<C_COMPILER_ID:GNU>:-E\;-xc> 71 $<$<C_COMPILER_ID:ARMClang>:-E\;-xc> 72 $<$<C_COMPILER_ID:IAR>:--preprocess=ns\;$<TARGET_OBJECTS:signing_layout_bl2>> 73) 74target_link_libraries(signing_layout_bl2 75 PRIVATE 76 platform_region_defs 77) 78 79################################################################################ 80get_target_property(bin_dir bl2 RUNTIME_OUTPUT_DIRECTORY) 81 82add_custom_target(bl2_signed_bin 83 ALL 84 SOURCES bl2_signed.bin 85 SOURCES bl2_signed_hash.bin 86 SOURCES ${bin_dir}/bl2_signed.bin 87 SOURCES ${bin_dir}/bl2_signed_hash.bin 88) 89 90add_custom_command(OUTPUT bl2_signed.bin bl2_signed_hash.bin 91 OUTPUT ${bin_dir}/bl2_signed.bin ${bin_dir}/bl2_signed_hash.bin 92 DEPENDS $<TARGET_FILE_DIR:bl2>/bl2.bin bl2_bin signing_layout_bl2 93 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_bl2_img.py 94 COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_bl2_img.py 95 --input_file $<TARGET_FILE_DIR:bl2>/bl2.bin 96 --img_output_file bl2_signed.bin 97 --hash_output_file bl2_signed_hash.bin 98 --encrypt_key_file ${TFM_BL2_ENCRYPTION_KEY_PATH} 99 --sign_key_file ${TFM_BL2_SIGNING_KEY_PATH} 100 --signing_layout_file $<TARGET_OBJECTS:signing_layout_bl2> 101 --img_version ${TFM_BL1_IMAGE_VERSION_BL2} 102 --img_security_counter ${TFM_BL1_IMAGE_SECURITY_COUNTER_BL2} 103 --header_size ${BL1_HEADER_SIZE} 104 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl2_signed.bin $<TARGET_FILE_DIR:bl2> 105 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bl2_signed_hash.bin $<TARGET_FILE_DIR:bl2> 106) 107