Build: Enable boot data sharing with UPSTREAM
Modify the build system (by removing restrictions) to allow boot data
sharing (measured boot) when the 'UPSTREAM' MCUboot repository is
selected as MCUboot v1.6.0 (current default bootloader) already includes
this feature.
Move target specific macros definitions to target specific header files
so that they are not only available in TF-M's MCUboot fork.
Change-Id: Ib30976419d9d668e588c2e4fdb9f42d90d57a7e2
Signed-off-by: David Vincze <david.vincze@linaro.org>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 499cdb6..b2febdc 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -510,7 +510,7 @@
endif()
if (NOT DEFINED BOOT_DATA_AVAILABLE)
- if (BL2 AND (NOT MCUBOOT_REPO STREQUAL "UPSTREAM"))
+ if (BL2)
set(BOOT_DATA_AVAILABLE ON)
else()
set(BOOT_DATA_AVAILABLE OFF)
diff --git a/bl2/ext/mcuboot/CMakeLists.txt b/bl2/ext/mcuboot/CMakeLists.txt
index d1dd171..5c1cebf 100644
--- a/bl2/ext/mcuboot/CMakeLists.txt
+++ b/bl2/ext/mcuboot/CMakeLists.txt
@@ -101,6 +101,7 @@
)
else()
list(APPEND ALL_SRC_C
+ "${MCUBOOT_DIR}/bootutil/src/boot_record.c"
"${MCUBOOT_DIR}/bootutil/src/swap_scratch.c"
"${MCUBOOT_DIR}/bootutil/src/swap_move.c"
"${MCUBOOT_DIR}/bootutil/src/swap_misc.c"
@@ -205,6 +206,7 @@
if (MCUBOOT_REPO STREQUAL "UPSTREAM")
set(MCUBOOT_HW_ROLLBACK_PROT On)
+ set(MCUBOOT_MEASURED_BOOT On)
endif()
if(MCUBOOT_SIGNATURE_TYPE STREQUAL "RSA-3072")
diff --git a/bl2/ext/mcuboot/include/flash_map/flash_map.h b/bl2/ext/mcuboot/include/flash_map/flash_map.h
index f47b585..f94d613 100644
--- a/bl2/ext/mcuboot/include/flash_map/flash_map.h
+++ b/bl2/ext/mcuboot/include/flash_map/flash_map.h
@@ -49,6 +49,7 @@
* and match the target offset specified in download script.
*/
#include <inttypes.h>
+#include "region_defs.h"
/*
* For now, we only support one flash device.
@@ -59,6 +60,16 @@
#define FLASH_DEVICE_ID 100
#define FLASH_DEVICE_BASE FLASH_BASE_ADDRESS
+/*
+ * Shared data area between bootloader and runtime firmware.
+ */
+#if (defined(BOOT_TFM_SHARED_DATA_BASE) && defined(BOOT_TFM_SHARED_DATA_SIZE))
+#define MCUBOOT_SHARED_DATA_BASE BOOT_TFM_SHARED_DATA_BASE
+#define MCUBOOT_SHARED_DATA_SIZE BOOT_TFM_SHARED_DATA_SIZE
+#else
+#error "BOOT_TFM_SHARED_DATA_* must be defined by target."
+#endif
+
/**
* @brief Structure describing an area on a flash device.
*
diff --git a/bl2/ext/mcuboot/include/mcuboot_config/mcuboot_config.h.in b/bl2/ext/mcuboot/include/mcuboot_config/mcuboot_config.h.in
index 4213cfc..f7b5252 100644
--- a/bl2/ext/mcuboot/include/mcuboot_config/mcuboot_config.h.in
+++ b/bl2/ext/mcuboot/include/mcuboot_config/mcuboot_config.h.in
@@ -48,6 +48,19 @@
#cmakedefine MCUBOOT_HW_KEY
#cmakedefine MCUBOOT_HW_ROLLBACK_PROT
+#cmakedefine MCUBOOT_MEASURED_BOOT
+
+/*
+ * Maximum size of the measured boot record.
+ *
+ * Its size can be calculated based on the following aspects:
+ * - There are 5 allowed software component claims,
+ * - SHA256 is used as the measurement method for the other claims.
+ * Considering these aspects, the only claim which size can vary is the type
+ * of the software component with a maximum length of 12 bytes, which means
+ * the boot record size can be up to 100 bytes.
+ */
+#define MAX_BOOT_RECORD_SZ (100u)
/*
* Cryptographic settings
diff --git a/bl2/src/boot_record.c b/bl2/src/boot_record.c
index 20ec7a0..c343cde 100644
--- a/bl2/src/boot_record.c
+++ b/bl2/src/boot_record.c
@@ -24,20 +24,6 @@
#endif
/*!
- * \def MAX_BOOT_RECORD_SZ
- *
- * \brief Maximum size of the measured boot record.
- *
- * Its size can be calculated based on the following aspects:
- * - There are 5 allowed software component claims,
- * - SHA256 is used as the measurement method for the other claims.
- * Considering these aspects, the only claim which size can vary is the
- * type of the software component. In case of single image boot it is
- * "NSPE_SPE" which results the maximum boot record size of 96.
- */
-#define MAX_BOOT_RECORD_SZ (96u)
-
-/*!
* \var shared_memory_init_done
*
* \brief Indicates whether shared memory area was already initialized.