new file mode 100644
@@ -0,0 +1,36 @@
+From 9eee1fb21191cf8702054182136a626315017511 Mon Sep 17 00:00:00 2001
+From: Bence Balogh <bence.balogh@arm.com>
+Date: Fri, 2 Aug 2024 22:02:55 +0200
+Subject: [PATCH 2/6] Platform: CS1000: Fix Bank offsets
+
+The BANK_0_PARTITION_OFFSET and BANK_1_PARTITION_OFFSET are used for
+erasing the banks during capsule update. The fwu_agent erases the flash
+using them as starting addresses. The BL2 (MCUBoot) should also
+be erased during capsule update.
+
+Signed-off-by: Bence Balogh <bence.balogh@arm.com>
+Upstream-Status: Pending [Not submitted to upstream yet]
+---
+ .../ext/target/arm/corstone1000/partition/flash_layout.h | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/platform/ext/target/arm/corstone1000/partition/flash_layout.h b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
+index 9fc1d9fa63..2c5dba7006 100644
+--- a/platform/ext/target/arm/corstone1000/partition/flash_layout.h
++++ b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
+@@ -109,10 +109,8 @@
+ #define FWU_PRIVATE_METADATA_REPLICA_2_OFFSET (FWU_PRIVATE_METADATA_REPLICA_1_OFFSET + \
+ FWU_METADATA_FLASH_SECTOR_SIZE)
+
+-#define BANK_0_PARTITION_OFFSET (SE_BL2_BANK_0_OFFSET + \
+- SE_BL2_PARTITION_SIZE)
+-#define BANK_1_PARTITION_OFFSET (SE_BL2_BANK_1_OFFSET + \
+- SE_BL2_PARTITION_SIZE)
++#define BANK_0_PARTITION_OFFSET (SE_BL2_BANK_0_OFFSET)
++#define BANK_1_PARTITION_OFFSET (SE_BL2_BANK_1_OFFSET)
+
+ /* BL1: mcuboot flashmap configurations */
+ #define FLASH_AREA_8_ID (1)
+--
+2.25.1
+
@@ -30,6 +30,7 @@ SRC_URI:append:corstone1000 = " \
file://0010-platform-CS1000-Add-multicore-support-for-FVP.patch \
file://0011-Platform-Corstone1000-switch-to-metadata-v2.patch \
file://0012-platform-corstone1000-Increase-flash-PS-area-size.patch \
+ file://0013-Platform-CS1000-Fix-Bank-offsets.patch \
"
# TF-M ships patches for external dependencies that needs to be applied
@@ -26,7 +26,8 @@ part --source rawcopy --size 2 --sourceparams="file=signed_fip-corstone1000.bin"
part --source rawcopy --size 12 --sourceparams="file=Image.gz-initramfs-${MACHINE}.bin" --align 4 --part-name="kernel_primary" --uuid BF7A6142-0662-47FD-9434-6A8811980816 --part-type 8197561D-6124-46FC-921E-141CC5745B05
-part --source empty --size 100k --offset 16488k --align 4 --part-name="bl2_secondary" --uuid 3F0C49A4-48B7-4D1E-AF59-3E4A3CE1BA9F --part-type 64BD8ADB-02C0-4819-8688-03AB4CAB0ED9
+# The offset has to be aligned to TF-M's SE_BL2_BANK_1_OFFSET define (tfm/platform/ext/target/arm/corstone1000/partition/flash_layout.h)
+part --source empty --size 100k --offset 16392k --align 4 --part-name="bl2_secondary" --uuid 3F0C49A4-48B7-4D1E-AF59-3E4A3CE1BA9F --part-type 64BD8ADB-02C0-4819-8688-03AB4CAB0ED9
part --source empty --size 368k --align 4 --part-name="tfm_secondary" --uuid 009A6A12-64A6-4F0F-9882-57CD79A34A3D --part-type D763C27F-07F6-4FF0-B2F3-060CB465CD4E
part --source empty --size 2 --align 4 --part-name="FIP_B" --uuid 9424E370-7BC9-43BB-8C23-71EE645E1273 --part-type B5EB19BD-CF56-45E8-ABA7-7ADB228FFEA7
part --source empty --size 12 --align 4 --part-name="kernel_secondary" --uuid A2698A91-F9B1-4629-9188-94E4520808F8 --part-type 8197561D-6124-46FC-921E-141CC5745B05