-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge-tfm-images: Add new function for merging images
A new CMake module (MergeTfmImages.cmake) is introduced to be used to merge Bootloader, TF-M secure, Non-secure user application, secure and non-secure provisioning images into one image to be loaded inside the ROM rather than loading different images at their respective addresses. CI is modified to archive the merged binary instead of separate binaries which would be used the test stage of the CI. This change enhance re-usability and decrease code duplication within the existing applications and applications to be added. Signed-off-by: Ahmed Ismail <[email protected]>
- Loading branch information
1 parent
dae01b8
commit 87b8ea1
Showing
11 changed files
with
89 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ RIHN | |
RSAES | ||
RSASSA | ||
SECP | ||
srecord | ||
srtp | ||
SRTP | ||
tinycbor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2023 Arm Limited and/or its affiliates | ||
# <[email protected]> | ||
# SPDX-License-Identifier: MIT | ||
|
||
include(ConvertElfToBin) | ||
include(ExternalProject) | ||
|
||
ExternalProject_Get_Property(tf-m-build BINARY_DIR) | ||
|
||
# To merge the bootloader image, TF-M secure image, non-secure user application image, | ||
# secure and non-secure provsioning bundle images into one image, their addresses are | ||
# needed. As the addresses are defined in their respective linker scripts, there is no | ||
# simple way to programmatically get them, so they need to be specified by the user project. | ||
# Order: <bootloader>, <signed secure TF-M firmware>, <signed non-secure user app>, <secure provisioning bundle address>, <non-secure provisioning data load address> (optional), <non-secure provisioning data path> (optional). | ||
|
||
# This function is making use of CMake optional arguments feature, the reason why this feature | ||
# is used is that not every application will need to pass the non-secure provisioning data load address | ||
# and the non-secure provisioning data path to this function. | ||
# ARGV5 is mapped to non-secure provisioning data load address. | ||
# ARGV6 is mapped to non-secure provisioning data path. | ||
function(iot_reference_arm_corstone3xx_tf_m_merge_images target bl2_address tfm_s_address ns_address s_prov_bundle_address) | ||
if(DEFINED ARGV5) | ||
set(ns_provisioning_data_param ${ARGV6} -Binary -offset ${ARGV5}) | ||
else() | ||
set(ns_provisioning_data_param "") | ||
endif() | ||
find_program(srec_cat NAMES srec_cat REQUIRED) | ||
find_program(objcopy NAMES arm-none-eabi-objcopy objcopy REQUIRED) | ||
add_custom_command( | ||
TARGET | ||
${target} | ||
POST_BUILD | ||
DEPENDS | ||
$<TARGET_FILE_DIR:${target}>/${target}_signed.bin | ||
COMMAND | ||
${srec_cat} ${BINARY_DIR}/install/outputs/bl2.bin -Binary -offset ${bl2_address} | ||
${BINARY_DIR}/install/outputs/tfm_s_signed.bin -Binary -offset ${tfm_s_address} | ||
$<TARGET_FILE_DIR:${target}>/${target}_signed.bin -Binary -offset ${ns_address} | ||
${ns_provisioning_data_param} | ||
${CMAKE_BINARY_DIR}/Middleware/ARM/TF-M/tf-m-build-prefix/src/tf-m-build-build/install/outputs/encrypted_provisioning_bundle.bin -Binary -offset ${s_prov_bundle_address} | ||
-o $<TARGET_FILE_DIR:${target}>/${target}_merged.hex | ||
COMMAND | ||
${objcopy} -I ihex -O elf32-little | ||
$<TARGET_FILE_DIR:${target}>/${target}_merged.hex | ||
$<TARGET_FILE_DIR:${target}>/${target}_merged.elf | ||
COMMAND | ||
${CMAKE_COMMAND} -E echo "-- merged: $<TARGET_FILE_DIR:${target}>/${target}_merged.elf" | ||
VERBATIM | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters