Boot: Make MCUBoot logging optional
Add new MCUBOOT_LOG_LEVEL CMake variable to the MCUBoot configuration.
In a debug build the MCUBoot logging can be set to several levels.
The logging can also be entirely disabled and thus the code size can be
reduced. In case of a release build the value of MCUBOOT_LOG_LEVEL is
overridden and the logging is disabled in MCUBoot.
Change-Id: I55ad8f85fdd0921f07a9c156858fadecf81a7449
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/bl2/ext/mcuboot/MCUBootConfig.cmake b/bl2/ext/mcuboot/MCUBootConfig.cmake
index 67526b1c..97edcfa 100644
--- a/bl2/ext/mcuboot/MCUBootConfig.cmake
+++ b/bl2/ext/mcuboot/MCUBootConfig.cmake
@@ -27,6 +27,13 @@
set(MCUBOOT_HW_KEY On CACHE BOOL "Configure to use HW key for image verification. Otherwise key is embedded in MCUBoot image.")
+ set(MCUBOOT_LOG_LEVEL "LOG_LEVEL_INFO" CACHE STRING "Configure the level of logging in MCUBoot.")
+ set_property(CACHE MCUBOOT_LOG_LEVEL PROPERTY STRINGS "LOG_LEVEL_OFF;LOG_LEVEL_ERROR;LOG_LEVEL_WARNING;LOG_LEVEL_INFO;LOG_LEVEL_DEBUG")
+ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(MCUBOOT_LOG_LEVEL "LOG_LEVEL_OFF")
+ endif()
+ validate_cache_value(MCUBOOT_LOG_LEVEL)
+
if ((${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP" OR
${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING") AND
NOT (MCUBOOT_IMAGE_NUMBER EQUAL 1))
@@ -40,12 +47,14 @@
if (DEFINED MCUBOOT_IMAGE_NUMBER OR
DEFINED MCUBOOT_UPGRADE_STRATEGY OR
DEFINED MCUBOOT_SIGNATURE_TYPE OR
- DEFINED MCUBOOT_HW_KEY)
+ DEFINED MCUBOOT_HW_KEY OR
+ DEFINED MCUBOOT_LOG_LEVEL)
message(WARNING "Ignoring the values of MCUBOOT_* variables as BL2 option is set to False.")
set(MCUBOOT_IMAGE_NUMBER "")
set(MCUBOOT_UPGRADE_STRATEGY "")
set(MCUBOOT_SIGNATURE_TYPE "")
set(MCUBOOT_HW_KEY "")
+ set(MCUBOOT_LOG_LEVEL "")
endif()
if (DEFINED SECURITY_COUNTER OR