Skip to content

Commit

Permalink
tfm: Add BL2 log level configuration and disable it with TFM silent conf
Browse files Browse the repository at this point in the history
Add choice for BL2 log level configuration.
Silence TF-M BL2 logging when TF-M is configured to be silent.

Signed-off-by: Joakim Andersson <[email protected]>
  • Loading branch information
joerchan authored and carlescufi committed Oct 26, 2023
1 parent baad781 commit 96c5052
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/trusted-firmware-m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ if (CONFIG_BUILD_WITH_TFM)
list(APPEND TFM_CMAKE_ARGS -DTFM_EXCEPTION_INFO_DUMP=OFF)
endif()

if (CONFIG_TFM_BL2)
if (CONFIG_TFM_BL2_LOG_LEVEL_DEBUG)
set(TFM_BL2_LOG_LEVEL "DEBUG")
elseif (CONFIG_TFM_BL2_LOG_LEVEL_INFO)
set(TFM_BL2_LOG_LEVEL "INFO")
elseif (CONFIG_TFM_BL2_LOG_LEVEL_WARNING)
set(TFM_BL2_LOG_LEVEL "WARNING")
elseif (CONFIG_TFM_BL2_LOG_LEVEL_ERROR)
set(TFM_BL2_LOG_LEVEL "ERROR")
elseif (CONFIG_TFM_BL2_LOG_LEVEL_OFF OR CONFIG_TFM_LOG_LEVEL_SILENCE)
set(TFM_BL2_LOG_LEVEL "OFF")
endif()

if (DEFINED TFM_BL2_LOG_LEVEL)
# BL2 uses MCUBOOT_LOG_LEVEL configuration
list(APPEND TFM_CMAKE_ARGS -DMCUBOOT_LOG_LEVEL=${TFM_BL2_LOG_LEVEL})
endif()
endif()

if (CONFIG_TFM_PARTITION_LOG_LEVEL_DEBUG)
set(TFM_PARTITION_LOG_LEVEL "TFM_PARTITION_LOG_LEVEL_DEBUG")
elseif (CONFIG_TFM_PARTITION_LOG_LEVEL_INFO)
Expand Down
15 changes: 15 additions & 0 deletions modules/trusted-firmware-m/Kconfig.tfm
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,21 @@ config ROM_START_OFFSET
needs to be updated if TF-M switches to use a different header
size for BL2.

choice TFM_BL2_LOG_LEVEL
prompt "BL2 Log Level" if !TFM_LOG_LEVEL_SILENCE
default TFM_BL2_LOG_LEVEL_INFO
config TFM_BL2_LOG_LEVEL_DEBUG
bool "Debug"
config TFM_BL2_LOG_LEVEL_INFO
bool "Info"
config TFM_BL2_LOG_LEVEL_WARNING
bool "Warning"
config TFM_BL2_LOG_LEVEL_ERROR
bool "Error"
config TFM_BL2_LOG_LEVEL_OFF
bool "Off"
endchoice

endif # !TFM_BL2

# Option to instruct flashing a merged binary consisting of BL2 (optionally),
Expand Down

0 comments on commit 96c5052

Please sign in to comment.