boot: zephyr: migrate to new log subystem
The old log subsystem has been deprecated in Zephyr.
Migrate to the new subsystem to avoid compilation warnings.
In-place log processing is selected as it is required as MCUBoot is
one thread application.
Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig
index e87db5a..2ce1b2d 100644
--- a/boot/zephyr/Kconfig
+++ b/boot/zephyr/Kconfig
@@ -132,10 +132,11 @@
config BOOT_HAVE_LOGGING
bool "MCUboot have logging enabled"
default y
- select SYS_LOG
+ select LOG
+ select LOG_INPLACE_PROCESS
help
If y, enables logging on the serial port. The log level can
- be defined by setting `SYS_LOG_DEFAULT_LEVEL`.
+ be defined by setting `LOG_DEFAULT_LEVEL`.
If unsure, leave at the default value.
menuconfig MCUBOOT_SERIAL
diff --git a/boot/zephyr/boards/nrf52840_pca10059.conf b/boot/zephyr/boards/nrf52840_pca10059.conf
index bf63bf7..89cc154 100644
--- a/boot/zephyr/boards/nrf52840_pca10059.conf
+++ b/boot/zephyr/boards/nrf52840_pca10059.conf
@@ -25,6 +25,3 @@
CONFIG_USB_CDC_ACM=y
CONFIG_USB_COMPOSITE_DEVICE=n
CONFIG_USB_MASS_STORAGE=n
-
-# Logging
-CONFIG_SYS_LOG_DEFAULT_LEVEL=1
diff --git a/boot/zephyr/flash_map_extended.c b/boot/zephyr/flash_map_extended.c
index b7fa610..db2f94b 100644
--- a/boot/zephyr/flash_map_extended.c
+++ b/boot/zephyr/flash_map_extended.c
@@ -15,6 +15,8 @@
#include "bootutil/bootutil_log.h"
+MCUBOOT_LOG_MODULE_DECLARE(mcuboot);
+
#if (!defined(CONFIG_XTENSA) && defined(DT_FLASH_DEV_NAME))
#define FLASH_DEVICE_ID SOC_FLASH_0_ID
#elif (defined(CONFIG_XTENSA) && defined(DT_SPI_NOR_DRV_NAME))
diff --git a/boot/zephyr/flash_map_legacy.c b/boot/zephyr/flash_map_legacy.c
index 69803fe..b217947 100644
--- a/boot/zephyr/flash_map_legacy.c
+++ b/boot/zephyr/flash_map_legacy.c
@@ -49,6 +49,8 @@
#define FLASH_AREA_IMAGE_SECTOR_SIZE FLASH_AREA_IMAGE_SCRATCH_SIZE
#endif
+MCUBOOT_LOG_MODULE_DECLARE(mcuboot);
+
/*
* Lookup the sector map for a given flash area. This should fill in
* `ret` with all of the sectors in the area. `*cnt` will be set to
diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_logging.h b/boot/zephyr/include/mcuboot_config/mcuboot_logging.h
index 8ee5378..5077451 100644
--- a/boot/zephyr/include/mcuboot_config/mcuboot_logging.h
+++ b/boot/zephyr/include/mcuboot_config/mcuboot_logging.h
@@ -12,38 +12,17 @@
/*
* When building for targets running Zephyr, delegate to its native
* logging subsystem.
- *
- * In this case:
- *
- * - MCUBOOT_LOG_LEVEL determines SYS_LOG_LEVEL,
- * - MCUBOOT_LOG_ERR() and friends are SYS_LOG_ERR() etc.
- * - SYS_LOG_DOMAIN is unconditionally set to "MCUBOOT"
*/
-#define MCUBOOT_LOG_LEVEL_OFF SYS_LOG_LEVEL_OFF
-#define MCUBOOT_LOG_LEVEL_ERROR SYS_LOG_LEVEL_ERROR
-#define MCUBOOT_LOG_LEVEL_WARNING SYS_LOG_LEVEL_WARNING
-#define MCUBOOT_LOG_LEVEL_INFO SYS_LOG_LEVEL_INFO
-#define MCUBOOT_LOG_LEVEL_DEBUG SYS_LOG_LEVEL_DEBUG
-/* Treat MCUBOOT_LOG_LEVEL equivalently to SYS_LOG_LEVEL. */
-#ifndef MCUBOOT_LOG_LEVEL
-#define MCUBOOT_LOG_LEVEL CONFIG_SYS_LOG_DEFAULT_LEVEL
-#elif (MCUBOOT_LOG_LEVEL < CONFIG_SYS_LOG_OVERRIDE_LEVEL)
-#undef MCUBOOT_LOG_LEVEL
-#define MCUBOOT_LOG_LEVEL CONFIG_SYS_LOG_OVERRIDE_LEVEL
-#endif
+#define MCUBOOT_LOG_MODULE_DECLARE(domain) LOG_MODULE_DECLARE(domain)
+#define MCUBOOT_LOG_MODULE_REGISTER(domain) LOG_MODULE_REGISTER(domain)
-#define SYS_LOG_LEVEL MCUBOOT_LOG_LEVEL
+#define MCUBOOT_LOG_ERR(...) LOG_ERR(__VA_ARGS__)
+#define MCUBOOT_LOG_WRN(...) LOG_WRN(__VA_ARGS__)
+#define MCUBOOT_LOG_INF(...) LOG_INF(__VA_ARGS__)
+#define MCUBOOT_LOG_DBG(...) LOG_DBG(__VA_ARGS__)
-#undef SYS_LOG_DOMAIN
-#define SYS_LOG_DOMAIN "MCUBOOT"
-
-#define MCUBOOT_LOG_ERR(...) SYS_LOG_ERR(__VA_ARGS__)
-#define MCUBOOT_LOG_WRN(...) SYS_LOG_WRN(__VA_ARGS__)
-#define MCUBOOT_LOG_INF(...) SYS_LOG_INF(__VA_ARGS__)
-#define MCUBOOT_LOG_DBG(...) SYS_LOG_DBG(__VA_ARGS__)
-
-#include <logging/sys_log.h>
+#include <logging/log.h>
#endif /* !__BOOTSIM__ */
diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
index 345b449..f4bc4ab 100644
--- a/boot/zephyr/main.c
+++ b/boot/zephyr/main.c
@@ -40,6 +40,8 @@
};
#endif
+MCUBOOT_LOG_MODULE_REGISTER(mcuboot);
+
void os_heap_init(void);
#if defined(CONFIG_ARM)
diff --git a/boot/zephyr/prj.conf b/boot/zephyr/prj.conf
index 8a88abc..3bc1e02 100644
--- a/boot/zephyr/prj.conf
+++ b/boot/zephyr/prj.conf
@@ -1,5 +1,4 @@
CONFIG_CONSOLE_HANDLER=y
-CONFIG_SYS_LOG=y
CONFIG_DEBUG=y
CONFIG_SYSTEM_CLOCK_DISABLE=y
CONFIG_SYS_POWER_MANAGEMENT=n
diff --git a/boot/zephyr/serial_adapter.c b/boot/zephyr/serial_adapter.c
index fc39f71..14adb45 100644
--- a/boot/zephyr/serial_adapter.c
+++ b/boot/zephyr/serial_adapter.c
@@ -25,6 +25,8 @@
#error Zephyr UART console must been disabled if serial_adapter module is used.
#endif
+MCUBOOT_LOG_MODULE_REGISTER(serial_adapter);
+
/** @brief Console input representation
*
* This struct is used to represent an input line from a serial interface.