bootutil: extracted app common library from bootutil_misc
Part of code of boot/bootutil/ is re-implemented in zephyr-rtos
repository.
As some code are defined here and there it becomes problem when
need to include it with outstanding feature in a build.
It is possible to mitigate problem using #fdefry - but this was
rather temporary hack.
This patch introduce new module which is common for MCUBoot build
and application build.
Common code were extracted to bootutil_public.c source file and
bootutil_public.h header
MCUboot also select DISABLE_MCUBOOT_BOOTUTIL_LIB_OWN_LOG Kconfig
option, as it must define log configuration on its own for all its
sourcecode.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
diff --git a/boot/zephyr/CMakeLists.txt b/boot/zephyr/CMakeLists.txt
index 1b6024d..49b0fa0 100644
--- a/boot/zephyr/CMakeLists.txt
+++ b/boot/zephyr/CMakeLists.txt
@@ -113,6 +113,9 @@
${BOOT_DIR}/bootutil/src/fault_injection_hardening.c
)
+# library which might be common source code for MCUBoot and an application
+zephyr_link_libraries(MCUBOOT_BOOTUTIL)
+
if(CONFIG_BOOT_FIH_PROFILE_HIGH)
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/fault_injection_hardening_delay_rng_mbedtls.c
diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig
index 0d0bed3..ef3e834 100644
--- a/boot/zephyr/Kconfig
+++ b/boot/zephyr/Kconfig
@@ -14,6 +14,7 @@
bool
select MPU_ALLOW_FLASH_WRITE if ARM_MPU
select USE_DT_CODE_PARTITION if HAS_FLASH_LOAD_OFFSET
+ select MCUBOOT_BOOTUTIL_LIB
config BOOT_USE_MBEDTLS
bool
@@ -573,4 +574,9 @@
config USB_DEVICE_PRODUCT
default "MCUBOOT"
+# use MCUboot's own log configuration
+config MCUBOOT_BOOTUTIL_LIB_OWN_LOG
+ bool
+ default n
+
source "Kconfig.zephyr"
diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_config.h b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
index 4f852be..8f2b157 100644
--- a/boot/zephyr/include/mcuboot_config/mcuboot_config.h
+++ b/boot/zephyr/include/mcuboot_config/mcuboot_config.h
@@ -154,8 +154,14 @@
*/
#define MCUBOOT_USE_FLASH_AREA_GET_SECTORS
+#ifdef CONFIG_BOOT_MAX_IMG_SECTORS
+
#define MCUBOOT_MAX_IMG_SECTORS CONFIG_BOOT_MAX_IMG_SECTORS
+#else
+#define MCUBOOT_MAX_IMG_SECTORS 128
+#endif
+
#endif /* !__BOOTSIM__ */
#if CONFIG_BOOT_WATCHDOG_FEED
diff --git a/boot/zephyr/include/mcuboot_config/mcuboot_logging.h b/boot/zephyr/include/mcuboot_config/mcuboot_logging.h
index fa43a80..6f24868 100644
--- a/boot/zephyr/include/mcuboot_config/mcuboot_logging.h
+++ b/boot/zephyr/include/mcuboot_config/mcuboot_logging.h
@@ -13,9 +13,13 @@
* When building for targets running Zephyr, delegate to its native
* logging subsystem.
*/
-
+#ifdef CONFIG_MCUBOOT
#define MCUBOOT_LOG_MODULE_DECLARE(domain) LOG_MODULE_DECLARE(domain, CONFIG_MCUBOOT_LOG_LEVEL)
#define MCUBOOT_LOG_MODULE_REGISTER(domain) LOG_MODULE_REGISTER(domain, CONFIG_MCUBOOT_LOG_LEVEL)
+#else
+#define MCUBOOT_LOG_MODULE_DECLARE(domain) LOG_MODULE_DECLARE(domain, CONFIG_MCUBOOT_UTIL_LOG_LEVEL)
+#define MCUBOOT_LOG_MODULE_REGISTER(domain) LOG_MODULE_REGISTER(domain, CONFIG_MCUBOOT_UTIL_LOG_LEVEL)
+#endif
#define MCUBOOT_LOG_ERR(...) LOG_ERR(__VA_ARGS__)
#define MCUBOOT_LOG_WRN(...) LOG_WRN(__VA_ARGS__)