Skip to content

Commit 70a9bc0

Browse files
joerchancfriedt
authored andcommitted
modules: tfm: Add configuration for TF-M log options
Add Kconfig options for configuring TF-M log options. - Partition log level - SPM log level - Exception info dump Set log level to "info" which is the default in upstream TF-M. Signed-off-by: Joakim Andersson <[email protected]>
1 parent f26f416 commit 70a9bc0

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

modules/trusted-firmware-m/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,36 @@ if (CONFIG_BUILD_WITH_TFM)
7979
list(APPEND TFM_CMAKE_ARGS -DMCUBOOT_IMAGE_NUMBER=${CONFIG_TFM_MCUBOOT_IMAGE_NUMBER})
8080
endif()
8181

82+
if (CONFIG_TFM_EXCEPTION_INFO_DUMP)
83+
list(APPEND TFM_CMAKE_ARGS -DTFM_EXCEPTION_INFO_DUMP=ON)
84+
else()
85+
list(APPEND TFM_CMAKE_ARGS -DTFM_EXCEPTION_INFO_DUMP=OFF)
86+
endif()
87+
88+
if (CONFIG_TFM_PARTITION_LOG_LEVEL_DEBUG)
89+
set(TFM_PARTITION_LOG_LEVEL "TFM_PARTITION_LOG_LEVEL_DEBUG")
90+
elseif (CONFIG_TFM_PARTITION_LOG_LEVEL_INFO)
91+
set(TFM_PARTITION_LOG_LEVEL "TFM_PARTITION_LOG_LEVEL_INFO")
92+
elseif (CONFIG_TFM_PARTITION_LOG_LEVEL_ERROR)
93+
set(TFM_PARTITION_LOG_LEVEL "TFM_PARTITION_LOG_LEVEL_ERROR")
94+
elseif (CONFIG_TFM_PARTITION_LOG_LEVEL_SILENCE)
95+
set(TFM_PARTITION_LOG_LEVEL "TFM_PARTITION_LOG_LEVEL_SILENCE")
96+
endif()
97+
98+
list(APPEND TFM_CMAKE_ARGS -DTFM_PARTITION_LOG_LEVEL=${TFM_PARTITION_LOG_LEVEL})
99+
100+
if (CONFIG_TFM_SPM_LOG_LEVEL_DEBUG)
101+
set(TFM_SPM_LOG_LEVEL "TFM_SPM_LOG_LEVEL_DEBUG")
102+
elseif (CONFIG_TFM_SPM_LOG_LEVEL_INFO)
103+
set(TFM_SPM_LOG_LEVEL "TFM_SPM_LOG_LEVEL_INFO")
104+
elseif (CONFIG_TFM_SPM_LOG_LEVEL_ERROR)
105+
set(TFM_SPM_LOG_LEVEL "TFM_SPM_LOG_LEVEL_ERROR")
106+
elseif (CONFIG_TFM_SPM_LOG_LEVEL_SILENCE)
107+
set(TFM_SPM_LOG_LEVEL "TFM_PARTITION_LOG_LEVEL_SILENCE")
108+
endif()
109+
110+
list(APPEND TFM_CMAKE_ARGS -DTFM_SPM_LOG_LEVEL=${TFM_SPM_LOG_LEVEL})
111+
82112
# Enable TFM partitions as specified in Kconfig
83113
foreach(partition ${TFM_VALID_PARTITIONS})
84114
if (CONFIG_${partition})

modules/trusted-firmware-m/Kconfig.tfm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,23 @@ config TFM_FLASH_MERGED_BINARY
265265
(if building with TFM_BL2 is enabled), and the
266266
Non-Secure application firmware.
267267

268+
choice TFM_SPM_LOG_LEVEL
269+
prompt "TF-M SPM Log Level"
270+
default TFM_SPM_LOG_LEVEL_INFO
271+
config TFM_SPM_LOG_LEVEL_DEBUG
272+
bool "Debug"
273+
config TFM_SPM_LOG_LEVEL_INFO
274+
bool "Info"
275+
config TFM_SPM_LOG_LEVEL_ERROR
276+
bool "Error"
277+
config TFM_SPM_LOG_LEVEL_SILENCE
278+
bool "Off"
279+
endchoice
280+
281+
config TFM_EXCEPTION_INFO_DUMP
282+
bool "TF-M exception info dump"
283+
help
284+
On fatal errors in the secure firmware, capture info about the exception.
285+
Print the info if the SPM log level is sufficient.
286+
268287
endif # BUILD_WITH_TFM

modules/trusted-firmware-m/Kconfig.tfm.partitions

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,17 @@ config TFM_PARTITION_AUDIT_LOG
7474
Note: the Audit Log service does not implement the IPC model
7575
interface so it may not be enabled together with IPC option.
7676

77+
choice TFM_PARTITION_LOG_LEVEL
78+
prompt "TF-M Partition Log Level"
79+
default TFM_PARTITION_LOG_LEVEL_INFO
80+
config TFM_PARTITION_LOG_LEVEL_DEBUG
81+
bool "Debug"
82+
config TFM_PARTITION_LOG_LEVEL_INFO
83+
bool "Info"
84+
config TFM_PARTITION_LOG_LEVEL_ERROR
85+
bool "Error"
86+
config TFM_PARTITION_LOG_LEVEL_SILENCE
87+
bool "Off"
88+
endchoice
89+
7790
endif # BUILD_WITH_TFM

0 commit comments

Comments
 (0)