Platform: Change secure memory allocation

Change the NS/S memory allocation to fit the ITS service.

Change-Id: I55b4a321a2e0aebad9f53d91cb1bf41159e3e851
Signed-off-by: Tudor Cretu <tudor.cretu@arm.com>
diff --git a/docs/user_guides/tfm_secure_boot.rst b/docs/user_guides/tfm_secure_boot.rst
index 83e372a..d2b5ebb 100644
--- a/docs/user_guides/tfm_secure_boot.rst
+++ b/docs/user_guides/tfm_secure_boot.rst
@@ -650,11 +650,11 @@
 
 - Linux::
 
-    srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 tfm_sign_1.bin -Binary -offset 0xA0E0000 -o tfm.hex -Intel
+    srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 tfm_sign_1.bin -Binary -offset 0xA0F0000 -o tfm.hex -Intel
 
 - Windows::
 
-    srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 tfm_sign_1.bin -Binary -offset 0xA0E0000 -o tfm.hex -Intel
+    srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0xA000000 tfm_sign.bin -Binary -offset 0xA020000 tfm_sign_1.bin -Binary -offset 0xA0F0000 -o tfm.hex -Intel
 
 The following message will be shown in case of successful firmware upgrade,
 notice that image with higher version number (``version=1.2.3.5``) is executed:
diff --git a/platform/ext/target/mps3/an524/partition/flash_layout.h b/platform/ext/target/mps3/an524/partition/flash_layout.h
index f2a3a04..22be543 100644
--- a/platform/ext/target/mps3/an524/partition/flash_layout.h
+++ b/platform/ext/target/mps3/an524/partition/flash_layout.h
@@ -28,27 +28,26 @@
  *
  * 0x0000_0000 BL2 - MCUBoot            (256 KB)
  * Primary image area:
- *     0x0004_0000 Secure image         (256 KB)
- *     0x0008_0000 Non-secure image     (256 KB)
+ *     0x0004_0000 Secure image         (512 KB)
+ *     0x000C_0000 Non-secure image     (256 KB)
  * Secondary image area:
- *     0x000C_0000 Secure image         (256 KB)
- *     0x0010_0000 Non-secure image     (256 KB)
- * 0x0014_0000 Scratch area             (512 KB)
+ *     0x0010_0000 Secure image         (512 KB)
+ *     0x0018_0000 Non-secure image     (256 KB)
  * 0x001C_0000 SST area                 (20 KB)
  * 0x001C_5000 NV counters              (4 KB)
  * 0x001C_6000 Unused
  *
  * Flash layout without BL2
  *
- * 0x0000_0000 Secure image             (256 KB)
- * 0x0008_0000 Non-secure image         (256 KB)
+ * 0x0000_0000 Secure image             (512 KB)
+ * 0x000C_0000 Non-secure image         (256 KB)
  * 0x001C_0000 SST area                 (20 KB)
  * 0x001C_5000 NV counters              (4 KB)
  * 0x001C_6000 Unused
  */
 
 /* Size of a Secure and of a Non-secure image */
-#define FLASH_S_PARTITION_SIZE          (0x40000) /* S partition: 256 KB */
+#define FLASH_S_PARTITION_SIZE          (0x80000) /* S partition: 512 KB */
 #define FLASH_NS_PARTITION_SIZE         (0x40000) /* NS partition: 256 KB */
 #define FLASH_MAX_PARTITION_SIZE        ((FLASH_S_PARTITION_SIZE >   \
                                           FLASH_NS_PARTITION_SIZE) ? \
diff --git a/platform/ext/target/musca_a/partition/flash_layout.h b/platform/ext/target/musca_a/partition/flash_layout.h
index 92a5b81..ada2ae1 100644
--- a/platform/ext/target/musca_a/partition/flash_layout.h
+++ b/platform/ext/target/musca_a/partition/flash_layout.h
@@ -26,9 +26,9 @@
  * 0x0032_0000 Secondary image area (1 MB):
  *    0x0032_0000 Secure     image secondary
  *    0x003A_0000 Non-secure image secondary
- * 0x0042_0000 Secure Storage Area (0.02 MB)
- * 0x0042_5000 NV counters area (4 KB)
- * 0x0042_6000 Unused
+ * 0x0042_0000 Secure Storage Area (8 KB)
+ * 0x0042_2000 NV counters area (4 KB)
+ * 0x0042_3000 Unused
  */
 
 /* Code SRAM layout on Musca (with BL2, which is mandatory) after the newest
@@ -131,7 +131,7 @@
 /* Secure Storage (SST) Service definitions */
 #define FLASH_SST_AREA_OFFSET           (FLASH_AREA_SCRATCH_OFFSET + \
                                          FLASH_AREA_SCRATCH_SIZE)
-#define FLASH_SST_AREA_SIZE             (0x5000)   /* 20 KB */
+#define FLASH_SST_AREA_SIZE             (0x2000)   /* 8 KB */
 
 /* NV Counters definitions */
 #define FLASH_NV_COUNTERS_AREA_OFFSET   (FLASH_SST_AREA_OFFSET + \
@@ -177,7 +177,7 @@
 /* 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)
+#define SST_MAX_ASSET_SIZE      (512)
 /* The maximum number of assets to be stored in the SST area */
 #define SST_NUM_ASSETS          (10)
 
diff --git a/platform/ext/target/musca_a/partition/region_defs.h b/platform/ext/target/musca_a/partition/region_defs.h
index 839e3d5..144a7f9 100644
--- a/platform/ext/target/musca_a/partition/region_defs.h
+++ b/platform/ext/target/musca_a/partition/region_defs.h
@@ -80,11 +80,11 @@
 #define S_CODE_LIMIT    (S_CODE_START + S_CODE_SIZE - 1)
 
 #define S_DATA_START    (S_RAM_ALIAS(0x0))
-/* Reserve 104 KB of RAM to the SPE to meet worst case scenario
+/* Reserve 96 KB of RAM to the SPE to meet worst case scenario
  * requirements which are encountered in IPC mode and regression
- * tests enabled. Leave the remaining 24 KB to the NSPE.
+ * tests enabled. Leave the remaining 32 KB to the NSPE.
  */
-#define S_DATA_SIZE     ((TOTAL_RAM_SIZE / 16) * 13)
+#define S_DATA_SIZE     ((TOTAL_RAM_SIZE / 4) * 3)
 #define S_DATA_LIMIT    (S_DATA_START + S_DATA_SIZE - 1)
 
 /* CMSE Veneers region */
diff --git a/platform/ext/target/musca_b1/partition/flash_layout.h b/platform/ext/target/musca_b1/partition/flash_layout.h
index 3547dc8..9255b8c 100644
--- a/platform/ext/target/musca_b1/partition/flash_layout.h
+++ b/platform/ext/target/musca_b1/partition/flash_layout.h
@@ -20,19 +20,19 @@
 /* Flash layout on Musca-B1 with BL2(single image boot, boot from eFlash 0):
  *
  * 0x0A00_0000 BL2 - MCUBoot (128 KB)
- * 0x0A02_0000 Primary image area (768 KB):
- *    0x0A02_0000 Secure     image primary (256 KB)
- *    0x0A06_0000 Non-secure image primary (512 KB)
- * 0x0A0E_0000 Secondary image area (768 KB):
- *    0x0A0E_0000 Secure     image secondary (256 KB)
- *    0x0A12_0000 Non-secure image secondary (512 KB)
- * 0x0A1E_0000 Secure Storage Area (0.02 MB)
- * 0x0A1E_5000 NV counters area (4 KB)
- * 0x0A1E_6000 Unused
+ * 0x0A02_0000 Primary image area (832 KB):
+ *    0x0A02_0000 Secure     image primary (320 KB)
+ *    0x0A07_0000 Non-secure image primary (512 KB)
+ * 0x0A0F_0000 Secondary image area (832 KB):
+ *    0x0A0F_0000 Secure     image secondary (320 KB)
+ *    0x0A14_0000 Non-secure image secondary (512 KB)
+ * 0x0A1C_0000 Secure Storage Area (0.02 MB)
+ * 0x0A1C_5000 NV counters area (4 KB)
+ * 0x0A1C_6000 Unused
  *
  * Flash layout on Musca-B1 without BL2:
  * 0x0A00_0000 Secure     image
- * 0x0A06_0000 Non-secure image
+ * 0x0A07_0000 Non-secure image
  */
 
 /* This header file is included from linker scatter file as well, where only a
@@ -43,7 +43,7 @@
  */
 
 /* Size of a Secure and of a Non-secure image */
-#define FLASH_S_PARTITION_SIZE          (0x40000) /* S partition: 256 KB */
+#define FLASH_S_PARTITION_SIZE          (0x50000) /* S partition: 320 KB */
 #define FLASH_NS_PARTITION_SIZE         (0x80000) /* NS partition: 512 KB */
 #define FLASH_MAX_PARTITION_SIZE        ((FLASH_S_PARTITION_SIZE >   \
                                           FLASH_NS_PARTITION_SIZE) ? \
diff --git a/platform/ext/target/musca_b1/partition/region_defs.h b/platform/ext/target/musca_b1/partition/region_defs.h
index da051bf..3e46a59 100644
--- a/platform/ext/target/musca_b1/partition/region_defs.h
+++ b/platform/ext/target/musca_b1/partition/region_defs.h
@@ -36,7 +36,7 @@
  */
 #define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE   (0x250)
 
-/* MPC granularity is 128 KB on Musca_B1. Alignment
+/* eFlash MPC granularity is 4 KB on Musca_B1. Alignment
  * of partitions is defined in accordance with this constraint.
  */
 #ifdef BL2