Skip to content

Commit

Permalink
scripts: size_report: Add support for TF-M and BL2 image size reports
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
joerchan authored and nashif committed Mar 9, 2022
1 parent 5b50133 commit 5ee41d8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cmake/reports/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<TARGET_PROPERTY:tfm,TFM_S_ELF_FILE>
-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 $<TARGET_PROPERTY:tfm,BL2_ELF_FILE>
-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)
Expand Down
6 changes: 6 additions & 0 deletions modules/trusted-firmware-m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand Down Expand Up @@ -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}
)
Expand All @@ -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)
Expand Down

0 comments on commit 5ee41d8

Please sign in to comment.