PSoC64: Layout and partition changes
Rename the "scratch" area to "unused".
Rather than naming the combined ITS/PS/unused/NVC area "reserved"
while also having a separate "system reserved" area, rename the former
to "data".
Increase the size of the PS are from 20KB to 24KB (taking from the
unused area).
Re-order the PS, unused, and NV counters areas in flash.
Remove unused macros.
Rework SMPU region that covers PS accordingly.
Change-Id: I53e7e258893653bc167e267813bfb33f10937f33
Signed-off-by: Chris Brand <chris.brand@cypress.com>
diff --git a/platform/ext/target/cypress/psoc64/partition/flash_layout.h b/platform/ext/target/cypress/psoc64/partition/flash_layout.h
index 21bd8fe..1bf06a1 100644
--- a/platform/ext/target/cypress/psoc64/partition/flash_layout.h
+++ b/platform/ext/target/cypress/psoc64/partition/flash_layout.h
@@ -29,16 +29,14 @@
* 0x1017_0000 Secure image secondary (320 KB)
* 0x101c_0000 - 0x101f_ffff Reserved
* 0x101c_0000 Internal Trusted Storage Area (16 KB)
- * 0x101c_4000 NV counters area (1 KB)
- * 0x101c_4400 Scratch area (27 KB)
- * 0x101c_b000 Protected Storage Area (20 KB)
+ * 0x101c_4000 Protected Storage Area (24 KB)
+ * 0x101c_a000 Unused area (23 KB)
+ * 0x101c_fc00 NV counters area (1 KB)
* 0x101d_0000 Reserved (192 KB)
* 0x101f_ffff End of Flash
*
*/
-#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_base_address.h to access flash related defines. To resolve
@@ -46,6 +44,10 @@
* marked with comment.
*/
+#ifdef BL2
+#error "BL2 configuration is not supported"
+#endif /* BL2 */
+
/* The size of S partition */
#define FLASH_S_PARTITION_SIZE 0x50000 /* 320 KB */
/* The size of NS partition */
@@ -60,34 +62,30 @@
#define FLASH_BASE_ADDRESS (0x10000000U) /* same as FLASH0_BASE */
/* Reserved areas */
-#define FLASH_RESERVED_AREA_OFFSET (SECURE_IMAGE_OFFSET + \
+#define FLASH_DATA_AREA_OFFSET (SECURE_IMAGE_OFFSET + \
2*SECURE_IMAGE_MAX_SIZE + \
NON_SECURE_IMAGE_MAX_SIZE)
/* FixMe: implement proper mcuboot partitioning for CYBL */
/* Internal Trusted Storage Area */
-#define FLASH_ITS_AREA_OFFSET (FLASH_RESERVED_AREA_OFFSET)
+#define FLASH_ITS_AREA_OFFSET (FLASH_DATA_AREA_OFFSET)
#define FLASH_ITS_AREA_SIZE (0x4000) /* 16 KB */
-/* Non-volatile Counters Area */
-#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_ITS_AREA_OFFSET + \
- FLASH_ITS_AREA_SIZE)
-#define FLASH_NV_COUNTERS_AREA_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
-
-#ifdef BL2
-#error "BL2 configuration is not supported"
-#endif /* BL2 */
-
-/* Scratch Area - unused */
-#define FLASH_AREA_SCRATCH_OFFSET (FLASH_NV_COUNTERS_AREA_OFFSET + \
- FLASH_NV_COUNTERS_AREA_SIZE)
-#define FLASH_AREA_SCRATCH_SIZE (0x6c00) /* 27 KB */
-
/* Protected Storage Area */
-#define FLASH_PS_AREA_OFFSET (FLASH_AREA_SCRATCH_OFFSET + \
- FLASH_AREA_SCRATCH_SIZE)
-#define FLASH_PS_AREA_SIZE (0x5000) /* 20 KB */
+#define FLASH_PS_AREA_OFFSET (FLASH_ITS_AREA_OFFSET + \
+ FLASH_ITS_AREA_SIZE)
+#define FLASH_PS_AREA_SIZE (0x6000) /* 24 KB */
+
+/* Unused Area */
+#define FLASH_UNUSED_AREA_OFFSET (FLASH_PS_AREA_OFFSET + \
+ FLASH_PS_AREA_SIZE)
+#define FLASH_UNUSED_AREA_SIZE (0x5c00) /* 23 KB */
+
+/* Non-volatile Counters Area */
+#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_UNUSED_AREA_OFFSET + \
+ FLASH_UNUSED_AREA_SIZE)
+#define FLASH_NV_COUNTERS_AREA_SIZE (2 * FLASH_AREA_IMAGE_SECTOR_SIZE)
#define FLASH_AREA_SYSTEM_RESERVED_SIZE (0x30000) /* 192 KB */
@@ -105,21 +103,16 @@
/* Check if it fits into available Flash*/
-#define FLASH_RESERVED_AREA_SIZE (FLASH_ITS_AREA_SIZE + \
- FLASH_NV_COUNTERS_AREA_SIZE + \
- FLASH_AREA_SCRATCH_SIZE + \
+#define FLASH_DATA_AREA_SIZE (FLASH_ITS_AREA_SIZE + \
FLASH_PS_AREA_SIZE + \
+ FLASH_UNUSED_AREA_SIZE + \
+ FLASH_NV_COUNTERS_AREA_SIZE + \
FLASH_AREA_SYSTEM_RESERVED_SIZE)
-#if (FLASH_RESERVED_AREA_OFFSET + FLASH_RESERVED_AREA_SIZE) > (FLASH_TOTAL_SIZE)
+#if (FLASH_DATA_AREA_OFFSET + FLASH_DATA_AREA_SIZE) > (FLASH_TOTAL_SIZE)
#error "Out of Flash memory"
#endif
-/* Flash device name used by BL2 and PS
- * Name is defined in flash driver file: Driver_Flash.c
- */
-#define FLASH_DEV_NAME Driver_FLASH0
-
/* Protected Storage (PS) Service definitions
* Note: Further documentation of these definitions can be found in the
* TF-M PS Integration Guide.
diff --git a/platform/ext/target/cypress/psoc64/smpu_config.h b/platform/ext/target/cypress/psoc64/smpu_config.h
index 37295f8..5a62303 100644
--- a/platform/ext/target/cypress/psoc64/smpu_config.h
+++ b/platform/ext/target/cypress/psoc64/smpu_config.h
@@ -120,11 +120,13 @@
#endif
/* SMPU3 - PS in Flash */
-#define SMPU3_BASE S_ROM_ALIAS(0x1c8000)
-#define SMPU3_REGIONSIZE PROT_SIZE_32KB_BIT_SHIFT
+#define SMPU3_BASE S_ROM_ALIAS(0x1c0000)
+#define SMPU3_REGIONSIZE PROT_SIZE_64KB_BIT_SHIFT
#define SMPU3_SUBREGION_DIS (CY_PROT_SUBREGION_DIS0 | \
CY_PROT_SUBREGION_DIS1 | \
- CY_PROT_SUBREGION_DIS2)
+ CY_PROT_SUBREGION_DIS5 | \
+ CY_PROT_SUBREGION_DIS6 | \
+ CY_PROT_SUBREGION_DIS7)
#define SMPU3_SLAVE_CONFIG {\
.address = (void *)SMPU3_BASE, \
.regionSize = (cy_en_prot_size_t) SMPU3_REGIONSIZE, \
@@ -143,17 +145,17 @@
#endif
/*
- * PS_FLASH_AREA_ADDR must equal the base address of subregion 3 of
+ * PS_FLASH_AREA_ADDR must equal the base address of subregion 2 of
* SMPU3
*/
#if S_ROM_ALIAS(PS_FLASH_AREA_ADDR) != (SMPU3_BASE + \
- (3 * REGIONSIZE_TO_BYTES(SMPU3_REGIONSIZE) / 8))
-#error "Flash layout has changed - S_DATA_PRIV_START isn't subregion 3 of SMPU3"
+ (2 * REGIONSIZE_TO_BYTES(SMPU3_REGIONSIZE) / 8))
+#error "Flash layout has changed - PS_FLASH_AREA_ADDR isn't subregion 2 of SMPU3"
#endif
/* Should exactly cover the PS region */
-#if FLASH_PS_AREA_SIZE != (5 * REGIONSIZE_TO_BYTES(SMPU3_REGIONSIZE) / 8)
-#error "Flash layout has changed - SMPU3_REGIONSIZE isn't FLASH_PS_AREA_SIZE"
+#if FLASH_PS_AREA_SIZE != (3 * REGIONSIZE_TO_BYTES(SMPU3_REGIONSIZE) / 8)
+#error "Flash layout has changed - 3/5 of SMPU3_REGIONSIZE isn't FLASH_PS_AREA_SIZE"
#endif
/* SMPU6 - 32KB of unprivileged secure data in SRAM */