aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vincze <david.vincze@arm.com>2020-02-19 09:42:07 +0100
committerDavid Vincze <david.vincze@linaro.org>2020-06-24 14:27:50 +0200
commit141f215f49aa6dc6264c64a30bbdfd28958f3305 (patch)
treed51e576ab184ae19efb66db13808c65bcfc0ec46
parent5399803fa6724959d0a6ae379540a03e19ff4bb6 (diff)
downloadtrusted-firmware-m-141f215f49aa6dc6264c64a30bbdfd28958f3305.tar.gz
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>
-rw-r--r--CommonConfig.cmake2
-rw-r--r--bl2/ext/mcuboot/CMakeLists.txt2
-rw-r--r--bl2/ext/mcuboot/include/flash_map/flash_map.h11
-rw-r--r--bl2/ext/mcuboot/include/mcuboot_config/mcuboot_config.h.in13
-rw-r--r--bl2/src/boot_record.c14
5 files changed, 27 insertions, 15 deletions
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 499cdb67d..b2febdc0d 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -510,7 +510,7 @@ if (NOT DEFINED ATTEST_INCLUDE_TEST_CODE)
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 d1dd17105..5c1cebfed 100644
--- a/bl2/ext/mcuboot/CMakeLists.txt
+++ b/bl2/ext/mcuboot/CMakeLists.txt
@@ -101,6 +101,7 @@ if (MCUBOOT_REPO STREQUAL "TF-M")
)
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 @@ list(FIND _log_levels ${MCUBOOT_LOG_LEVEL} LOG_LEVEL_ID)
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 f47b58562..f94d613db 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 @@ extern "C" {
* 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 @@ extern "C" {
#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 4213cfc01..f7b52529e 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 @@ extern "C" {
#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 20ec7a063..c343cde8b 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.