Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
82bc3ba
[zep fromtree] LIB: Add tfm_vprintf support for left formatting
jackson-cooperd Mar 14, 2025
4415528
[zep fromtree] LIB: Use tfm_log for BL2 logging
jackson-cooperd Mar 13, 2025
28a3715
[zep fromtree] LIB: Add _RAW macros
jackson-cooperd Mar 3, 2025
08ca17f
[zep fromtree] LIB: Change tfm_log_unpriv to INTERFACE library
jackson-cooperd Mar 3, 2025
8c5aa2b
[zep fromtree] LIB: Remove log/log_unpriv dependencies
jackson-cooperd Mar 13, 2025
26ddbc3
[zep fromtree] LIB: Allow tfm_log_unpriv to handle large strings
jackson-cooperd Mar 17, 2025
f4bed24
[zep fromtree] LIB: Add tfm_vprintf_unpriv
jackson-cooperd Mar 18, 2025
a0e36e2
[zep fromtree] LIB: Move partitions to use new logging API
jackson-cooperd Mar 3, 2025
e01e498
[zep fromtree] LIB: Replace SPM log with tfm_log
jackson-cooperd Mar 13, 2025
3fa8a8e
[zep fromtree] LIB: Use tfm_log for fatal error logging
jackson-cooperd Mar 13, 2025
8befe64
[zep fromtree] LIB: Partially rework BL2 logging
jackson-cooperd Mar 28, 2025
b6c8fb8
[zep fromtree] LIB: Return total printed chars from vprintf
jackson-cooperd Mar 28, 2025
b10ac75
[zep fromtree] LIB: Move tfm_vprintf definition to private header
jackson-cooperd Mar 31, 2025
54f12f0
[zep fromtree] LIB: Add with_marker argument to tfm_vprintf
jackson-cooperd Mar 31, 2025
0285f0a
[zep fromtree] LIB: Replace MCUBoot log level with BL2 log level
jackson-cooperd Mar 28, 2025
0421fe6
[zep fromtree] LIB: Link tfm_vprintf_headers to logging headers
jackson-cooperd Apr 3, 2025
e3f0f99
[zep fromtree] LIB: tfm_vprintf: Add %i format specifier
nicola-mazzucato-arm Mar 28, 2025
47b0152
[zep fromtree] LIB: Fix potential NULL pointer dereference
jackson-cooperd May 8, 2025
05b6c04
[zep fromtree] LIB: Add support for %X format specifier
jackson-cooperd Jul 9, 2025
04af9b0
[zep fromtree] platform: Add support of frdmmcxn947
waqar-tahir Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bl1/bl1_1/shared_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ target_link_libraries(bl1_1_shared_lib_interface
INTERFACE
psa_interface
tfm_fih_headers
tfm_vprintf_headers
tfm_log_headers
bl1_1_crypto_mbedcrypto
)
Expand All @@ -37,6 +36,7 @@ target_link_libraries(bl1_1_shared_lib
PUBLIC
bl1_1_shared_lib_interface
tfm_log
tfm_vprintf
PRIVATE
platform_bl1_1
)
Expand Down
5 changes: 1 addition & 4 deletions bl2/ext/mcuboot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#------------------------------------------------------------------------------
# Copyright (c) 2020-2024, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
Expand Down Expand Up @@ -72,9 +72,6 @@ target_link_libraries(bl2
bootutil
)

set(MCUBOOT_ALLOWED_LOG_LEVELS OFF ERROR WARNING INFO DEBUG)
list(FIND MCUBOOT_ALLOWED_LOG_LEVELS ${MCUBOOT_LOG_LEVEL} LOG_LEVEL_ID)

if (MCUBOOT_ALIGN_VAL GREATER 8)
set (MCUBOOT_BOOT_MAX_ALIGN ${MCUBOOT_ALIGN_VAL})
else()
Expand Down
44 changes: 26 additions & 18 deletions bl2/ext/mcuboot/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2023-2024, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
Expand Down Expand Up @@ -244,27 +244,35 @@ config MCUBOOT_PSA_CRYPTO_CONFIG_FILEPATH
string "Mbed TLS PSA Crypto config file to use with MCUboot"
default "$(TFM_SOURCE_DIR)/bl2/ext/mcuboot/config/mcuboot_crypto_config.h"

choice MCUBOOT_LOG_LEVEL_CHOICE
prompt "MCUBoot Log Level"
default MCUBOOT_LOG_LEVEL_INFO
choice BL2_LOG_LEVEL
prompt "TFM BL2 Log Level"
default LOG_LEVEL_INFO

config MCUBOOT_LOG_LEVEL_DEBUG
bool "Debug"
config MCUBOOT_LOG_LEVEL_INFO
config LOG_LEVEL_VERBOSE
bool "Verbose"

config LOG_LEVEL_INFO
bool "Info"
config MCUBOOT_LOG_LEVEL_WARNING

config LOG_LEVEL_WARNING
bool "Warning"
config MCUBOOT_LOG_LEVEL_ERROR

config LOG_LEVEL_NOTICE
bool "Notice"

config LOG_LEVEL_ERROR
bool "Error"
config MCUBOOT_LOG_LEVEL_OFF
bool "Off"

config LOG_LEVEL_NONE
bool "None"
endchoice

config MCUBOOT_LOG_LEVEL
string
default "DEBUG" if MCUBOOT_LOG_LEVEL_DEBUG
default "INFO" if MCUBOOT_LOG_LEVEL_INFO
default "WARNING" if MCUBOOT_LOG_LEVEL_WARNING
default "ERROR" if MCUBOOT_LOG_LEVEL_ERROR
default "OFF" if MCUBOOT_LOG_LEVEL_OFF
config TFM_BL2_LOG_LEVEL
int
default 50 if LOG_LEVEL_VERBOSE
default 40 if LOG_LEVEL_INFO
default 30 if LOG_LEVEL_WARN
default 20 if LOG_LEVEL_NOTICE
default 10 if LOG_LEVEL_ERROR
default 0 if LOG_LEVEL_NONE
endif
10 changes: 6 additions & 4 deletions bl2/ext/mcuboot/bl2_main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
* Copyright (c) 2017-2024 Arm Limited.
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,7 +92,7 @@ static void do_boot(struct boot_rsp *rsp)
rsp->br_hdr->ih_hdr_size);
}

#if (MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF) || defined(TEST_BL2)
#if (LOG_LEVEL > LOG_LEVEL_NONE) || defined(TEST_BL2)
stdio_uninit();
#endif

Expand Down Expand Up @@ -120,7 +122,7 @@ int main(void)
*/
mbedtls_memory_buffer_alloc_init(mbedtls_mem_buf, BL2_MBEDTLS_MEM_BUF_LEN);

#if (MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF) || defined(TEST_BL2)
#if (LOG_LEVEL > LOG_LEVEL_NONE) || defined(TEST_BL2)
stdio_init();
#if defined(TEST_BL2)
for (int i = 0; i < 0xFFFFF; i++) {
Expand All @@ -130,7 +132,7 @@ int main(void)
}
(void)stdio_output_string("\r\n", 2);
#endif /* defined(TEST_BL2) */
#endif /* (MCUBOOT_LOG_LEVEL > MCUBOOT_LOG_LEVEL_OFF) || defined(TEST_BL2) */
#endif /* (LOG_LEVEL > LOG_LEVEL_NONE) || defined(TEST_BL2) */

/* Perform platform specific initialization */
err = boot_platform_init();
Expand Down
5 changes: 2 additions & 3 deletions bl2/ext/mcuboot/include/mcuboot_config/mcuboot_config.h.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* Copyright (c) 2018 Open Source Foundries Limited
* Copyright (c) 2019-2024 Arm Limited
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: BSD-3-Clause
*/

/*
Expand Down Expand Up @@ -80,7 +80,6 @@ extern "C" {
* Logging
*/
#define MCUBOOT_HAVE_LOGGING 1
#define MCUBOOT_LOG_LEVEL @LOG_LEVEL_ID@

#endif /* !__BOOTSIM__ */

Expand Down
49 changes: 8 additions & 41 deletions bl2/ext/mcuboot/include/mcuboot_config/mcuboot_logging.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* Copyright (c) 2017 Linaro Limited
* Copyright (c) 2019 Arm Limited.
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,57 +20,22 @@
#ifndef __MCUBOOT_LOGGING_H__
#define __MCUBOOT_LOGGING_H__

#include "bootutil/ignore.h"
#include <stdio.h>
#include "tfm_log.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MCUBOOT_LOG_LEVEL_OFF 0
#define MCUBOOT_LOG_LEVEL_ERROR 1
#define MCUBOOT_LOG_LEVEL_WARNING 2
#define MCUBOOT_LOG_LEVEL_INFO 3
#define MCUBOOT_LOG_LEVEL_DEBUG 4

/*
* The compiled log level determines the maximum level that can be
* printed. Messages at or below this level can be printed.
*/
#ifndef MCUBOOT_LOG_LEVEL
#define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_INFO
#endif

#define MCUBOOT_LOG_MODULE_DECLARE(domain) /* Ignore */
#define MCUBOOT_LOG_MODULE_REGISTER(domain) /* Ignore */

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_ERROR
#define MCUBOOT_LOG_ERR(_fmt, ...) \
printf("[ERR] " _fmt "\r\n", ##__VA_ARGS__)
#else
#define MCUBOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
#endif
#define MCUBOOT_LOG_ERR(_fmt, ...) ERROR(_fmt "\n", ##__VA_ARGS__)

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_WARNING
#define MCUBOOT_LOG_WRN(_fmt, ...) \
printf("[WRN] " _fmt "\r\n", ##__VA_ARGS__)
#else
#define MCUBOOT_LOG_WRN(...) IGNORE(__VA_ARGS__)
#endif
#define MCUBOOT_LOG_WRN(_fmt, ...) WARN(_fmt "\n", ##__VA_ARGS__)

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_INFO
#define MCUBOOT_LOG_INF(_fmt, ...) \
printf("[INF] " _fmt "\r\n", ##__VA_ARGS__)
#else
#define MCUBOOT_LOG_INF(...) IGNORE(__VA_ARGS__)
#endif
#define MCUBOOT_LOG_INF(_fmt, ...) INFO(_fmt "\n", ##__VA_ARGS__)

#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_DEBUG
#define MCUBOOT_LOG_DBG(_fmt, ...) \
printf("[DBG] " _fmt "\r\n", ##__VA_ARGS__)
#else
#define MCUBOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
#endif
#define MCUBOOT_LOG_DBG(_fmt, ...) VERBOSE(_fmt "\n", ##__VA_ARGS__)

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion bl2/ext/mcuboot/mcuboot_default_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(MCUBOOT_NS_IMAGE_FLASH_AREA_NUM 1 CACHE STRING "ID of the f

set(MCUBOOT_IMAGE_NUMBER 2 CACHE STRING "Whether to combine S and NS into either 1 image, or sign each seperately")
set(MCUBOOT_EXECUTION_SLOT 1 CACHE STRING "Slot from which to execute the image, used for XIP mode")
set(MCUBOOT_LOG_LEVEL "INFO" CACHE STRING "Level of logging to use for MCUboot [OFF, ERROR, WARNING, INFO, DEBUG]")
set(TFM_BL2_LOG_LEVEL LOG_LEVEL_INFO CACHE STRING "Level of logging to use for BL2: LOG_LEVEL_[NONE, ERROR, WARNING, INFO, VERBOSE]")
set(MCUBOOT_HW_KEY ON CACHE BOOL "Whether to embed the entire public key in the image metadata instead of the hash only")
set(MCUBOOT_BUILTIN_KEY OFF CACHE BOOL "Use builtin key(s) for validation, no public key data is embedded into the image metadata")
set(MCUBOOT_UPGRADE_STRATEGY "OVERWRITE_ONLY" CACHE STRING "Upgrade strategy for images")
Expand Down
6 changes: 3 additions & 3 deletions config/build_type/Kconfig.debug
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2023, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
Expand All @@ -15,9 +15,9 @@ config CONFIG_TFM_HALT_ON_CORE_PANIC
default y

choice SPM_LOG_LEVEL
default SPM_LOG_LEVEL_DEBUG
default LOG_LEVEL_VERBOSE
endchoice

choice PARTITION_LOG_LEVEL
default PARTITION_LOG_LEVEL_DEBUG
default LOG_LEVEL_VERBOSE
endchoice
10 changes: 5 additions & 5 deletions config/build_type/Kconfig.minsizerel
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2023, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

if BL2
config MCUBOOT_LOG_LEVEL
default "OFF"
config BL2_LOG_LEVEL
default LOG_LEVEL_NONE
endif

choice SPM_LOG_LEVEL
default SPM_LOG_LEVEL_SILENCE
default LOG_LEVEL_NONE
endchoice

choice PARTITION_LOG_LEVEL
default PARTITION_LOG_LEVEL_SILENCE
default LOG_LEVEL_NONE
endchoice
10 changes: 5 additions & 5 deletions config/build_type/Kconfig.release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2023, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
Expand All @@ -12,14 +12,14 @@ config BL1_2_BUILD_TYPE
default "minsizerel"

if BL2
config MCUBOOT_LOG_LEVEL
default "OFF"
config BL2_LOG_LEVEL
default LOG_LEVEL_NONE
endif

choice SPM_LOG_LEVEL
default SPM_LOG_LEVEL_SILENCE
default LOG_LEVEL_NONE
endchoice

choice PARTITION_LOG_LEVEL
default PARTITION_LOG_LEVEL_SILENCE
default LOG_LEVEL_NONE
endchoice
6 changes: 3 additions & 3 deletions config/build_type/debug.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

set(MBEDCRYPTO_BUILD_TYPE relwithdebinfo CACHE STRING "Build type of Mbed Crypto library")
set(BL1_2_BUILD_TYPE relwithdebinfo CACHE STRING "Build type of BL1_2")
set(TFM_SPM_LOG_LEVEL TFM_SPM_LOG_LEVEL_DEBUG CACHE STRING "Set debug SPM log level as Debug level")
set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_DEBUG CACHE STRING "Set debug SP log level as Debug level")
set(TFM_SPM_LOG_LEVEL LOG_LEVEL_VERBOSE CACHE STRING "Set debug SPM log level as Debug level")
set(TFM_PARTITION_LOG_LEVEL LOG_LEVEL_VERBOSE CACHE STRING "Set debug SP log level as Debug level")

set(CONFIG_TFM_HALT_ON_CORE_PANIC ON CACHE BOOL "On fatal errors in the secure firmware, halt instead of rebooting.")
8 changes: 4 additions & 4 deletions config/build_type/minsizerel.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

set(MCUBOOT_LOG_LEVEL "OFF" CACHE STRING "Level of logging to use for MCUboot [OFF, ERROR, WARNING, INFO, DEBUG]")
set(TFM_SPM_LOG_LEVEL TFM_SPM_LOG_LEVEL_SILENCE CACHE STRING "Set minsizerel SPM log level as Silence level")
set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_SILENCE CACHE STRING "Set minsizerel SP log level as Silence level")
set(TFM_BL2_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Level of logging to use for BL2: LOG_LEVEL_[NONE, ERROR, WARNING, INFO, VERBOSE]")
set(TFM_SPM_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Set minsizerel SPM log level as Silence level")
set(TFM_PARTITION_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Set minsizerel SP log level as Silence level")
set(TFM_BL1_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "The level of BL1 logging to uart")
8 changes: 4 additions & 4 deletions config/build_type/release.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

set(MBEDCRYPTO_BUILD_TYPE minsizerel CACHE STRING "Build type of Mbed Crypto library")
set(BL1_2_BUILD_TYPE minsizerel CACHE STRING "Build type of BL1_2")
set(MCUBOOT_LOG_LEVEL "OFF" CACHE STRING "Level of logging to use for MCUboot [OFF, ERROR, WARNING, INFO, DEBUG]")
set(TFM_SPM_LOG_LEVEL TFM_SPM_LOG_LEVEL_SILENCE CACHE STRING "Set release SPM log level as Silence level")
set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_SILENCE CACHE STRING "Set release SP log level as Silence level")
set(TFM_BL2_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Level of logging to use for BL2: LOG_LEVEL_[NONE, ERROR, WARNING, INFO, VERBOSE]")
set(TFM_SPM_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Set release SPM log level as Silence level")
set(TFM_PARTITION_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Set release SP log level as Silence level")
set(TFM_BL1_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "The level of BL1 logging to uart")
10 changes: 5 additions & 5 deletions config/tfm_secure_log.cmake
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2021, Arm Limited. All rights reserved.
# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------

set(TFM_SPM_LOG_LEVEL TFM_SPM_LOG_LEVEL_SILENCE CACHE STRING "Set default SPM log level as INFO level")
set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_SILENCE CACHE STRING "Set default Secure Partition log level as INFO level")
set(TFM_SPM_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Set default SPM log level as INFO level")
set(TFM_PARTITION_LOG_LEVEL LOG_LEVEL_NONE CACHE STRING "Set default Secure Partition log level as INFO level")

# Secure regression tests also require SP log function
# Enable SP log raw dump when SP log level is higher than silence or TF-M
# regression test is enabled.
if ((NOT ${TFM_PARTITION_LOG_LEVEL} STREQUAL TFM_PARTITION_LOG_LEVEL_SILENCE)
if ((NOT ${TFM_PARTITION_LOG_LEVEL} STREQUAL LOG_LEVEL_NONE)
OR TFM_S_REG_TEST OR TFM_NS_REG_TEST)
set(TFM_SP_LOG_RAW_ENABLED ON)
endif()

# SP log relies on SPM log.
# Enable SPM log when SPM log level is higher than silence or SP log is active.
if ((NOT ${TFM_SPM_LOG_LEVEL} STREQUAL TFM_SPM_LOG_LEVEL_SILENCE)
if ((NOT ${TFM_SPM_LOG_LEVEL} STREQUAL LOG_LEVEL_NONE)
OR TFM_SP_LOG_RAW_ENABLED)
set(TFM_SPM_LOG_RAW_ENABLED ON)
endif()
Loading