From 41c568aba727efbd79a1c5e6e07f918a36452fcd Mon Sep 17 00:00:00 2001 From: Artur Tynecki Date: Tue, 8 Feb 2022 10:55:24 +0100 Subject: [PATCH] mbed: Add enable MCUboot logging parameter and fix logging configuration This commit add option for a user to enable MCUboot logging from project configuration level. Now, logging from MCUboot's sources will be printed in the same way as mbed-os logs. Co-created by @AGlass0fMilk - George Beckstein Signed-off-by: Artur Tynecki Signed-off-by: George Beckstein --- boot/mbed/include/mcuboot_config/mcuboot_logging.h | 7 ------- boot/mbed/mbed_lib.json | 6 ++++++ boot/mbed/mcuboot_main.cpp | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/boot/mbed/include/mcuboot_config/mcuboot_logging.h b/boot/mbed/include/mcuboot_config/mcuboot_logging.h index fc5282e7..c6a1cf78 100644 --- a/boot/mbed/include/mcuboot_config/mcuboot_logging.h +++ b/boot/mbed/include/mcuboot_config/mcuboot_logging.h @@ -36,13 +36,6 @@ #define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_OFF #endif -#if MCUBOOT_LOG_LEVEL == MCUBOOT_LOG_LEVEL_OFF -#define MBED_CONF_MBED_TRACE_ENABLE 0 -#else -#define MBED_CONF_MBED_TRACE_ENABLE 1 -#define MCUBOOT_HAVE_LOGGING -#endif - #if MCUBOOT_LOG_LEVEL == MCUBOOT_LOG_LEVEL_ERROR #define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_ERROR #elif MCUBOOT_LOG_LEVEL == MCUBOOT_LOG_LEVEL_WARNING diff --git a/boot/mbed/mbed_lib.json b/boot/mbed/mbed_lib.json index ae8e2885..afab39fe 100644 --- a/boot/mbed/mbed_lib.json +++ b/boot/mbed/mbed_lib.json @@ -64,6 +64,12 @@ "accepted_values": [true, null], "value": null }, + "log-enable": { + "help": "Enable MCUboot logging. Must also enable mbed-trace", + "macro_name": "MCUBOOT_HAVE_LOGGING", + "accepted_values": [true, null], + "value": null + }, "log-level": { "help": "Verbosity of MCUboot logging.", "macro_name": "MCUBOOT_LOG_LEVEL", diff --git a/boot/mbed/mcuboot_main.cpp b/boot/mbed/mcuboot_main.cpp index 4acb34d8..bf95e3ab 100644 --- a/boot/mbed/mcuboot_main.cpp +++ b/boot/mbed/mcuboot_main.cpp @@ -50,10 +50,12 @@ int main() { int rc; +#ifdef MCUBOOT_HAVE_LOGGING mbed_trace_init(); #if MCUBOOT_LOG_BOOTLOADER_ONLY mbed_trace_include_filters_set("MCUb,BL"); -#endif +#endif //MCUBOOT_LOG_BOOTLOADER_ONLY +#endif //MCUBOOT_HAVE_LOGGING tr_info("Starting MCUboot");