Platform: Unify flash_layout.h across platforms
This change unifies the flash_layout.h file taking Musca B1
as reference. The change does not modify the image.
Change-Id: I95fabdf6d14ec29f805d5e3e523c78ab4aa6a432
Signed-off-by: Sverteczky, Marcell <marcell.sverteczky@arm.com>
diff --git a/platform/ext/readme.rst b/platform/ext/readme.rst
index 2f93940..f6816c8 100644
--- a/platform/ext/readme.rst
+++ b/platform/ext/readme.rst
@@ -72,7 +72,7 @@
Assemble tool
^^^^^^^^^^^^^
-The ``assemble.py`` tools is used to concatenate secure and non-secure binary
+The ``assemble.py`` tool is used to concatenate secure and non-secure binary
to a single binary blob. It requires the following definitions:
- ``SECURE_IMAGE_OFFSET`` - Defines the offset from the single binary blob base
@@ -83,6 +83,17 @@
- ``NON_SECURE_IMAGE_MAX_SIZE`` - Defines the maximum size of the non-secure
image area.
+Image tool
+^^^^^^^^^^^^^
+The ``imgtool.py`` tool is used to handle the tasks related to signing the
+binary. It requires the following definitions:
+
+- ``SIGN_BIN_SIZE`` - Defines the size of the concatenated binary that is to
+ be signed.
+- ``IMAGE_LOAD_ADDRESS`` - Defines the address to where the image is loaded
+ and is executed from. Only used in case the ``MCUBOOT_UPGRADE_STRATEGY``
+ is configured to be ``RAM_LOADING``.
+
Secure Storage (SST) Service definitions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The SST service requires the following definitions:
diff --git a/platform/ext/target/mps2/an519/partition/flash_layout.h b/platform/ext/target/mps2/an519/partition/flash_layout.h
index 4dc96fd..8602824 100644
--- a/platform/ext/target/mps2/an519/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an519/partition/flash_layout.h
@@ -43,58 +43,72 @@
* with comment.
*/
-/* The size of a partition. This should be large enough to contain a S or NS
- * sw binary. Each FLASH_AREA_IMAGE contains two partitions. See Flash layout
- * above.
- */
-#define FLASH_PARTITION_SIZE (0x80000) /* 512 kB */
-#define SIGN_BIN_SIZE (FLASH_PARTITION_SIZE + \
- FLASH_PARTITION_SIZE)
+/* Size of a Secure and of a Non-secure image */
+#define FLASH_S_PARTITION_SIZE (0x80000) /* S partition: 512 KB */
+#define FLASH_NS_PARTITION_SIZE (0x80000) /* NS partition: 512 KB */
/* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
-#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 kB */
+#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 KB */
/* Same as FLASH0_SIZE */
#define FLASH_TOTAL_SIZE (0x00400000) /* 4 MB */
/* Flash layout info for BL2 bootloader */
-#define FLASH_BASE_ADDRESS (0x10000000) /* same as FLASH0_BASE_S */
+/* Same as FLASH0_BASE_S */
+#define FLASH_BASE_ADDRESS (0x10000000)
/* Offset and size definitions of the flash partitions that are handled by the
* bootloader. The image swapping is done between IMAGE_0 and IMAGE_1, SCRATCH
* is used as a temporary storage during image swapping.
*/
#define FLASH_AREA_BL2_OFFSET (0x0)
-#define FLASH_AREA_BL2_SIZE (FLASH_PARTITION_SIZE)
+#define FLASH_AREA_BL2_SIZE (0x80000) /* 512 KB */
-#define FLASH_AREA_IMAGE_0_OFFSET (0x080000)
-#define FLASH_AREA_IMAGE_0_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_0_OFFSET (FLASH_AREA_BL2_OFFSET + \
+ FLASH_AREA_BL2_SIZE)
+#define FLASH_AREA_IMAGE_0_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-#define FLASH_AREA_IMAGE_1_OFFSET (0x180000)
-#define FLASH_AREA_IMAGE_1_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + \
+ FLASH_AREA_IMAGE_0_SIZE)
+#define FLASH_AREA_IMAGE_1_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (0x280000)
-#define FLASH_AREA_IMAGE_SCRATCH_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + \
+ FLASH_AREA_IMAGE_1_SIZE)
+#define FLASH_AREA_IMAGE_SCRATCH_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-/* Maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES ((2 * FLASH_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)
-/** Maximum number of image sectors supported by the bootloader. */
-#define BOOT_MAX_IMG_SECTORS ((2 * FLASH_PARTITION_SIZE) / \
+/* Maximum number of image sectors supported by the bootloader. */
+#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
FLASH_AREA_IMAGE_SECTOR_SIZE)
-#define FLASH_SST_AREA_OFFSET (0x380000)
+/* Secure Storage (SST) Service definitions */
+#define FLASH_SST_AREA_OFFSET (FLASH_AREA_IMAGE_SCRATCH_OFFSET + \
+ FLASH_AREA_IMAGE_SCRATCH_SIZE)
#define FLASH_SST_AREA_SIZE (0x5000) /* 20 KB */
-#define FLASH_NV_COUNTERS_AREA_OFFSET (0x385000)
+/* NV Counters definitions */
+#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_SST_AREA_OFFSET + \
+ FLASH_SST_AREA_SIZE)
#define FLASH_NV_COUNTERS_AREA_SIZE (0x14) /* 20 Bytes */
-/* Offset and size definition in flash area, used by assemble.py */
-#define SECURE_IMAGE_OFFSET 0x0
-#define SECURE_IMAGE_MAX_SIZE 0x80000
+/* Offset and size definition in flash area used by assemble.py */
+#define SECURE_IMAGE_OFFSET (0x0)
+#define SECURE_IMAGE_MAX_SIZE FLASH_S_PARTITION_SIZE
-#define NON_SECURE_IMAGE_OFFSET 0x80000
-#define NON_SECURE_IMAGE_MAX_SIZE 0x80000
+#define NON_SECURE_IMAGE_OFFSET (SECURE_IMAGE_OFFSET + \
+ SECURE_IMAGE_MAX_SIZE)
+#define NON_SECURE_IMAGE_MAX_SIZE FLASH_NS_PARTITION_SIZE
+
+/* Concatenated binary size used by imgtool.py */
+#define SIGN_BIN_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
/* Flash device name used by BL2
* Name is defined in flash driver file: Driver_Flash.c
@@ -113,13 +127,13 @@
#define SST_FLASH_AREA_ADDR FLASH_SST_AREA_OFFSET
#define SST_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
/* The sectors must be in consecutive memory location */
-#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
+#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
/* Specifies the smallest flash programmable unit in bytes */
-#define SST_FLASH_PROGRAM_UNIT 0x1
+#define SST_FLASH_PROGRAM_UNIT (0x1)
/* The maximum asset size to be stored in the SST area */
-#define SST_MAX_ASSET_SIZE 2048
+#define SST_MAX_ASSET_SIZE (2048)
/* The maximum number of assets to be stored in the SST area */
-#define SST_NUM_ASSETS 10
+#define SST_NUM_ASSETS (10)
/* NV Counters definitions */
#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
@@ -127,15 +141,22 @@
#define TFM_NV_COUNTERS_SECTOR_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
#define TFM_NV_COUNTERS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
+/* Use SRAM1 memory to store Code data */
+#define S_ROM_ALIAS_BASE (0x10000000)
+#define NS_ROM_ALIAS_BASE (0x00000000)
+
/* FIXME: Use SRAM2 memory to store RW data */
#define S_RAM_ALIAS_BASE (0x38000000)
#define NS_RAM_ALIAS_BASE (0x28000000)
+#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
+#define TOTAL_RAM_SIZE (0x200000) /* 2 MB */
+
/* Shared data area between bootloader and runtime firmware.
* Shared data area is allocated at the beginning of the RAM, it is overlapping
* with TF-M Secure code's MSP stack
*/
#define BOOT_TFM_SHARED_DATA_BASE S_RAM_ALIAS_BASE
-#define BOOT_TFM_SHARED_DATA_SIZE 0x400
+#define BOOT_TFM_SHARED_DATA_SIZE (0x400)
#endif /* __FLASH_LAYOUT_H__ */
diff --git a/platform/ext/target/mps2/an519/partition/region_defs.h b/platform/ext/target/mps2/an519/partition/region_defs.h
index 3a8bb81..30d1ba0 100644
--- a/platform/ext/target/mps2/an519/partition/region_defs.h
+++ b/platform/ext/target/mps2/an519/partition/region_defs.h
@@ -19,81 +19,76 @@
#include "flash_layout.h"
-#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
-#define TOTAL_RAM_SIZE (0x00200000) /* 2 MB */
+#define BL2_HEAP_SIZE (0x0001000)
+#define BL2_MSP_STACK_SIZE (0x0001800)
-#define BL2_HEAP_SIZE 0x0001000
-#define BL2_MSP_STACK_SIZE 0x0001800
+#define S_HEAP_SIZE (0x0001000)
+#define S_MSP_STACK_SIZE_INIT (0x0000400)
+#define S_MSP_STACK_SIZE (0x0000800)
+#define S_PSP_STACK_SIZE (0x0000800)
-#define S_HEAP_SIZE 0x0001000
-#define S_MSP_STACK_SIZE_INIT 0x0000400
-#define S_MSP_STACK_SIZE 0x0000800
-#define S_PSP_STACK_SIZE 0x0000800
+#define NS_HEAP_SIZE (0x0001000)
+#define NS_MSP_STACK_SIZE (0x0000400)
+#define NS_PSP_STACK_SIZE (0x0000C00)
-#define NS_HEAP_SIZE 0x0001000
-#define NS_MSP_STACK_SIZE 0x0000400
-#define NS_PSP_STACK_SIZE 0x0000C00
-
-/*
- * This size of buffer is big enough to store an attestation
+/* This size of buffer is big enough to store an attestation
* token produced by initial attestation service
*/
-#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE 0x200
+#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE (0x200)
-/*
- * MPC granularity is 128 KB on AN519 MPS2 FPGA image. Alignment
+/* MPC granularity is 128 KB on AN519 MPS2 FPGA image. Alignment
* of partitions is defined in accordance with this constraint.
*/
#ifdef BL2
#ifndef LINK_TO_SECONDARY_PARTITION
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
-#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
+#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
#else
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
-#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
+#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
#endif /* !LINK_TO_SECONDARY_PARTITION */
#else
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET (0x0)
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (0x0)
#endif /* BL2 */
#ifndef LINK_TO_SECONDARY_PARTITION
-#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (0x100000)
+#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET \
+ + FLASH_S_PARTITION_SIZE)
#else
-#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (0x200000)
+#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET \
+ + FLASH_S_PARTITION_SIZE)
#endif /* !LINK_TO_SECONDARY_PARTITION */
-/*
- * Boot partition structure if MCUBoot is used:
+/* Boot partition structure if MCUBoot is used:
* 0x0_0000 Bootloader header
* 0x0_0400 Image area
* 0x7_0000 Trailer
*/
/* IMAGE_CODE_SIZE is the space available for the software binary image.
- * It is less than the FLASH_PARTITION_SIZE because we reserve space
- * for the image header and trailer introduced by the bootloader.
+ * It is less than the FLASH_S_PARTITION_SIZE + FLASH_NS_PARTITION_SIZE
+ * because we reserve space for the image header and trailer introduced
+ * by the bootloader.
*/
#ifdef BL2
-#define BL2_HEADER_SIZE (0x400)
-#define BL2_TRAILER_SIZE (0x10000)
+#define BL2_HEADER_SIZE (0x400) /* 1 KB */
+#define BL2_TRAILER_SIZE (0x10000) /* 64 KB */
#else
/* No header if no bootloader, but keep IMAGE_CODE_SIZE the same */
#define BL2_HEADER_SIZE (0x0)
#define BL2_TRAILER_SIZE (0x10400)
#endif /* BL2 */
-#define IMAGE_CODE_SIZE \
- (FLASH_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_S_CODE_SIZE \
+ (FLASH_S_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_NS_CODE_SIZE \
+ (FLASH_NS_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
/* FIXME: veneer region size is increased temporarily while both legacy veneers
* and their iovec-based equivalents co-exist for secure partitions. To be
* adjusted as legacy veneers are eliminated
*/
-#define CMSE_VENEER_REGION_SIZE (0x00000380)
-
-/* Use SRAM1 memory to store Code data */
-#define S_ROM_ALIAS_BASE (0x10000000)
-#define NS_ROM_ALIAS_BASE (0x00000000)
+#define CMSE_VENEER_REGION_SIZE (0x380)
/* Alias definitions for secure and non-secure areas*/
#define S_ROM_ALIAS(x) (S_ROM_ALIAS_BASE + (x))
@@ -103,10 +98,10 @@
#define NS_RAM_ALIAS(x) (NS_RAM_ALIAS_BASE + (x))
/* Secure regions */
-#define S_IMAGE_PRIMARY_AREA_OFFSET \
+#define S_IMAGE_PRIMARY_AREA_OFFSET \
(S_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define S_CODE_START (S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET))
-#define S_CODE_SIZE (IMAGE_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
+#define S_CODE_SIZE (IMAGE_S_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
#define S_CODE_LIMIT (S_CODE_START + S_CODE_SIZE - 1)
#define S_DATA_START (S_RAM_ALIAS(0x0))
@@ -120,7 +115,7 @@
#define NS_IMAGE_PRIMARY_AREA_OFFSET \
(NS_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define NS_CODE_START (NS_ROM_ALIAS(NS_IMAGE_PRIMARY_AREA_OFFSET))
-#define NS_CODE_SIZE (IMAGE_CODE_SIZE)
+#define NS_CODE_SIZE (IMAGE_NS_CODE_SIZE)
#define NS_CODE_LIMIT (NS_CODE_START + NS_CODE_SIZE - 1)
#define NS_DATA_START (NS_RAM_ALIAS(TOTAL_RAM_SIZE / 2))
@@ -130,13 +125,11 @@
/* NS partition information is used for MPC and SAU configuration */
#define NS_PARTITION_START \
(NS_ROM_ALIAS(NS_IMAGE_PRIMARY_PARTITION_OFFSET))
-
-#define NS_PARTITION_SIZE (FLASH_PARTITION_SIZE)
+#define NS_PARTITION_SIZE (FLASH_NS_PARTITION_SIZE)
/* Secondary partition for new images in case of firmware upgrade */
#define SECONDARY_PARTITION_START \
(NS_ROM_ALIAS(S_IMAGE_SECONDARY_PARTITION_OFFSET))
-
#define SECONDARY_PARTITION_SIZE (FLASH_AREA_IMAGE_1_SIZE)
#ifdef BL2
diff --git a/platform/ext/target/mps2/an521/partition/flash_layout.h b/platform/ext/target/mps2/an521/partition/flash_layout.h
index c9c56e9..d2ffa33 100644
--- a/platform/ext/target/mps2/an521/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an521/partition/flash_layout.h
@@ -43,58 +43,72 @@
* with comment.
*/
-/* The size of a partition. This should be large enough to contain a S or NS
- * sw binary. Each FLASH_AREA_IMAGE contains two partitions. See Flash layout
- * above.
- */
-#define FLASH_PARTITION_SIZE (0x80000) /* 512 kB */
-#define SIGN_BIN_SIZE (FLASH_PARTITION_SIZE + \
- FLASH_PARTITION_SIZE)
+/* Size of a Secure and of a Non-secure image */
+#define FLASH_S_PARTITION_SIZE (0x80000) /* S partition: 512 KB */
+#define FLASH_NS_PARTITION_SIZE (0x80000) /* NS partition: 512 KB */
/* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
-#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 kB */
+#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 KB */
/* Same as FLASH0_SIZE */
#define FLASH_TOTAL_SIZE (0x00400000) /* 4 MB */
/* Flash layout info for BL2 bootloader */
-#define FLASH_BASE_ADDRESS (0x10000000) /* same as FLASH0_BASE_S */
+/* Same as FLASH0_BASE_S */
+#define FLASH_BASE_ADDRESS (0x10000000)
/* Offset and size definitions of the flash partitions that are handled by the
* bootloader. The image swapping is done between IMAGE_0 and IMAGE_1, SCRATCH
* is used as a temporary storage during image swapping.
*/
#define FLASH_AREA_BL2_OFFSET (0x0)
-#define FLASH_AREA_BL2_SIZE (FLASH_PARTITION_SIZE)
+#define FLASH_AREA_BL2_SIZE (0x80000) /* 512 KB */
-#define FLASH_AREA_IMAGE_0_OFFSET (0x080000)
-#define FLASH_AREA_IMAGE_0_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_0_OFFSET (FLASH_AREA_BL2_OFFSET + \
+ FLASH_AREA_BL2_SIZE)
+#define FLASH_AREA_IMAGE_0_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-#define FLASH_AREA_IMAGE_1_OFFSET (0x180000)
-#define FLASH_AREA_IMAGE_1_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + \
+ FLASH_AREA_IMAGE_0_SIZE)
+#define FLASH_AREA_IMAGE_1_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (0x280000)
-#define FLASH_AREA_IMAGE_SCRATCH_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + \
+ FLASH_AREA_IMAGE_1_SIZE)
+#define FLASH_AREA_IMAGE_SCRATCH_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-/* Maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES ((2 * FLASH_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)
-/** Maximum number of image sectors supported by the bootloader. */
-#define BOOT_MAX_IMG_SECTORS ((2 * FLASH_PARTITION_SIZE) / \
+/* Maximum number of image sectors supported by the bootloader. */
+#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
FLASH_AREA_IMAGE_SECTOR_SIZE)
-#define FLASH_SST_AREA_OFFSET (0x380000)
+/* Secure Storage (SST) Service definitions */
+#define FLASH_SST_AREA_OFFSET (FLASH_AREA_IMAGE_SCRATCH_OFFSET + \
+ FLASH_AREA_IMAGE_SCRATCH_SIZE)
#define FLASH_SST_AREA_SIZE (0x5000) /* 20 KB */
-#define FLASH_NV_COUNTERS_AREA_OFFSET (0x385000)
+/* NV Counters definitions */
+#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_SST_AREA_OFFSET + \
+ FLASH_SST_AREA_SIZE)
#define FLASH_NV_COUNTERS_AREA_SIZE (0x14) /* 20 Bytes */
-/* Offset and size definition in flash area, used by assemble.py */
-#define SECURE_IMAGE_OFFSET 0x0
-#define SECURE_IMAGE_MAX_SIZE 0x80000
+/* Offset and size definition in flash area used by assemble.py */
+#define SECURE_IMAGE_OFFSET (0x0)
+#define SECURE_IMAGE_MAX_SIZE FLASH_S_PARTITION_SIZE
-#define NON_SECURE_IMAGE_OFFSET 0x80000
-#define NON_SECURE_IMAGE_MAX_SIZE 0x80000
+#define NON_SECURE_IMAGE_OFFSET (SECURE_IMAGE_OFFSET + \
+ SECURE_IMAGE_MAX_SIZE)
+#define NON_SECURE_IMAGE_MAX_SIZE FLASH_NS_PARTITION_SIZE
+
+/* Concatenated binary size used by imgtool.py */
+#define SIGN_BIN_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
/* Flash device name used by BL2
* Name is defined in flash driver file: Driver_Flash.c
@@ -113,13 +127,13 @@
#define SST_FLASH_AREA_ADDR FLASH_SST_AREA_OFFSET
#define SST_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
/* The sectors must be in consecutive memory location */
-#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
+#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
/* Specifies the smallest flash programmable unit in bytes */
-#define SST_FLASH_PROGRAM_UNIT 0x1
+#define SST_FLASH_PROGRAM_UNIT (0x1)
/* The maximum asset size to be stored in the SST area */
-#define SST_MAX_ASSET_SIZE 2048
+#define SST_MAX_ASSET_SIZE (2048)
/* The maximum number of assets to be stored in the SST area */
-#define SST_NUM_ASSETS 10
+#define SST_NUM_ASSETS (10)
/* NV Counters definitions */
#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
@@ -127,15 +141,22 @@
#define TFM_NV_COUNTERS_SECTOR_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
#define TFM_NV_COUNTERS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
+/* Use SRAM1 memory to store Code data */
+#define S_ROM_ALIAS_BASE (0x10000000)
+#define NS_ROM_ALIAS_BASE (0x00000000)
+
/* FIXME: Use SRAM2 memory to store RW data */
#define S_RAM_ALIAS_BASE (0x38000000)
#define NS_RAM_ALIAS_BASE (0x28000000)
+#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
+#define TOTAL_RAM_SIZE (0x200000) /* 2 MB */
+
/* Shared data area between bootloader and runtime firmware.
* Shared data area is allocated at the beginning of the RAM, it is overlapping
* with TF-M Secure code's MSP stack
*/
#define BOOT_TFM_SHARED_DATA_BASE S_RAM_ALIAS_BASE
-#define BOOT_TFM_SHARED_DATA_SIZE 0x400
+#define BOOT_TFM_SHARED_DATA_SIZE (0x400)
#endif /* __FLASH_LAYOUT_H__ */
diff --git a/platform/ext/target/mps2/an521/partition/region_defs.h b/platform/ext/target/mps2/an521/partition/region_defs.h
index f6d71c9..8951163 100644
--- a/platform/ext/target/mps2/an521/partition/region_defs.h
+++ b/platform/ext/target/mps2/an521/partition/region_defs.h
@@ -19,81 +19,76 @@
#include "flash_layout.h"
-#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
-#define TOTAL_RAM_SIZE (0x00200000) /* 2 MB */
+#define BL2_HEAP_SIZE (0x0001000)
+#define BL2_MSP_STACK_SIZE (0x0001800)
-#define BL2_HEAP_SIZE 0x0001000
-#define BL2_MSP_STACK_SIZE 0x0001800
+#define S_HEAP_SIZE (0x0001000)
+#define S_MSP_STACK_SIZE_INIT (0x0000400)
+#define S_MSP_STACK_SIZE (0x0000800)
+#define S_PSP_STACK_SIZE (0x0000800)
-#define S_HEAP_SIZE 0x0001000
-#define S_MSP_STACK_SIZE_INIT 0x0000400
-#define S_MSP_STACK_SIZE 0x0000800
-#define S_PSP_STACK_SIZE 0x0000800
+#define NS_HEAP_SIZE (0x0001000)
+#define NS_MSP_STACK_SIZE (0x0000400)
+#define NS_PSP_STACK_SIZE (0x0000C00)
-#define NS_HEAP_SIZE 0x0001000
-#define NS_MSP_STACK_SIZE 0x0000400
-#define NS_PSP_STACK_SIZE 0x0000C00
-
-/*
- * This size of buffer is big enough to store an attestation
+/* This size of buffer is big enough to store an attestation
* token produced by initial attestation service
*/
-#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE 0x200
+#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE (0x200)
-/*
- * MPC granularity is 128 KB on AN521 Castor MPS2 FPGA image. Alignment
+/* MPC granularity is 128 KB on AN521 Castor MPS2 FPGA image. Alignment
* of partitions is defined in accordance with this constraint.
*/
#ifdef BL2
#ifndef LINK_TO_SECONDARY_PARTITION
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
-#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
+#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
#else
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
-#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
+#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
#endif /* !LINK_TO_SECONDARY_PARTITION */
#else
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET (0x0)
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (0x0)
#endif /* BL2 */
#ifndef LINK_TO_SECONDARY_PARTITION
-#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (0x100000)
+#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET \
+ + FLASH_S_PARTITION_SIZE)
#else
-#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (0x200000)
+#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET \
+ + FLASH_S_PARTITION_SIZE)
#endif /* !LINK_TO_SECONDARY_PARTITION */
-/*
- * Boot partition structure if MCUBoot is used:
+/* Boot partition structure if MCUBoot is used:
* 0x0_0000 Bootloader header
* 0x0_0400 Image area
* 0x7_0000 Trailer
*/
/* IMAGE_CODE_SIZE is the space available for the software binary image.
- * It is less than the FLASH_PARTITION_SIZE because we reserve space
- * for the image header and trailer introduced by the bootloader.
+ * It is less than the FLASH_S_PARTITION_SIZE + FLASH_NS_PARTITION_SIZE
+ * because we reserve space for the image header and trailer introduced
+ * by the bootloader.
*/
#ifdef BL2
-#define BL2_HEADER_SIZE (0x400)
-#define BL2_TRAILER_SIZE (0x10000)
+#define BL2_HEADER_SIZE (0x400) /* 1 KB */
+#define BL2_TRAILER_SIZE (0x10000) /* 64 KB */
#else
/* No header if no bootloader, but keep IMAGE_CODE_SIZE the same */
#define BL2_HEADER_SIZE (0x0)
#define BL2_TRAILER_SIZE (0x10400)
#endif /* BL2 */
-#define IMAGE_CODE_SIZE \
- (FLASH_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_S_CODE_SIZE \
+ (FLASH_S_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_NS_CODE_SIZE \
+ (FLASH_NS_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
/* FIXME: veneer region size is increased temporarily while both legacy veneers
* and their iovec-based equivalents co-exist for secure partitions. To be
* adjusted as legacy veneers are eliminated
*/
-#define CMSE_VENEER_REGION_SIZE (0x00000380)
-
-/* Use SRAM1 memory to store Code data */
-#define S_ROM_ALIAS_BASE (0x10000000)
-#define NS_ROM_ALIAS_BASE (0x00000000)
+#define CMSE_VENEER_REGION_SIZE (0x380)
/* Alias definitions for secure and non-secure areas*/
#define S_ROM_ALIAS(x) (S_ROM_ALIAS_BASE + (x))
@@ -103,10 +98,10 @@
#define NS_RAM_ALIAS(x) (NS_RAM_ALIAS_BASE + (x))
/* Secure regions */
-#define S_IMAGE_PRIMARY_AREA_OFFSET \
+#define S_IMAGE_PRIMARY_AREA_OFFSET \
(S_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define S_CODE_START (S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET))
-#define S_CODE_SIZE (IMAGE_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
+#define S_CODE_SIZE (IMAGE_S_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
#define S_CODE_LIMIT (S_CODE_START + S_CODE_SIZE - 1)
#define S_DATA_START (S_RAM_ALIAS(0x0))
@@ -120,7 +115,7 @@
#define NS_IMAGE_PRIMARY_AREA_OFFSET \
(NS_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define NS_CODE_START (NS_ROM_ALIAS(NS_IMAGE_PRIMARY_AREA_OFFSET))
-#define NS_CODE_SIZE (IMAGE_CODE_SIZE)
+#define NS_CODE_SIZE (IMAGE_NS_CODE_SIZE)
#define NS_CODE_LIMIT (NS_CODE_START + NS_CODE_SIZE - 1)
#define NS_DATA_START (NS_RAM_ALIAS(TOTAL_RAM_SIZE / 2))
@@ -130,13 +125,11 @@
/* NS partition information is used for MPC and SAU configuration */
#define NS_PARTITION_START \
(NS_ROM_ALIAS(NS_IMAGE_PRIMARY_PARTITION_OFFSET))
-
-#define NS_PARTITION_SIZE (FLASH_PARTITION_SIZE)
+#define NS_PARTITION_SIZE (FLASH_NS_PARTITION_SIZE)
/* Secondary partition for new images in case of firmware upgrade */
#define SECONDARY_PARTITION_START \
(NS_ROM_ALIAS(S_IMAGE_SECONDARY_PARTITION_OFFSET))
-
#define SECONDARY_PARTITION_SIZE (FLASH_AREA_IMAGE_1_SIZE)
#ifdef BL2
diff --git a/platform/ext/target/mps3/an524/cmsis_drivers/Driver_Flash.c b/platform/ext/target/mps3/an524/cmsis_drivers/Driver_Flash.c
index 623f943..55fe265 100644
--- a/platform/ext/target/mps3/an524/cmsis_drivers/Driver_Flash.c
+++ b/platform/ext/target/mps3/an524/cmsis_drivers/Driver_Flash.c
@@ -42,7 +42,7 @@
#define FLASH_REDIRECT_BASE SST_FLASH_AREA_ADDR
#define FLASH_REDIRECT_LIMIT (FLASH_REDIRECT_BASE \
- + SST_FLASH_AREA_SIZE \
+ + FLASH_SST_AREA_SIZE \
+ FLASH_NV_COUNTERS_AREA_SIZE)
#define FLASH_REDIRECT_DEST 0x38000000
diff --git a/platform/ext/target/mps3/an524/partition/flash_layout.h b/platform/ext/target/mps3/an524/partition/flash_layout.h
index d854bc0..c6afd9f 100644
--- a/platform/ext/target/mps3/an524/partition/flash_layout.h
+++ b/platform/ext/target/mps3/an524/partition/flash_layout.h
@@ -17,16 +17,15 @@
#ifndef __FLASH_LAYOUT_H__
#define __FLASH_LAYOUT_H__
-/*
- * Use the QSPI as boot flash
+/* Use the QSPI as boot flash
*
* QSPI MPC BLK_CFG register value is 0xD.
* Thus QSPI MPC Block size is 256 KB = 2 ^ (0xD + 5).
*/
-/*
- * The addresses used in the following layout are all NS alias
- * Flash layout with BL2:
+/* The addresses used in the following layout are all NS alias
+ * Flash layout on MPS3 AN524 with BL2:
+ *
* 0x0000_0000 BL2 - MCUBoot (256 KB)
* Flash_area_image_0
* 0x0004_0000 Secure image (256 KB)
@@ -47,117 +46,119 @@
* 0x001C_5014 Unused
*/
+/* 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 */
+
+/* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
+#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 KB */
+/* Same as FLASH0_SIZE */
+#define FLASH_TOTAL_SIZE (0x800000) /* 8 MB */
+
/* Flash base info for BL2 bootloader */
-#define FLASH_BASE_ADDRESS 0x10000000
-/*
- * Flash device name used by BL2
- * Name is defined in flash driver file: Driver_Flash.c
- */
-#define FLASH_DEV_NAME Driver_FLASH0
-
-/*
- * Flash device name used by SST
- * Name is defined in flash driver file: Driver_Flash.c
- */
-#define SST_FLASH_DEV_NAME Driver_FLASH0
-
-
-#define FLASH_AREA_IMAGE_SECTOR_SIZE 0x1000 /* 4 KB */
-#define FLASH_TOTAL_SIZE 0x800000 /* 8 MB */
-
-#define FLASH_AREA_S_IMAGE_SIZE 0x40000 /* 256 KB */
-#define FLASH_AREA_NS_IMAGE_SIZE 0x40000 /* 256 KB */
-#define SIGN_BIN_SIZE (FLASH_AREA_S_IMAGE_SIZE + \
- FLASH_AREA_NS_IMAGE_SIZE)
-
-#define FLASH_AREA_IMAGE_SLOT_SIZE (FLASH_AREA_S_IMAGE_SIZE + \
- FLASH_AREA_NS_IMAGE_SIZE)
+#define FLASH_BASE_ADDRESS (0x10000000)
/* offset to QSPI base */
-#define FLASH_AREA_BL2_OFFSET 0x0
-#define FLASH_AREA_BL2_SIZE 0x40000 /* 256 KB */
+#define FLASH_AREA_BL2_OFFSET (0x0)
+#define FLASH_AREA_BL2_SIZE (0x40000) /* 256 KB */
#define FLASH_AREA_IMAGE_0_OFFSET (FLASH_AREA_BL2_OFFSET + \
FLASH_AREA_BL2_SIZE)
-#define FLASH_AREA_IMAGE_0_SIZE FLASH_AREA_IMAGE_SLOT_SIZE
+#define FLASH_AREA_IMAGE_0_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + \
FLASH_AREA_IMAGE_0_SIZE)
-#define FLASH_AREA_IMAGE_1_SIZE FLASH_AREA_IMAGE_SLOT_SIZE
+#define FLASH_AREA_IMAGE_1_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + \
FLASH_AREA_IMAGE_1_SIZE)
-#define FLASH_AREA_IMAGE_SCRATCH_SIZE FLASH_AREA_IMAGE_SLOT_SIZE
+#define FLASH_AREA_IMAGE_SCRATCH_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-/* Maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES (FLASH_AREA_IMAGE_SLOT_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)
/* Maximum number of image sectors supported by the bootloader. */
-#define BOOT_MAX_IMG_SECTORS (FLASH_AREA_IMAGE_SLOT_SIZE / \
+#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
FLASH_AREA_IMAGE_SECTOR_SIZE)
-/*
- * Secure Storage (SST) Service definitions
- */
-#define SST_FLASH_AREA_OFFSET (FLASH_AREA_IMAGE_SCRATCH_OFFSET + \
- FLASH_AREA_IMAGE_SCRATCH_SIZE)
-
-/*
- * In this target the CMSIS driver requires only the offset from the
- * flash base address instead of the full flash address.
- */
-#define SST_FLASH_AREA_SIZE 0x5000 /* 20 KB */
-#define SST_FLASH_AREA_ADDR SST_FLASH_AREA_OFFSET
-
-/* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
-#define SST_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE /* 4 KB */
-/* The sectors must be in consecutive memory location */
-#define SST_NBR_OF_SECTORS (SST_FLASH_AREA_SIZE / SST_SECTOR_SIZE)
-/* Specifies the smallest flash programmable unit in bytes */
-#define SST_FLASH_PROGRAM_UNIT 0x1
-/* The maximum asset size to be stored in the SST area */
-#define SST_MAX_ASSET_SIZE 2048
-/* The maximum number of assets to be stored in the SST area */
-#define SST_NUM_ASSETS 10
+/* Secure Storage (SST) Service definitions */
+#define FLASH_SST_AREA_OFFSET (FLASH_AREA_IMAGE_SCRATCH_OFFSET + \
+ FLASH_AREA_IMAGE_SCRATCH_SIZE)
+#define FLASH_SST_AREA_SIZE (0x5000) /* 20 KB */
/* NV Counters definitions */
+#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_SST_AREA_OFFSET + \
+ FLASH_SST_AREA_SIZE)
#define FLASH_NV_COUNTERS_AREA_SIZE (0x14) /* 20 Bytes */
-#define FLASH_NV_COUNTERS_AREA_OFFSET (SST_FLASH_AREA_OFFSET + \
- SST_FLASH_AREA_SIZE)
-#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
-#define TFM_NV_COUNTERS_AREA_SIZE FLASH_NV_COUNTERS_AREA_SIZE
-#define TFM_NV_COUNTERS_SECTOR_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
-#define TFM_NV_COUNTERS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
+/* Offset and size definition in flash area used by assemble.py */
+#define SECURE_IMAGE_OFFSET (0x0)
+#define SECURE_IMAGE_MAX_SIZE FLASH_S_PARTITION_SIZE
-/*
- * Offset and size definition in flash area, used by BL2 MCUboot assemble.py
- * assemble.py is unable to handle the nested macros.
- * Only immediate data is valid here.
+#define NON_SECURE_IMAGE_OFFSET (SECURE_IMAGE_OFFSET + \
+ SECURE_IMAGE_MAX_SIZE)
+#define NON_SECURE_IMAGE_MAX_SIZE FLASH_NS_PARTITION_SIZE
+
+/* Concatenated binary size used by imgtool.py */
+#define SIGN_BIN_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
+
+/* Flash device name used by BL2
+ * Name is defined in flash driver file: Driver_Flash.c
*/
-#define SECURE_IMAGE_OFFSET 0x0
-/* FLASH_AREA_S_IMAGE_SIZE */
-#define SECURE_IMAGE_MAX_SIZE 0x40000
+#define FLASH_DEV_NAME Driver_FLASH0
-/* SECURE_IMAGE_OFFSET + SECURE_IMAGE_MAX_SIZE */
-#define NON_SECURE_IMAGE_OFFSET 0x40000
-/* FLASH_AREA_NS_IMAGE_SIZE */
-#define NON_SECURE_IMAGE_MAX_SIZE 0x40000
+/* Secure Storage (SST) Service definitions
+ * Note: Further documentation of these definitions can be found in the
+ * TF-M SST Integration Guide.
+ */
+#define SST_FLASH_DEV_NAME Driver_FLASH0
-/*
- * Use Internal SRAM0~3 to store RW data
+/* In this target the CMSIS driver requires only the offset from the base
+ * address instead of the full memory address.
+ */
+#define SST_FLASH_AREA_ADDR FLASH_SST_AREA_OFFSET
+
+/* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
+#define SST_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
+/* The sectors must be in consecutive memory location */
+#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
+/* Specifies the smallest flash programmable unit in bytes */
+#define SST_FLASH_PROGRAM_UNIT (0x1)
+/* The maximum asset size to be stored in the SST area */
+#define SST_MAX_ASSET_SIZE (2048)
+/* The maximum number of assets to be stored in the SST area */
+#define SST_NUM_ASSETS (10)
+
+/* NV Counters definitions */
+#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
+#define TFM_NV_COUNTERS_AREA_SIZE FLASH_NV_COUNTERS_AREA_SIZE
+#define TFM_NV_COUNTERS_SECTOR_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
+#define TFM_NV_COUNTERS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
+
+/* Use Internal SRAM0~3 to store RW data
* ISRAM0 and ISRAM1 for Secure Data
* ISRAM2 and ISRAM3 for Non-Secure Data
*/
-#define S_RAM_ALIAS_BASE 0x30000000
-#define NS_RAM_ALIAS_BASE 0x20000000
+#define S_ROM_ALIAS_BASE (0x10000000)
+#define NS_ROM_ALIAS_BASE (0x00000000)
+
+#define S_RAM_ALIAS_BASE (0x30000000)
+#define NS_RAM_ALIAS_BASE (0x20000000)
+
+#define TOTAL_RAM_SIZE (0x20000) /* 128 KB */
/* Shared data area between bootloader and runtime firmware.
* Shared data area is allocated at the beginning of the RAM, it is overlapping
* with TF-M Secure code's MSP stack
*/
-#define BOOT_TFM_SHARED_DATA_BASE S_RAM_ALIAS_BASE
-#define BOOT_TFM_SHARED_DATA_SIZE 0x400
+#define BOOT_TFM_SHARED_DATA_BASE S_RAM_ALIAS_BASE
+#define BOOT_TFM_SHARED_DATA_SIZE (0x400)
#endif /* __FLASH_LAYOUT_H__ */
diff --git a/platform/ext/target/mps3/an524/partition/region_defs.h b/platform/ext/target/mps3/an524/partition/region_defs.h
index dfeade0..e6df473 100644
--- a/platform/ext/target/mps3/an524/partition/region_defs.h
+++ b/platform/ext/target/mps3/an524/partition/region_defs.h
@@ -19,137 +19,127 @@
#include "flash_layout.h"
-#define BL2_HEAP_SIZE 0x0001000
-#define BL2_MSP_STACK_SIZE 0x0001800
+#define BL2_HEAP_SIZE (0x0001000)
+#define BL2_MSP_STACK_SIZE (0x0001800)
-#define S_HEAP_SIZE 0x0001000
-#define S_MSP_STACK_SIZE_INIT 0x0000400
-#define S_MSP_STACK_SIZE 0x0000800
-#define S_PSP_STACK_SIZE 0x0000800
+#define S_HEAP_SIZE (0x0001000)
+#define S_MSP_STACK_SIZE_INIT (0x0000400)
+#define S_MSP_STACK_SIZE (0x0000800)
+#define S_PSP_STACK_SIZE (0x0000800)
-#define NS_HEAP_SIZE 0x0001000
-#define NS_MSP_STACK_SIZE 0x0000400
-#define NS_PSP_STACK_SIZE 0x0000C00
+#define NS_HEAP_SIZE (0x0001000)
+#define NS_MSP_STACK_SIZE (0x0000400)
+#define NS_PSP_STACK_SIZE (0x0000C00)
-/*
- * This size of buffer is big enough to store an attestation
+/* This size of buffer is big enough to store an attestation
* token produced by initial attestation service
*/
-#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE 0x200
+#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE (0x200)
-/*
- * This configuration uses QSPI for code memory and ISRAM0-3 as data
+/* This configuration uses QSPI for code memory and ISRAM0-3 as data
* memory.
*/
#ifdef BL2
#ifndef LINK_TO_SECONDARY_PARTITION
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET FLASH_AREA_IMAGE_0_OFFSET
-#define S_IMAGE_SECONDARY_PARTITION_OFFSET FLASH_AREA_IMAGE_1_OFFSET
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
+#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
#else
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET FLASH_AREA_IMAGE_1_OFFSET
-#define S_IMAGE_SECONDARY_PARTITION_OFFSET FLASH_AREA_IMAGE_0_OFFSET
-#endif /* LINK_TO_SECONDARY_PARTITION */
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
+#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
+#endif /* !LINK_TO_SECONDARY_PARTITION */
#else
-#define S_IMAGE_PRIMARY_PARTITION_OFFSET 0x0
+#define S_IMAGE_PRIMARY_PARTITION_OFFSET (0x0)
#endif /* BL2 */
#ifndef LINK_TO_SECONDARY_PARTITION
#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET \
- + FLASH_AREA_S_IMAGE_SIZE)
+ + FLASH_S_PARTITION_SIZE)
#else
#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET \
- + FLASH_AREA_S_IMAGE_SIZE)
+ + FLASH_S_PARTITION_SIZE)
#endif /* !LINK_TO_SECONDARY_PARTITION */
#ifdef BL2
-/*
- * Boot partition structure if MCUBoot is used:
+/* Boot partition structure if MCUBoot is used:
* 1. Bootloader header
* 2. Image area
* 3. Trailer
*/
-#define BL2_HEADER_SIZE 0x400 /* 1 KB */
-#define BL2_TRAILER_SIZE 0x400 /* 1 KB */
-#else /* BL2 */
+#define BL2_HEADER_SIZE (0x400) /* 1 KB */
+#define BL2_TRAILER_SIZE (0x400) /* 1 KB */
+#else
/* No header if no bootloader, but keep IMAGE_CODE_SIZE the same */
-#define BL2_HEADER_SIZE 0x0
-#define BL2_TRAILER_SIZE 0x800
+#define BL2_HEADER_SIZE (0x0)
+#define BL2_TRAILER_SIZE (0x800)
#endif /* BL2 */
-#define S_IMAGE_CODE_SIZE \
- (FLASH_AREA_S_IMAGE_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
-#define NS_IMAGE_CODE_SIZE \
- (FLASH_AREA_NS_IMAGE_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_S_CODE_SIZE \
+ (FLASH_S_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_NS_CODE_SIZE \
+ (FLASH_NS_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
-#define CMSE_VENEER_REGION_SIZE 0x300
-
-#define S_ROM_ALIAS_BASE 0x10000000
-#define NS_ROM_ALIAS_BASE 0x00000000
-
-/* RAM ALIAS BASES are defined in flash_layout.h */
-#define TOTAL_RAM_SIZE 0x20000 /* 128 KB */
+#define CMSE_VENEER_REGION_SIZE (0x300)
/* Alias definitions for secure and non-secure areas*/
-#define S_ROM_ALIAS(x) (S_ROM_ALIAS_BASE + (x))
-#define NS_ROM_ALIAS(x) (NS_ROM_ALIAS_BASE + (x))
+#define S_ROM_ALIAS(x) (S_ROM_ALIAS_BASE + (x))
+#define NS_ROM_ALIAS(x) (NS_ROM_ALIAS_BASE + (x))
-#define S_RAM_ALIAS(x) (S_RAM_ALIAS_BASE + (x))
-#define NS_RAM_ALIAS(x) (NS_RAM_ALIAS_BASE + (x))
+#define S_RAM_ALIAS(x) (S_RAM_ALIAS_BASE + (x))
+#define NS_RAM_ALIAS(x) (NS_RAM_ALIAS_BASE + (x))
/* Secure regions */
-#define S_IMAGE_PRIMARY_AREA_OFFSET (S_IMAGE_PRIMARY_PARTITION_OFFSET + \
- BL2_HEADER_SIZE)
-#define S_CODE_START S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET)
-#define S_CODE_SIZE (S_IMAGE_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
-#define S_CODE_LIMIT (S_CODE_START + S_CODE_SIZE - 1)
+#define S_IMAGE_PRIMARY_AREA_OFFSET \
+ (S_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
+#define S_CODE_START (S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET))
+#define S_CODE_SIZE (IMAGE_S_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
+#define S_CODE_LIMIT (S_CODE_START + S_CODE_SIZE - 1)
/* ISRAM0 and ISRAM1 are assigned to Secure data */
-#define S_DATA_START S_RAM_ALIAS(0x0)
-#define S_DATA_SIZE (TOTAL_RAM_SIZE / 2 + (TOTAL_RAM_SIZE / 4))
-#define S_DATA_LIMIT (S_DATA_START + S_DATA_SIZE - 1)
+#define S_DATA_START (S_RAM_ALIAS(0x0))
+#define S_DATA_SIZE (TOTAL_RAM_SIZE / 2 + (TOTAL_RAM_SIZE / 4))
+#define S_DATA_LIMIT (S_DATA_START + S_DATA_SIZE - 1)
/* CMSE Veneers region */
-#define CMSE_VENEER_REGION_START (S_CODE_LIMIT + 1)
-#define CMSE_VENEER_REGION_LIMIT (CMSE_VENEER_REGION_START + \
- CMSE_VENEER_REGION_SIZE - 1)
+#define CMSE_VENEER_REGION_START (S_CODE_LIMIT + 1)
/* Non-secure regions */
-#define NS_IMAGE_PRIMARY_AREA_OFFSET (NS_IMAGE_PRIMARY_PARTITION_OFFSET + \
- BL2_HEADER_SIZE)
-#define NS_CODE_START NS_ROM_ALIAS(NS_IMAGE_PRIMARY_AREA_OFFSET)
-#define NS_CODE_SIZE NS_IMAGE_CODE_SIZE
-#define NS_CODE_LIMIT (NS_CODE_START + NS_CODE_SIZE - 1)
-
-/* NS partition information is used for MPC configuration */
-#define NS_PARTITION_START NS_ROM_ALIAS(NS_IMAGE_PRIMARY_PARTITION_OFFSET)
-#define NS_PARTITION_SIZE FLASH_AREA_NS_IMAGE_SIZE
-#define NS_PARTITION_LIMIT (NS_PARTITION_START + NS_PARTITION_SIZE - 1)
+#define NS_IMAGE_PRIMARY_AREA_OFFSET \
+ (NS_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
+#define NS_CODE_START (NS_ROM_ALIAS(NS_IMAGE_PRIMARY_AREA_OFFSET))
+#define NS_CODE_SIZE (IMAGE_NS_CODE_SIZE)
+#define NS_CODE_LIMIT (NS_CODE_START + NS_CODE_SIZE - 1)
/* ISRAM2 and ISRAM3 are assigned to Secure data */
-#define NS_DATA_START NS_RAM_ALIAS(S_DATA_SIZE)
-#define NS_DATA_SIZE (TOTAL_RAM_SIZE - S_DATA_SIZE)
-#define NS_DATA_LIMIT (NS_DATA_START + NS_DATA_SIZE - 1)
+#define NS_DATA_START (NS_RAM_ALIAS(S_DATA_SIZE))
+#define NS_DATA_SIZE (TOTAL_RAM_SIZE - S_DATA_SIZE)
+#define NS_DATA_LIMIT (NS_DATA_START + NS_DATA_SIZE - 1)
+
+/* NS partition information is used for MPC and SAU configuration */
+#define NS_PARTITION_START \
+ (NS_ROM_ALIAS(NS_IMAGE_PRIMARY_PARTITION_OFFSET))
+#define NS_PARTITION_SIZE (FLASH_NS_PARTITION_SIZE)
#ifdef BL2
-#define SECONDARY_PARTITION_START \
- (NS_ROM_ALIAS(S_IMAGE_SECONDARY_PARTITION_OFFSET))
-#define SECONDARY_PARTITION_SIZE FLASH_AREA_IMAGE_1_SIZE
+/* Secondary partition for new images in case of firmware upgrade */
+#define SECONDARY_PARTITION_START \
+ (NS_ROM_ALIAS(S_IMAGE_SECONDARY_PARTITION_OFFSET))
+#define SECONDARY_PARTITION_SIZE (FLASH_AREA_IMAGE_1_SIZE)
#define SECONDARY_PARTITION_LIMIT (SECONDARY_PARTITION_START + \
SECONDARY_PARTITION_SIZE - 1)
-#define BL2_ROM_ALIAS_BASE 0x0
+#define BL2_ROM_ALIAS_BASE (0x0)
#define BL2_ROM_ALIAS(x) (BL2_ROM_ALIAS_BASE + (x))
/* Bootloader regions */
-#define BL2_CODE_START BL2_ROM_ALIAS(FLASH_AREA_BL2_OFFSET)
-#define BL2_CODE_SIZE FLASH_AREA_BL2_SIZE
-#define BL2_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1)
+#define BL2_CODE_START (BL2_ROM_ALIAS(FLASH_AREA_BL2_OFFSET))
+#define BL2_CODE_SIZE (FLASH_AREA_BL2_SIZE)
+#define BL2_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1)
-#define BL2_DATA_START S_RAM_ALIAS(0x0)
-#define BL2_DATA_SIZE TOTAL_RAM_SIZE
-#define BL2_DATA_LIMIT (BL2_DATA_START + BL2_DATA_SIZE - 1)
+#define BL2_DATA_START (S_RAM_ALIAS(0x0))
+#define BL2_DATA_SIZE (TOTAL_RAM_SIZE)
+#define BL2_DATA_LIMIT (BL2_DATA_START + BL2_DATA_SIZE - 1)
#endif /* BL2 */
#endif /* __REGION_DEFS_H__ */
diff --git a/platform/ext/target/musca_a/partition/flash_layout.h b/platform/ext/target/musca_a/partition/flash_layout.h
index 744ecbd..1e3e155 100644
--- a/platform/ext/target/musca_a/partition/flash_layout.h
+++ b/platform/ext/target/musca_a/partition/flash_layout.h
@@ -18,6 +18,7 @@
#define __FLASH_LAYOUT_H__
/* Flash layout on Musca with BL2:
+ *
* 0x0020_0000 BL2 - MCUBoot(128 KB)
* 0x0022_0000 Flash_area_image_0(1 MB)
* 0x0022_0000 Secure image primary
@@ -46,64 +47,76 @@
* marked with comment.
*/
-/* The size of a partition. This should be large enough to contain a S or NS
- * sw binary. Each FLASH_AREA_IMAGE contains two partitions. See Flash layout
- * above.
- */
-#define FLASH_PARTITION_SIZE (0x80000) /* 512KB */
-#define SIGN_BIN_SIZE (FLASH_PARTITION_SIZE + \
- FLASH_PARTITION_SIZE)
+/* Size of a Secure and of a Non-secure image */
+#define FLASH_S_PARTITION_SIZE (0x80000) /* S partition: 512 KB */
+#define FLASH_NS_PARTITION_SIZE (0x80000) /* NS partition: 512 KB */
/* Sector size of the flash hardware */
-#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4KB */
-#define FLASH_TOTAL_SIZE (0x800000) /* 8MB */
+#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 KB */
+#define FLASH_TOTAL_SIZE (0x800000) /* 8 MB */
/* Flash layout info for BL2 bootloader */
-#define FLASH_BASE_ADDRESS (0x10200000) /* same as
- * MPC_QSPI_RANGE_BASE_S
- */
+/* Same as MPC_QSPI_RANGE_BASE_S */
+#define FLASH_BASE_ADDRESS (0x10200000)
/* Offset and size definitions of the flash partitions that are handled by the
* bootloader. The image swapping is done between IMAGE_0 and IMAGE_1, SCRATCH
* is used as a temporary storage during image swapping.
*/
#define FLASH_AREA_BL2_OFFSET (0x0)
-#define FLASH_AREA_BL2_SIZE (0x20000) /* 128KB */
+#define FLASH_AREA_BL2_SIZE (0x20000) /* 128 KB */
-#define FLASH_AREA_IMAGE_0_OFFSET (0x20000)
-#define FLASH_AREA_IMAGE_0_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_0_OFFSET (FLASH_AREA_BL2_OFFSET + \
+ FLASH_AREA_BL2_SIZE)
+#define FLASH_AREA_IMAGE_0_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-#define FLASH_AREA_IMAGE_1_OFFSET (0x120000)
-#define FLASH_AREA_IMAGE_1_SIZE (2 * FLASH_PARTITION_SIZE)
+#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + \
+ FLASH_AREA_IMAGE_0_SIZE)
+#define FLASH_AREA_IMAGE_1_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
-/* Not used, only RAM loading is supported on Musca-A */
-#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (0x220000)
+/* Not used, only the RAM loading firmware upgrade operation
+ * is supported on Musca-A.
+ */
+#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + \
+ FLASH_AREA_IMAGE_1_SIZE)
#define FLASH_AREA_IMAGE_SCRATCH_SIZE (0)
-/*
- * Not used, only RAM loading is supported on Musca-A.
- * The maximum number of status entries supported by the bootloader.
+/* Not used, only the RAM loading firmware upgrade operation
+ * is supported on Musca-A. The maximum number of status entries
+ * supported by the bootloader.
*/
#define BOOT_STATUS_MAX_ENTRIES (0)
-/** Maximum number of image sectors supported by the bootloader. */
-#define BOOT_MAX_IMG_SECTORS ((2 * FLASH_PARTITION_SIZE) / \
+/* Maximum number of image sectors supported by the bootloader. */
+#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
FLASH_AREA_IMAGE_SECTOR_SIZE)
+/* Secure Storage (SST) Service definitions */
#define FLASH_SST_AREA_OFFSET (FLASH_AREA_IMAGE_SCRATCH_OFFSET + \
FLASH_AREA_IMAGE_SCRATCH_SIZE)
#define FLASH_SST_AREA_SIZE (0x5000) /* 20 KB */
+/* NV Counters definitions */
#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_SST_AREA_OFFSET + \
FLASH_SST_AREA_SIZE)
#define FLASH_NV_COUNTERS_AREA_SIZE (0x14) /* 20 Bytes */
-/* Offset and size definition in flash area, used by assemble.py */
-#define SECURE_IMAGE_OFFSET 0x0
-#define SECURE_IMAGE_MAX_SIZE 0x80000
+/* Offset and size definition in flash area used by assemble.py */
+#define SECURE_IMAGE_OFFSET (0x0)
+#define SECURE_IMAGE_MAX_SIZE FLASH_S_PARTITION_SIZE
-#define NON_SECURE_IMAGE_OFFSET 0x80000
-#define NON_SECURE_IMAGE_MAX_SIZE 0x80000
+#define NON_SECURE_IMAGE_OFFSET (SECURE_IMAGE_OFFSET + \
+ SECURE_IMAGE_MAX_SIZE)
+#define NON_SECURE_IMAGE_MAX_SIZE FLASH_NS_PARTITION_SIZE
+
+/* Concatenated binary size and image load address used by imgtool.py */
+#define SIGN_BIN_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
+#define IMAGE_LOAD_ADDRESS (S_SRAM_ALIAS_BASE + \
+ FLASH_AREA_BL2_SIZE)
#define S_QSPI_ALIAS_BASE (0x10200000)
#define NS_QSPI_ALIAS_BASE (0x00200000)
@@ -111,14 +124,6 @@
#define S_SRAM_ALIAS_BASE (0x10000000)
#define NS_SRAM_ALIAS_BASE (0x00000000)
-/* Address that tells the bootloader where in SRAM to copy the image from flash
- * E.g. Lowest address = S_SRAM_ALIAS_BASE
- * + FLASH_AREA_BL2_SIZE
- * = 0x10000000 + 0x20000 = 0x10020000
- * Please make sure the value is in the form of hex. here
- */
-#define IMAGE_LOAD_ADDRESS 0x10020000
-
/* Flash device name used by BL2
* Name is defined in flash driver file: Driver_Flash.c
*/
@@ -136,13 +141,13 @@
#define SST_FLASH_AREA_ADDR FLASH_SST_AREA_OFFSET
#define SST_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
/* The sectors must be in consecutive memory location */
-#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
+#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
/* Specifies the smallest flash programmable unit in bytes */
-#define SST_FLASH_PROGRAM_UNIT 0x1
+#define SST_FLASH_PROGRAM_UNIT (0x1)
/* The maximum asset size to be stored in the SST area */
-#define SST_MAX_ASSET_SIZE 2048
+#define SST_MAX_ASSET_SIZE (2048)
/* The maximum number of assets to be stored in the SST area */
-#define SST_NUM_ASSETS 10
+#define SST_NUM_ASSETS (10)
/* NV Counters definitions */
#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
@@ -150,15 +155,22 @@
#define TFM_NV_COUNTERS_SECTOR_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
#define TFM_NV_COUNTERS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
+/* Use QSPI Flash memory to store Code data */
+#define S_ROM_ALIAS_BASE (0x10200000)
+#define NS_ROM_ALIAS_BASE (0x00200000)
+
/* FIXME: Use SRAM2 memory to store RW data */
#define S_RAM_ALIAS_BASE (0x30000000)
#define NS_RAM_ALIAS_BASE (0x20000000)
+#define TOTAL_ROM_SIZE (0x200000) /* 2 MB */
+#define TOTAL_RAM_SIZE (0x20000) /* 128 KB */
+
/* Shared data area between bootloader and runtime firmware.
* Shared data area is allocated at the beginning of the RAM, it is overlapping
* with TF-M Secure code's MSP stack
*/
#define BOOT_TFM_SHARED_DATA_BASE S_RAM_ALIAS_BASE
-#define BOOT_TFM_SHARED_DATA_SIZE 0x400
+#define BOOT_TFM_SHARED_DATA_SIZE (0x400)
#endif /* __FLASH_LAYOUT_H__ */
diff --git a/platform/ext/target/musca_a/partition/region_defs.h b/platform/ext/target/musca_a/partition/region_defs.h
index 27a6fd3..028abc4 100644
--- a/platform/ext/target/musca_a/partition/region_defs.h
+++ b/platform/ext/target/musca_a/partition/region_defs.h
@@ -19,73 +19,55 @@
#include "flash_layout.h"
-#define TOTAL_ROM_SIZE (0x00200000) /* 2 MB */
-#define TOTAL_RAM_SIZE (0x00020000) /* 128KB */
+#define BL2_HEAP_SIZE (0x0001000)
+#define BL2_MSP_STACK_SIZE (0x0001800)
-#define BL2_HEAP_SIZE 0x0001000
-#define BL2_MSP_STACK_SIZE 0x0001800
+#define S_HEAP_SIZE (0x0001000)
+#define S_MSP_STACK_SIZE_INIT (0x0000400)
+#define S_MSP_STACK_SIZE (0x0000800)
+#define S_PSP_STACK_SIZE (0x0000800)
-#define S_HEAP_SIZE 0x0001000
-#define S_MSP_STACK_SIZE_INIT 0x0000400
-#define S_MSP_STACK_SIZE 0x0000800
-#define S_PSP_STACK_SIZE 0x0000800
+#define NS_HEAP_SIZE (0x0001000)
+#define NS_MSP_STACK_SIZE (0x0000400)
+#define NS_PSP_STACK_SIZE (0x0000C00)
-#define NS_HEAP_SIZE 0x0001000
-#define NS_MSP_STACK_SIZE 0x0000400
-#define NS_PSP_STACK_SIZE 0x0000C00
-
-/*
- * This size of buffer is big enough to store an attestation
+/* This size of buffer is big enough to store an attestation
* token produced by initial attestation service
*/
-#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE 0x200
+#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE (0x200)
-/*
- * MPC granularity is 128 KB on Musca. Alignment
+/* MPC granularity is 128 KB on Musca_A. Alignment
* of partitions is defined in accordance with this constraint.
*/
#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET)
#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_1_OFFSET)
-#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (S_IMAGE_PRIMARY_PARTITION_OFFSET + \
- FLASH_PARTITION_SIZE)
+#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_IMAGE_0_OFFSET \
+ + FLASH_S_PARTITION_SIZE)
-/*
- * Boot partition structure if MCUBoot is used:
+/* Boot partition structure if MCUBoot is used:
* 0x0_0000 Bootloader header
* 0x0_0400 Image area
* 0x1_FC00 Trailer
*/
/* IMAGE_CODE_SIZE is the space available for the software binary image.
- * It is less than the FLASH_PARTITION_SIZE because we reserve space
- * for the image header and trailer introduced by the bootloader.
+ * It is less than the FLASH_S_PARTITION_SIZE + FLASH_NS_PARTITION_SIZE
+ * because we reserve space for the image header and trailer introduced
+ * by the bootloader.
*/
-#define BL2_HEADER_SIZE (0x400)
-#define BL2_TRAILER_SIZE (0x400)
+#define BL2_HEADER_SIZE (0x400) /* 1 KB */
+#define BL2_TRAILER_SIZE (0x400) /* 1 KB */
-#define IMAGE_CODE_SIZE \
- (FLASH_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_S_CODE_SIZE \
+ (FLASH_S_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
+#define IMAGE_NS_CODE_SIZE \
+ (FLASH_NS_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
/* FIXME: veneer region size is increased temporarily while both legacy veneers
* and their iovec-based equivalents co-exist for secure partitions. To be
* adjusted as legacy veneers are eliminated
*/
-#define CMSE_VENEER_REGION_SIZE (0x00000380)
-
-/*
- * Since we enable/disable flash during s/ns code copy to code sram we cannot
- * access bl2 code from flash, hence we need to copy the bl2 code to code sram
- */
-#define BL2_CODE_SRAM_ALIAS_BASE (S_SRAM_ALIAS_BASE)
-#define BL2_CODE_SRAM_ALIAS(x) (BL2_CODE_SRAM_ALIAS_BASE + x)
-#define BL2_CODE_SRAM_BASE (BL2_CODE_SRAM_ALIAS(FLASH_AREA_BL2_OFFSET))
-
-/* Use QSPI Flash memory to store Code data */
-#define S_ROM_ALIAS_BASE (0x10200000)
-#define NS_ROM_ALIAS_BASE (0x00200000)
-
-#define S_RAM_ALIAS_BASE (0x30000000)
-#define NS_RAM_ALIAS_BASE (0x20000000)
+#define CMSE_VENEER_REGION_SIZE (0x380)
/* Alias definitions for secure and non-secure areas*/
#define S_ROM_ALIAS(x) (S_SRAM_ALIAS_BASE + (x))
@@ -95,10 +77,10 @@
#define NS_RAM_ALIAS(x) (NS_RAM_ALIAS_BASE + (x))
/* Secure regions */
-#define S_IMAGE_PRIMARY_AREA_OFFSET \
+#define S_IMAGE_PRIMARY_AREA_OFFSET \
(S_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define S_CODE_START (S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET))
-#define S_CODE_SIZE (IMAGE_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
+#define S_CODE_SIZE (IMAGE_S_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
#define S_CODE_LIMIT (S_CODE_START + S_CODE_SIZE - 1)
#define S_DATA_START (S_RAM_ALIAS(0x0))
@@ -116,7 +98,7 @@
#define NS_IMAGE_PRIMARY_AREA_OFFSET \
(NS_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define NS_CODE_START (NS_ROM_ALIAS(NS_IMAGE_PRIMARY_AREA_OFFSET))
-#define NS_CODE_SIZE (IMAGE_CODE_SIZE - FLASH_AREA_BL2_SIZE)
+#define NS_CODE_SIZE (IMAGE_NS_CODE_SIZE - FLASH_AREA_BL2_SIZE)
#define NS_CODE_LIMIT (NS_CODE_START + NS_CODE_SIZE - 1)
#define NS_DATA_START (NS_RAM_ALIAS(S_DATA_SIZE))
@@ -127,13 +109,11 @@
/* NS partition information is used for MPC and SAU configuration */
#define NS_PARTITION_START \
(NS_ROM_ALIAS(NS_IMAGE_PRIMARY_PARTITION_OFFSET))
-
-#define NS_PARTITION_SIZE (FLASH_PARTITION_SIZE)
+#define NS_PARTITION_SIZE (FLASH_NS_PARTITION_SIZE)
/* Secondary partition for new images in case of firmware upgrade */
#define SECONDARY_PARTITION_START \
(NS_ROM_ALIAS(S_IMAGE_SECONDARY_PARTITION_OFFSET))
-
#define SECONDARY_PARTITION_SIZE (FLASH_AREA_IMAGE_1_SIZE)
/* Code SRAM area */
@@ -150,6 +130,13 @@
#define NS_CODE_SRAM_EXEC_LIMIT (NS_CODE_SRAM_EXEC_BASE + \
(TOTAL_CODE_SRAM_SIZE / 2) - 1)
+/* Since we enable/disable flash during s/ns code copy to code sram we cannot
+ * access bl2 code from flash, hence we need to copy the bl2 code to code sram
+ */
+#define BL2_CODE_SRAM_ALIAS_BASE (S_SRAM_ALIAS_BASE)
+#define BL2_CODE_SRAM_ALIAS(x) (BL2_CODE_SRAM_ALIAS_BASE + x)
+#define BL2_CODE_SRAM_BASE (BL2_CODE_SRAM_ALIAS(FLASH_AREA_BL2_OFFSET))
+
/* Bootloader regions */
#define BL2_CODE_START (S_QSPI_ALIAS_BASE)
#define BL2_CODE_SIZE (FLASH_AREA_BL2_SIZE)
diff --git a/platform/ext/target/musca_b1/partition/flash_layout.h b/platform/ext/target/musca_b1/partition/flash_layout.h
index 31b5dd7..6710f84 100644
--- a/platform/ext/target/musca_b1/partition/flash_layout.h
+++ b/platform/ext/target/musca_b1/partition/flash_layout.h
@@ -18,6 +18,7 @@
#define __FLASH_LAYOUT_H__
/* Flash layout on Musca-B1 with BL2(boot from eFlash 0):
+ *
* 0x0A00_0000 BL2 - MCUBoot(128 KB)
* 0x0A02_0000 Flash_area_image_0(768 KB)
* 0x0A02_0000 Secure image primary (256 KB)
@@ -25,7 +26,6 @@
* 0x0A0E_0000 Flash_area_image_1(768 KB)
* 0x0A0E_0000 Secure image secondary (256 KB)
* 0x0A12_0000 Non-secure image secondary (512 KB)
- * 0x0A1A_0000 Scratch area (256 KB)
* 0x0A1E_0000 Secure Storage Area(0.02 MB)
* 0x0A1E_5000 NV counters area(20 Bytes)
* 0x0A1E_5014 Unused
@@ -43,19 +43,13 @@
* marked with comment.
*/
-/* The sizes of S/NS partitions. These should be large enough to contain a S or
- * NS sw binary. For the detailed sizes, see Flash layout above.
- */
+/* 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 (0x80000) /* NS partition: 512 KB */
-#define FLASH_PARTITION_SIZE (FLASH_S_PARTITION_SIZE + \
- FLASH_NS_PARTITION_SIZE)
-#define SIGN_BIN_SIZE (FLASH_S_PARTITION_SIZE + \
- FLASH_NS_PARTITION_SIZE)
/* Sector size of the flash hardware */
-#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4KB */
-#define FLASH_TOTAL_SIZE (0x200000) /* 2MB */
+#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 KB */
+#define FLASH_TOTAL_SIZE (0x200000) /* 2 MB */
/* Flash layout info for BL2 bootloader */
/* Same as MUSCA_B1_EFLASH0_S_BASE */
@@ -66,26 +60,34 @@
* is used as a temporary storage during image swapping.
*/
#define FLASH_AREA_BL2_OFFSET (0x0)
-#define FLASH_AREA_BL2_SIZE (0x20000) /* 128KB */
+#define FLASH_AREA_BL2_SIZE (0x20000) /* 128 KB */
#define FLASH_AREA_IMAGE_0_OFFSET (FLASH_AREA_BL2_OFFSET + \
FLASH_AREA_BL2_SIZE)
-#define FLASH_AREA_IMAGE_0_SIZE FLASH_PARTITION_SIZE
+#define FLASH_AREA_IMAGE_0_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
#define FLASH_AREA_IMAGE_1_OFFSET (FLASH_AREA_IMAGE_0_OFFSET + \
FLASH_AREA_IMAGE_0_SIZE)
-#define FLASH_AREA_IMAGE_1_SIZE FLASH_PARTITION_SIZE
+#define FLASH_AREA_IMAGE_1_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
+/* Not used, only the Non-swapping firmware upgrade operation
+ * is supported on Musca-B1
+ */
#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (FLASH_AREA_IMAGE_1_OFFSET + \
FLASH_AREA_IMAGE_1_SIZE)
-#define FLASH_AREA_IMAGE_SCRATCH_SIZE (0x40000) /* 256 KB */
+#define FLASH_AREA_IMAGE_SCRATCH_SIZE (0)
-/* Maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES (FLASH_PARTITION_SIZE / \
- FLASH_AREA_IMAGE_SCRATCH_SIZE)
+/* Not used, only the Non-swapping firmware upgrade operation
+ * is supported on Musca-B1. The maximum number of status entries
+ * supported by the bootloader.
+ */
+#define BOOT_STATUS_MAX_ENTRIES (0)
/* Maximum number of image sectors supported by the bootloader. */
-#define BOOT_MAX_IMG_SECTORS (FLASH_PARTITION_SIZE / \
+#define BOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE) / \
FLASH_AREA_IMAGE_SECTOR_SIZE)
/* Note: FLASH_SST_AREA_OFFSET and FLASH_NV_COUNTERS_AREA_OFFSET point to
@@ -96,16 +98,22 @@
FLASH_AREA_IMAGE_SCRATCH_SIZE)
#define FLASH_SST_AREA_SIZE (0x5000) /* 20 KB */
+/* NV Counters definitions */
#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_SST_AREA_OFFSET + \
FLASH_SST_AREA_SIZE)
#define FLASH_NV_COUNTERS_AREA_SIZE (0x14) /* 20 Bytes */
-/* Offset and size definition in flash area, used by assemble.py */
-#define SECURE_IMAGE_OFFSET 0x0
-#define SECURE_IMAGE_MAX_SIZE 0x40000
+/* Offset and size definition in flash area used by assemble.py */
+#define SECURE_IMAGE_OFFSET (0x0)
+#define SECURE_IMAGE_MAX_SIZE FLASH_S_PARTITION_SIZE
-#define NON_SECURE_IMAGE_OFFSET 0x40000
-#define NON_SECURE_IMAGE_MAX_SIZE 0x80000
+#define NON_SECURE_IMAGE_OFFSET (SECURE_IMAGE_OFFSET + \
+ SECURE_IMAGE_MAX_SIZE)
+#define NON_SECURE_IMAGE_MAX_SIZE FLASH_NS_PARTITION_SIZE
+
+/* Concatenated binary size used by imgtool.py */
+#define SIGN_BIN_SIZE (FLASH_S_PARTITION_SIZE + \
+ FLASH_NS_PARTITION_SIZE)
/* Flash device name used by BL2
* Name is defined in flash driver file: Driver_Flash.c
@@ -124,13 +132,13 @@
#define SST_FLASH_AREA_ADDR FLASH_SST_AREA_OFFSET
#define SST_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
/* The sectors must be in consecutive memory location */
-#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
+#define SST_NBR_OF_SECTORS (FLASH_SST_AREA_SIZE / SST_SECTOR_SIZE)
/* Specifies the smallest flash programmable unit in bytes */
-#define SST_FLASH_PROGRAM_UNIT 0x4
+#define SST_FLASH_PROGRAM_UNIT (0x4)
/* The maximum asset size to be stored in the SST area */
-#define SST_MAX_ASSET_SIZE 2048
+#define SST_MAX_ASSET_SIZE (2048)
/* The maximum number of assets to be stored in the SST area */
-#define SST_NUM_ASSETS 10
+#define SST_NUM_ASSETS (10)
/* NV Counters definitions */
#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
@@ -138,15 +146,22 @@
#define TFM_NV_COUNTERS_SECTOR_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
#define TFM_NV_COUNTERS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
+/* Use eFlash 0 memory to store Code data */
+#define S_ROM_ALIAS_BASE (0x1A000000)
+#define NS_ROM_ALIAS_BASE (0x0A000000)
+
/* FIXME: Use SRAM2 memory to store RW data */
#define S_RAM_ALIAS_BASE (0x30000000)
#define NS_RAM_ALIAS_BASE (0x20000000)
+#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
+#define TOTAL_RAM_SIZE (0x80000) /* 512 KB */
+
/* Shared data area between bootloader and runtime firmware.
* Shared data area is allocated at the beginning of the RAM, it is overlapping
* with TF-M Secure code's MSP stack
*/
#define BOOT_TFM_SHARED_DATA_BASE S_RAM_ALIAS_BASE
-#define BOOT_TFM_SHARED_DATA_SIZE 0x400
+#define BOOT_TFM_SHARED_DATA_SIZE (0x400)
#endif /* __FLASH_LAYOUT_H__ */
diff --git a/platform/ext/target/musca_b1/partition/region_defs.h b/platform/ext/target/musca_b1/partition/region_defs.h
index 325c2e5..72dcb21 100644
--- a/platform/ext/target/musca_b1/partition/region_defs.h
+++ b/platform/ext/target/musca_b1/partition/region_defs.h
@@ -19,29 +19,24 @@
#include "flash_layout.h"
-#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
-#define TOTAL_RAM_SIZE (0x00080000) /* 512 KB */
+#define BL2_HEAP_SIZE (0x0001000)
+#define BL2_MSP_STACK_SIZE (0x0001800)
-#define BL2_HEAP_SIZE 0x0001000
-#define BL2_MSP_STACK_SIZE 0x0001800
+#define S_HEAP_SIZE (0x0001000)
+#define S_MSP_STACK_SIZE_INIT (0x0000400)
+#define S_MSP_STACK_SIZE (0x0000800)
+#define S_PSP_STACK_SIZE (0x0000800)
-#define S_HEAP_SIZE 0x0001000
-#define S_MSP_STACK_SIZE_INIT 0x0000400
-#define S_MSP_STACK_SIZE 0x0000800
-#define S_PSP_STACK_SIZE 0x0000800
+#define NS_HEAP_SIZE (0x0001000)
+#define NS_MSP_STACK_SIZE (0x0000400)
+#define NS_PSP_STACK_SIZE (0x0000C00)
-#define NS_HEAP_SIZE 0x0001000
-#define NS_MSP_STACK_SIZE 0x0000400
-#define NS_PSP_STACK_SIZE 0x0000C00
-
-/*
- * This size of buffer is big enough to store an attestation
+/* This size of buffer is big enough to store an attestation
* token produced by initial attestation service
*/
-#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE 0x200
+#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE (0x200)
-/*
- * MPC granularity is 128 KB on Musca. Alignment
+/* MPC granularity is 128 KB on Musca_B1. Alignment
* of partitions is defined in accordance with this constraint.
*/
#ifdef BL2
@@ -64,19 +59,19 @@
+ FLASH_S_PARTITION_SIZE)
#endif /* !LINK_TO_SECONDARY_PARTITION */
-/*
- * Boot partition structure if MCUBoot is used:
+/* Boot partition structure if MCUBoot is used:
* 0x0_0000 Bootloader header
* 0x0_0400 Image area
* 0x1_FC00 Trailer
*/
/* IMAGE_CODE_SIZE is the space available for the software binary image.
- * It is less than the FLASH_PARTITION_SIZE because we reserve space
- * for the image header and trailer introduced by the bootloader.
+ * It is less than the FLASH_S_PARTITION_SIZE + FLASH_NS_PARTITION_SIZE
+ * because we reserve space for the image header and trailer introduced
+ * by the bootloader.
*/
#ifdef BL2
-#define BL2_HEADER_SIZE (0x400)
-#define BL2_TRAILER_SIZE (0x400)
+#define BL2_HEADER_SIZE (0x400) /* 1 KB */
+#define BL2_TRAILER_SIZE (0x400) /* 1 KB */
#else
/* No header if no bootloader, but keep IMAGE_CODE_SIZE the same */
#define BL2_HEADER_SIZE (0x0)
@@ -92,14 +87,7 @@
* and their iovec-based equivalents co-exist for secure partitions. To be
* adjusted as legacy veneers are eliminated
*/
-#define CMSE_VENEER_REGION_SIZE (0x00000380)
-
-/* Use eFlash 0 memory to store Code data */
-#define S_ROM_ALIAS_BASE (0x1A000000)
-#define NS_ROM_ALIAS_BASE (0x0A000000)
-
-#define S_RAM_ALIAS_BASE (0x30000000)
-#define NS_RAM_ALIAS_BASE (0x20000000)
+#define CMSE_VENEER_REGION_SIZE (0x380)
/* Alias definitions for secure and non-secure areas*/
#define S_ROM_ALIAS(x) (S_ROM_ALIAS_BASE + (x))
@@ -109,7 +97,7 @@
#define NS_RAM_ALIAS(x) (NS_RAM_ALIAS_BASE + (x))
/* Secure regions */
-#define S_IMAGE_PRIMARY_AREA_OFFSET \
+#define S_IMAGE_PRIMARY_AREA_OFFSET \
(S_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define S_CODE_START (S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET))
#define S_CODE_SIZE (IMAGE_S_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
@@ -136,13 +124,11 @@
/* NS partition information is used for MPC and SAU configuration */
#define NS_PARTITION_START \
(NS_ROM_ALIAS(NS_IMAGE_PRIMARY_PARTITION_OFFSET))
-
#define NS_PARTITION_SIZE (FLASH_NS_PARTITION_SIZE)
/* Secondary partition for new images in case of firmware upgrade */
#define SECONDARY_PARTITION_START \
(NS_ROM_ALIAS(S_IMAGE_SECONDARY_PARTITION_OFFSET))
-
#define SECONDARY_PARTITION_SIZE (FLASH_AREA_IMAGE_1_SIZE)
/* Code SRAM area */