From 5ee41d8b4ee8d33e1e4db69c2afa534660a1c1c6 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Thu, 3 Mar 2022 13:25:13 +0100 Subject: [PATCH] scripts: size_report: Add support for TF-M and BL2 image size reports Add support for TF-M and BL2 image size reports. This adds the following targets when TF-M or BL2 is enabled: tfm_rom_report, tfm_ram_report, tfm_footprint bl2_rom_report, bl2_ram_report, bl2_footprint Example: west build -t tfm_rom_report Signed-off-by: Joakim Andersson --- cmake/reports/CMakeLists.txt | 38 +++++++++++++++++++++++ modules/trusted-firmware-m/CMakeLists.txt | 6 ++++ 2 files changed, 44 insertions(+) diff --git a/cmake/reports/CMakeLists.txt b/cmake/reports/CMakeLists.txt index 7dc3ef2181f..5cd3246f972 100644 --- a/cmake/reports/CMakeLists.txt +++ b/cmake/reports/CMakeLists.txt @@ -29,6 +29,44 @@ foreach(report ram_report rom_report footprint) ) endforeach() +if (CONFIG_BUILD_WITH_TFM) + foreach(report ram_report rom_report footprint) + add_custom_target( + tfm_${report} + ${PYTHON_EXECUTABLE} + ${ZEPHYR_BASE}/scripts/footprint/size_report + -k $ + -z ${ZEPHYR_BASE} + -o ${CMAKE_BINARY_DIR} + ${workspace_arg} + -d ${report_depth} + ${flag_for_${report}} + DEPENDS tfm + USES_TERMINAL + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endforeach() +endif() + +if (CONFIG_TFM_BL2) + foreach(report ram_report rom_report footprint) + add_custom_target( + bl2_${report} + ${PYTHON_EXECUTABLE} + ${ZEPHYR_BASE}/scripts/footprint/size_report + -k $ + -z ${ZEPHYR_BASE} + -o ${CMAKE_BINARY_DIR} + ${workspace_arg} + -d ${report_depth} + ${flag_for_${report}} + DEPENDS tfm + USES_TERMINAL + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endforeach() +endif() + find_program(PUNCOVER puncover) if(NOT ${PUNCOVER} STREQUAL PUNCOVER-NOTFOUND) diff --git a/modules/trusted-firmware-m/CMakeLists.txt b/modules/trusted-firmware-m/CMakeLists.txt index a524ec6d494..301775aa38b 100644 --- a/modules/trusted-firmware-m/CMakeLists.txt +++ b/modules/trusted-firmware-m/CMakeLists.txt @@ -162,9 +162,11 @@ if (CONFIG_BUILD_WITH_TFM) endif() if(CONFIG_TFM_BL2) + set(BL2_ELF_FILE ${TFM_BINARY_DIR}/bin/bl2.elf) set(BL2_BIN_FILE ${TFM_BINARY_DIR}/bin/bl2.bin) set(BL2_HEX_FILE ${TFM_BINARY_DIR}/bin/bl2.hex) endif() + set(TFM_S_ELF_FILE ${TFM_BINARY_DIR}/bin/tfm_s.elf) set(TFM_S_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s.bin) set(TFM_S_HEX_FILE ${TFM_BINARY_DIR}/bin/tfm_s.hex) set(TFM_NS_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_ns.bin) @@ -181,8 +183,10 @@ if (CONFIG_BUILD_WITH_TFM) ${PSA_TEST_PAL_FILE} ${PSA_TEST_COMBINE_FILE} ${PLATFORM_NS_FILE} + ${BL2_ELF_FILE} ${BL2_BIN_FILE} ${BL2_HEX_FILE} + ${TFM_S_ELF_FILE} ${TFM_S_BIN_FILE} ${TFM_S_HEX_FILE} ${TFM_NS_BIN_FILE} @@ -287,6 +291,7 @@ if (CONFIG_BUILD_WITH_TFM) # These files are produced by the TFM build system. if(CONFIG_TFM_BL2) set_target_properties(tfm PROPERTIES + BL2_ELF_FILE ${BL2_ELF_FILE} BL2_BIN_FILE ${BL2_BIN_FILE} BL2_HEX_FILE ${BL2_HEX_FILE} ) @@ -297,6 +302,7 @@ if (CONFIG_BUILD_WITH_TFM) # Note that the Nonsecure FW is replaced by the Zephyr app in regular Zephyr # builds. set_target_properties(tfm PROPERTIES + TFM_S_ELF_FILE ${TFM_S_ELF_FILE} TFM_S_BIN_FILE ${TFM_S_BIN_FILE} # TFM Secure FW (unsigned) TFM_S_HEX_FILE ${TFM_S_HEX_FILE} # TFM Secure FW (unsigned) TFM_NS_BIN_FILE ${TFM_NS_BIN_FILE} # TFM Nonsecure FW (unsigned)