aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vincze <david.vincze@arm.com>2019-07-26 11:03:32 +0200
committerDavid Vincze <david.vincze@arm.com>2019-08-16 12:35:54 +0200
commit711a5d31d5fa13508b492af289921c65f8206b14 (patch)
treed17355b1a75996b5eda210fa40b76e0483a804bf
parentfb068306daede896f77026440304a2682da16258 (diff)
downloadtrusted-firmware-m-master.tar.gz
Platform: Fix image swapping status updatesHEADmaster
Fix faulty status updates during image swapping. The value of BOOT_STATUS_MAX_ENTRIES must be at least 2 until the swap status update related code is revised in the original MCUBoot repository to prevent the overwrite of other parts (e.g. swap_size) of the image trailer. For more information see the MCUBoot issue: https://github.com/JuulLabs-OSS/mcuboot/issues/427. Change-Id: I96936036d0c5758d2caed27bcc96796a7a64516d Signed-off-by: David Vincze <david.vincze@arm.com>
-rw-r--r--platform/ext/target/mps2/an519/partition/flash_layout.h13
-rw-r--r--platform/ext/target/mps2/an521/partition/flash_layout.h13
-rw-r--r--platform/ext/target/mps3/an524/partition/flash_layout.h13
3 files changed, 30 insertions, 9 deletions
diff --git a/platform/ext/target/mps2/an519/partition/flash_layout.h b/platform/ext/target/mps2/an519/partition/flash_layout.h
index 86028242..b0ebbae6 100644
--- a/platform/ext/target/mps2/an519/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an519/partition/flash_layout.h
@@ -36,6 +36,8 @@
* 0x0010_0000 Non-secure image
*/
+#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+
/* This header file is included from linker scatter file as well, where only a
* limited C constructs are allowed. Therefore it is not possible to include
* here the platform_retarget.h to access flash related defines. To resolve this
@@ -79,9 +81,14 @@
FLASH_NS_PARTITION_SIZE)
/* The maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES ((FLASH_S_PARTITION_SIZE + \
- FLASH_NS_PARTITION_SIZE) / \
- FLASH_AREA_IMAGE_SCRATCH_SIZE)
+/* The maximum number of status entries must be at least 2. For more
+ * information see the MCUBoot issue:
+ * https://github.com/JuulLabs-OSS/mcuboot/issues/427.
+ */
+#define BOOT_STATUS_MAX_ENTRIES MAX(2, \
+ (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
+ FLASH_AREA_IMAGE_SCRATCH_SIZE)
/* Maximum number of image sectors supported by the bootloader. */
#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
diff --git a/platform/ext/target/mps2/an521/partition/flash_layout.h b/platform/ext/target/mps2/an521/partition/flash_layout.h
index d2ffa338..57c95926 100644
--- a/platform/ext/target/mps2/an521/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an521/partition/flash_layout.h
@@ -36,6 +36,8 @@
* 0x0010_0000 Non-secure image
*/
+#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+
/* This header file is included from linker scatter file as well, where only a
* limited C constructs are allowed. Therefore it is not possible to include
* here the platform_retarget.h to access flash related defines. To resolve this
@@ -79,9 +81,14 @@
FLASH_NS_PARTITION_SIZE)
/* The maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES ((FLASH_S_PARTITION_SIZE + \
- FLASH_NS_PARTITION_SIZE) / \
- FLASH_AREA_IMAGE_SCRATCH_SIZE)
+/* The maximum number of status entries must be at least 2. For more
+ * information see the MCUBoot issue:
+ * https://github.com/JuulLabs-OSS/mcuboot/issues/427.
+ */
+#define BOOT_STATUS_MAX_ENTRIES MAX(2, \
+ (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
+ FLASH_AREA_IMAGE_SCRATCH_SIZE)
/* Maximum number of image sectors supported by the bootloader. */
#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
diff --git a/platform/ext/target/mps3/an524/partition/flash_layout.h b/platform/ext/target/mps3/an524/partition/flash_layout.h
index c6afd9f7..918d4dc7 100644
--- a/platform/ext/target/mps3/an524/partition/flash_layout.h
+++ b/platform/ext/target/mps3/an524/partition/flash_layout.h
@@ -46,6 +46,8 @@
* 0x001C_5014 Unused
*/
+#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+
/* Size of a Secure and of a Non-secure image */
#define FLASH_S_PARTITION_SIZE (0x40000) /* S partition: 256 KB */
#define FLASH_NS_PARTITION_SIZE (0x40000) /* NS partition: 256 KB */
@@ -78,9 +80,14 @@
FLASH_NS_PARTITION_SIZE)
/* The maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES ((FLASH_S_PARTITION_SIZE + \
- FLASH_NS_PARTITION_SIZE) / \
- FLASH_AREA_IMAGE_SCRATCH_SIZE)
+/* The maximum number of status entries must be at least 2. For more
+ * information see the MCUBoot issue:
+ * https://github.com/JuulLabs-OSS/mcuboot/issues/427.
+ */
+#define BOOT_STATUS_MAX_ENTRIES MAX(2, \
+ (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
+ FLASH_AREA_IMAGE_SCRATCH_SIZE)
/* Maximum number of image sectors supported by the bootloader. */
#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \