Skip to content

Commit 854f7ec

Browse files
jackson-cooperdstgloorious
authored andcommitted
LIB: Partially rework BL2 logging
Instead of verifying that the LOG_LEVEL matches the MCUBOOT_LOG_LEVEL, completely ignore the definition of LOG_LEVEL for MCUBoot logging and ensure that instead we only use the MCUBOOT_LOG_LEVEL macro to determine the level to log at. We achieve this by setting the LOG_LEVEL to LOG_LEVEL_VERBOSE which compiles in all logging macros and allow the MCUBOOT_LOG_LEVEL to set which level to log at. Change-Id: I343774306734499b691fde04cd87626ff6d13add Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com> (cherry picked from commit 1fe05e9) Signed-off-by: Stefan Gloor <stefan.gloor@siemens.com>
1 parent a69c7ee commit 854f7ec

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

bl2/ext/mcuboot/include/mcuboot_config/mcuboot_logging.h

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
#define __MCUBOOT_LOGGING_H__
2020

2121
#include "bootutil/ignore.h"
22+
23+
/*
24+
* MCUBoot uses MCUBOOT_LOG_LEVEL to specify the log level
25+
* but tfm_log.h requires the definition of LOG_LEVEL. Define
26+
* the maximum possible LOG_LEVEL which ensures that all
27+
* macros are valid. MCUBoot can then use its log level
28+
* to determine what to log.
29+
*/
30+
#undef LOG_LEVEL
31+
#define LOG_LEVEL LOG_LEVEL_VERBOSE
2232
#include "tfm_log.h"
2333

2434
#ifdef __cplusplus
@@ -31,26 +41,40 @@ extern "C" {
3141
#define MCUBOOT_LOG_LEVEL_INFO LOG_LEVEL_INFO
3242
#define MCUBOOT_LOG_LEVEL_DEBUG LOG_LEVEL_VERBOSE
3343

34-
#if defined(MCUBOOT_LOG_LEVEL) && (MCUBOOT_LOG_LEVEL != LOG_LEVEL)
35-
#error "MCUBOOT_LOG_LEVEL does not match LOG_LEVEL"
36-
#elif !defined(MCUBOOT_LOG_LEVEL)
37-
#define MCUBOOT_LOG_LEVEL LOG_LEVEL
44+
#ifndef MCUBOOT_LOG_LEVEL
45+
#define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_INFO
3846
#endif
3947

4048
#define MCUBOOT_LOG_MODULE_DECLARE(domain) /* Ignore */
4149
#define MCUBOOT_LOG_MODULE_REGISTER(domain) /* Ignore */
4250

43-
#define MCUBOOT_LOG_ERR(_fmt, ...) \
51+
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_ERROR
52+
#define MCUBOOT_LOG_ERR(_fmt, ...) \
4453
ERROR(_fmt "\n", ##__VA_ARGS__)
54+
#else
55+
#define MCUBOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
56+
#endif
4557

46-
#define MCUBOOT_LOG_WRN(_fmt, ...) \
58+
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_WARNING
59+
#define MCUBOOT_LOG_WRN(_fmt, ...) \
4760
WARN(_fmt "\n", ##__VA_ARGS__)
61+
#else
62+
#define MCUBOOT_LOG_WRN(...) IGNORE(__VA_ARGS__)
63+
#endif
4864

49-
#define MCUBOOT_LOG_INF(_fmt, ...) \
65+
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_INFO
66+
#define MCUBOOT_LOG_INF(_fmt, ...) \
5067
INFO(_fmt "\n", ##__VA_ARGS__)
68+
#else
69+
#define MCUBOOT_LOG_INF(...) IGNORE(__VA_ARGS__)
70+
#endif
5171

52-
#define MCUBOOT_LOG_DBG(_fmt, ...) \
72+
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_DEBUG
73+
#define MCUBOOT_LOG_DBG(_fmt, ...) \
5374
VERBOSE(_fmt "\n", ##__VA_ARGS__)
75+
#else
76+
#define MCUBOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
77+
#endif
5478

5579
#ifdef __cplusplus
5680
}

secure_fw/partitions/firmware_update/bootloader/mcuboot/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ target_compile_definitions(tfm_psa_rot_partition_fwu
4444
PRIVATE
4545
MCUBOOT_${MCUBOOT_UPGRADE_STRATEGY}
4646
$<$<BOOL:${MCUBOOT_DIRECT_XIP_REVERT}>:MCUBOOT_DIRECT_XIP_REVERT>
47-
LOG_LEVEL=${BL2_LOG_LEVEL}
4847
)

0 commit comments

Comments
 (0)