Skip to content

Commit e5bcb7d

Browse files
frkvtomi-font
authored andcommitted
[nrf noup] secure_fw: Add option to log output on a shared UART instance.
Add an option to send the log output from the secure firmware on a UART instance that would be shared with the non-secure application. This option is added where the number of UART instances is limited and the application only cares about the receiving the TF-M log on fatal errors. To allow this option to be enabled the log is disabled in the boot process before the non-secure application is started. It is enabled again when an unrecoverable exception has occurred in the secure firmware. Here is an abandoned upstream PR (with some of the fixes): https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/25905 Note: This has removed any information about cherry-picked items as this is not valid since it is combining efforts form multiple commits Ref: NCSDK-18595 Ref: NCSDK-28740 Signed-off-by: Joakim Andersson <[email protected]> Signed-off-by: Markus Swarowsky <[email protected]> Signed-off-by: Sebastian Bøe <[email protected]> Signed-off-by: Frank Audun Kvamtrø <[email protected]>
1 parent cffaa81 commit e5bcb7d

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

config/check_config.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ tfm_invalid_config(TFM_MULTI_CORE_TOPOLOGY AND TFM_NS_MANAGE_NSID)
1717
tfm_invalid_config(TFM_PLAT_SPECIFIC_MULTI_CORE_COMM AND NOT TFM_MULTI_CORE_TOPOLOGY)
1818
tfm_invalid_config(TFM_ISOLATION_LEVEL EQUAL 3 AND CONFIG_TFM_STACK_WATERMARKS)
1919

20+
tfm_invalid_config(CONFIG_TFM_LOG_SHARE_UART AND NOT SECURE_UART1)
21+
2022
########################## BL1 #################################################
2123

2224
tfm_invalid_config(TFM_BL1_2_IN_OTP AND TFM_BL1_2_IN_FLASH)

config/config_base.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ set(CONFIG_TFM_HALT_ON_CORE_PANIC OFF CACHE BOOL "On fatal e
9090

9191
set(CONFIG_TFM_STACK_WATERMARKS OFF CACHE BOOL "Whether to pre-fill partition stacks with a set value to help determine stack usage")
9292

93+
set(CONFIG_TFM_LOG_SHARE_UART OFF CACHE BOOL "Allow TF-M and the non-secure application to share the UART instance. TF-M will use it while it is booting, after which the non-secure application will use it until an eventual fatal error is handled and logged by TF-M. Logging from TF-M will therefore otherwise be suppressed")
9394
############################ Platform ##########################################
9495

9596
set(NUM_MAILBOX_QUEUE_SLOT 1 CACHE BOOL "Number of mailbox queue slots")

platform/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ target_compile_definitions(platform_region_defs
383383
BL1_TRAILER_SIZE=${BL1_TRAILER_SIZE}
384384
$<$<BOOL:${PLATFORM_DEFAULT_BL1}>:PLATFORM_DEFAULT_BL1>
385385
$<$<BOOL:${SECURE_UART1}>:SECURE_UART1>
386+
$<$<BOOL:${CONFIG_TFM_LOG_SHARE_UART}>:CONFIG_TFM_LOG_SHARE_UART>
386387
DAUTH_${DEBUG_AUTHENTICATION}
387388
$<$<BOOL:${MCUBOOT_IMAGE_NUMBER}>:MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}>
388389
$<$<BOOL:${MCUBOOT_BUILTIN_KEY}>:MCUBOOT_BUILTIN_KEY>

platform/ext/common/exception_info.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "tfm_spm_log.h"
1010
/* "exception_info.h" must be the last include because of the IAR pragma */
1111
#include "exception_info.h"
12+
#include "uart_stdout.h"
1213

1314
static struct exception_info_t exception_info;
1415

@@ -168,6 +169,10 @@ static void dump_error(const struct exception_info_t *ctx)
168169
{
169170
bool stack_error = false;
170171

172+
#if defined(CONFIG_TFM_LOG_SHARE_UART)
173+
stdio_init();
174+
#endif
175+
171176
SPMLOG_ERRMSG("FATAL ERROR: ");
172177
switch (ctx->VECTACTIVE) {
173178
case EXCEPTION_TYPE_HARDFAULT:

secure_fw/spm/core/tfm_svcalls.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static uint32_t handle_spm_svc_requests(uint32_t svc_number, uint32_t exc_return
204204
case TFM_SVC_SPM_INIT:
205205
exc_return = tfm_spm_init();
206206
tfm_arch_check_msp_sealing();
207+
207208
/* The following call does not return */
208209
tfm_arch_free_msp_and_exc_ret(SPM_BOOT_STACK_BOTTOM, exc_return);
209210
break;

0 commit comments

Comments
 (0)