Skip to content

Commit 00db276

Browse files
committed
Mbed: Allow logging if mbed trace is disabled
1 parent d131ce2 commit 00db276

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

boot/mbed/include/mcuboot_config/mcuboot_config.h

+5
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,9 @@
9292
do { \
9393
} while (0)
9494

95+
/*
96+
* Enable MCUBoot logging
97+
*/
98+
#define MCUBOOT_HAVE_LOGGING
99+
95100
#endif /* __MCUBOOT_CONFIG_H__ */

boot/mbed/include/mcuboot_config/mcuboot_logging.h

+30-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef __MCUBOOT_LOGGING_H__
2323
#define __MCUBOOT_LOGGING_H__
2424

25+
#include <stdio.h>
26+
2527
#define MCUBOOT_LOG_LEVEL_OFF 0
2628
#define MCUBOOT_LOG_LEVEL_ERROR 1
2729
#define MCUBOOT_LOG_LEVEL_WARNING 2
@@ -39,7 +41,6 @@
3941
#if MCUBOOT_LOG_LEVEL == MCUBOOT_LOG_LEVEL_OFF
4042
#define MBED_CONF_MBED_TRACE_ENABLE 0
4143
#else
42-
#define MBED_CONF_MBED_TRACE_ENABLE 1
4344
#define MCUBOOT_HAVE_LOGGING
4445
#endif
4546

@@ -61,26 +62,54 @@
6162
#define MCUBOOT_LOG_MODULE_REGISTER(domain) /* ignore */
6263

6364
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_ERROR
65+
#if MBED_CONF_MBED_TRACE_ENABLE
6466
#define MCUBOOT_LOG_ERR tr_error
6567
#else
68+
#define MCUBOOT_LOG_ERR(_fmt, ...) \
69+
do { \
70+
printf("E-" _fmt "\n", ##__VA_ARGS__); \
71+
} while (0)
72+
#endif
73+
#else
6674
#define MCUBOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
6775
#endif
6876

6977
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_WARNING
78+
#if MBED_CONF_MBED_TRACE_ENABLE
7079
#define MCUBOOT_LOG_WRN tr_warn
7180
#else
81+
#define MCUBOOT_LOG_WRN(_fmt, ...) \
82+
do { \
83+
printf("W-" _fmt "\n", ##__VA_ARGS__); \
84+
} while (0)
85+
#endif
86+
#else
7287
#define MCUBOOT_LOG_WRN(...) IGNORE(__VA_ARGS__)
7388
#endif
7489

7590
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_INFO
91+
#if MBED_CONF_MBED_TRACE_ENABLE
7692
#define MCUBOOT_LOG_INF tr_info
7793
#else
94+
#define MCUBOOT_LOG_INF(_fmt, ...) \
95+
do { \
96+
printf("I-" _fmt "\n", ##__VA_ARGS__); \
97+
} while (0)
98+
#endif
99+
#else
78100
#define MCUBOOT_LOG_INF(...) IGNORE(__VA_ARGS__)
79101
#endif
80102

81103
#if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_DEBUG
104+
#if MBED_CONF_MBED_TRACE_ENABLE
82105
#define MCUBOOT_LOG_DBG tr_debug
83106
#else
107+
#define MCUBOOT_LOG_DBG(_fmt, ...) \
108+
do { \
109+
printf("D-" _fmt "\n", ##__VA_ARGS__); \
110+
} while (0)
111+
#endif
112+
#else
84113
#define MCUBOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
85114
#endif
86115

0 commit comments

Comments
 (0)