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 <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2022-03-03 13:25:13 +01:00 committed by Anas Nashif
parent 5b50133467
commit 5ee41d8b4e
2 changed files with 44 additions and 0 deletions

View File

@ -29,6 +29,44 @@ foreach(report ram_report rom_report footprint)
) )
endforeach() 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) find_program(PUNCOVER puncover)
if(NOT ${PUNCOVER} STREQUAL PUNCOVER-NOTFOUND) if(NOT ${PUNCOVER} STREQUAL PUNCOVER-NOTFOUND)

View File

@ -162,9 +162,11 @@ if (CONFIG_BUILD_WITH_TFM)
endif() endif()
if(CONFIG_TFM_BL2) 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_BIN_FILE ${TFM_BINARY_DIR}/bin/bl2.bin)
set(BL2_HEX_FILE ${TFM_BINARY_DIR}/bin/bl2.hex) set(BL2_HEX_FILE ${TFM_BINARY_DIR}/bin/bl2.hex)
endif() 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_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s.bin)
set(TFM_S_HEX_FILE ${TFM_BINARY_DIR}/bin/tfm_s.hex) set(TFM_S_HEX_FILE ${TFM_BINARY_DIR}/bin/tfm_s.hex)
set(TFM_NS_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_ns.bin) 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_PAL_FILE}
${PSA_TEST_COMBINE_FILE} ${PSA_TEST_COMBINE_FILE}
${PLATFORM_NS_FILE} ${PLATFORM_NS_FILE}
${BL2_ELF_FILE}
${BL2_BIN_FILE} ${BL2_BIN_FILE}
${BL2_HEX_FILE} ${BL2_HEX_FILE}
${TFM_S_ELF_FILE}
${TFM_S_BIN_FILE} ${TFM_S_BIN_FILE}
${TFM_S_HEX_FILE} ${TFM_S_HEX_FILE}
${TFM_NS_BIN_FILE} ${TFM_NS_BIN_FILE}
@ -287,6 +291,7 @@ if (CONFIG_BUILD_WITH_TFM)
# These files are produced by the TFM build system. # These files are produced by the TFM build system.
if(CONFIG_TFM_BL2) if(CONFIG_TFM_BL2)
set_target_properties(tfm PROPERTIES set_target_properties(tfm PROPERTIES
BL2_ELF_FILE ${BL2_ELF_FILE}
BL2_BIN_FILE ${BL2_BIN_FILE} BL2_BIN_FILE ${BL2_BIN_FILE}
BL2_HEX_FILE ${BL2_HEX_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 # Note that the Nonsecure FW is replaced by the Zephyr app in regular Zephyr
# builds. # builds.
set_target_properties(tfm PROPERTIES 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_BIN_FILE ${TFM_S_BIN_FILE} # TFM Secure FW (unsigned)
TFM_S_HEX_FILE ${TFM_S_HEX_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) TFM_NS_BIN_FILE ${TFM_NS_BIN_FILE} # TFM Nonsecure FW (unsigned)