Platform: Change flash layout on Musca-A1
- Change the size of an image from 192KB to 1MB in the Musca-A1 flash
layout configuration, and remove the scratch area as it isn't used
(Musca-A1 does not support swapping mode for image upgrade)
- Change the size of the memory allocated to BL2 from 64KB to 128KB
- Show the layout of Code SRAM after image has been copied to the load
address
Signed-off-by: Oliver Swede <oli.swede@arm.com>
Change-Id: Ie006fd199e1b9c920ed00247419a47fca5ee2c67
diff --git a/docs/user_guides/tfm_user_guide.md b/docs/user_guides/tfm_user_guide.md
index 77c9ad0..ae7751f 100755
--- a/docs/user_guides/tfm_user_guide.md
+++ b/docs/user_guides/tfm_user_guide.md
@@ -202,9 +202,9 @@
1. Create a unified hex file comprising of both mcuboot and tfm_sign binary
* Windows
- `srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0x200000 tfm_sign.bin -Binary -offset 0x210000 -o tfm.hex -Intel`
+ `srec_cat.exe bl2\ext\mcuboot\mcuboot.bin -Binary -offset 0x200000 tfm_sign.bin -Binary -offset 0x220000 -o tfm.hex -Intel`
* Linux
- `srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0x200000 tfm_sign.bin -Binary -offset 0x210000 -o tfm.hex -Intel`
+ `srec_cat bl2/ext/mcuboot/mcuboot.bin -Binary -offset 0x200000 tfm_sign.bin -Binary -offset 0x220000 -o tfm.hex -Intel`
2. Plug in the Musca-A1 board in your computer. The board should appear as USB
drive
3. Drag and drop `tfm.hex` to the USB drive
@@ -218,7 +218,7 @@
[INF] Scratch: magic=bad, copy_done=0x5, image_ok=0xd9
[INF] Boot source: slot 0
[INF] Swap type: none
-[INF] Bootloader chainload address offset: 0x10000
+[INF] Bootloader chainload address offset: 0x20000
[INF] Jumping to the first image slot
[Sec Thread] Secure image initializing!
```
@@ -234,7 +234,7 @@
[INF] Scratch: magic=bad, copy_done=0x5, image_ok=0x9
[INF] Boot source: slot 0
[INF] Swap type: none
-[INF] Bootloader chainload address offset: 0x10000
+[INF] Bootloader chainload address offset: 0x20000
[INF] Jumping to the first image slot
[Sec Thread] Secure image initializing!
diff --git a/platform/ext/musca_a.cmake b/platform/ext/musca_a.cmake
index dec8fe8..d0b76e9 100755
--- a/platform/ext/musca_a.cmake
+++ b/platform/ext/musca_a.cmake
@@ -34,7 +34,7 @@
endif()
set (FLASH_LAYOUT "${PLATFORM_DIR}/target/musca_a/partition/flash_layout.h")
set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/musca_a/partition")
-set (SIGN_BIN_SIZE 0x30000)
+set (SIGN_BIN_SIZE 0x100000)
if (BL2)
set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
diff --git a/platform/ext/target/musca_a/partition/flash_layout.h b/platform/ext/target/musca_a/partition/flash_layout.h
index 11cf3ed..893c638 100755
--- a/platform/ext/target/musca_a/partition/flash_layout.h
+++ b/platform/ext/target/musca_a/partition/flash_layout.h
@@ -18,20 +18,24 @@
#define __FLASH_LAYOUT_H__
/* Flash layout on Musca with BL2:
- * 0x0020_0000 BL2 - MCUBoot(64 KB)
- * 0x0021_0000 Flash_area_image_0(192 KB)
- * 0x0021_0000 Secure image primary
- * 0x0023_0000 Non-secure image primary
- * 0x0024_0000 Flash_area_image_1(192 KB)
- * 0x0024_0000 Secure image secondary
- * 0x0026_0000 Non-secure image secondary
- * 0x0027_0000 Scratch area(192 KB)
- * 0x002A_0000 Secure Storage Area (0.02 MB)
- * 0x002A_5000 Unused
- *
- * Flash layout on Musca, if BL2 not defined:
- * 0x0020_0000 Secure image
- * 0x0022_0000 Non-secure image
+ * 0x0020_0000 BL2 - MCUBoot(128 KB)
+ * 0x0022_0000 Flash_area_image_0(1 MB)
+ * 0x0022_0000 Secure image primary
+ * 0x002A_0000 Non-secure image primary
+ * 0x0032_0000 Flash_area_image_1(1 MB)
+ * 0x0032_0000 Secure image secondary
+ * 0x003A_0000 Non-secure image secondary
+ * 0x0042_0000 Secure Storage Area (0.02 MB)
+ * 0x0042_5000 Unused
+ */
+
+/* Code SRAM layout on Musca (with BL2, which is mandatory) after the newest
+ * image has been copied to SRAM:
+ * 0x0000_0000 BL2 - MCUBoot(128 KB)
+ * 0x0002_0000 Flash_area_newest_image(1 MB)
+ * 0x0002_0000 Secure image primary
+ * 0x000A_0000 Non-secure image primary
+ * 0x0012_00000 Unused
*/
/* This header file is included from linker scatter file as well, where only a
@@ -45,7 +49,7 @@
* sw binary. Each FLASH_AREA_IMAGE contains two partitions. See Flash layout
* above.
*/
-#define FLASH_PARTITION_SIZE (0x20000) /* 128KB */
+#define FLASH_PARTITION_SIZE (0x80000) /* 512KB */
/* Sector size of the flash hardware; same as FLASH0_SECTOR_SIZE */
#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 kB */
@@ -60,32 +64,26 @@
* is used as a temporary storage during image swapping.
*/
#define FLASH_AREA_BL2_OFFSET (0x0)
-#ifdef BL2
-#define FLASH_AREA_BL2_SIZE (0x10000) /* 64KB */
-#else
-#define FLASH_AREA_BL2_SIZE (0x0)
-#endif
-#define FLASH_AREA_IMAGE_SIZE ((2 * FLASH_PARTITION_SIZE) -\
- FLASH_AREA_BL2_SIZE)
+#define FLASH_AREA_BL2_SIZE (0x20000) /* 128KB */
-#define FLASH_AREA_IMAGE_0_OFFSET (FLASH_AREA_BL2_OFFSET + \
- FLASH_AREA_BL2_SIZE)
-#define FLASH_AREA_IMAGE_0_SIZE (FLASH_AREA_IMAGE_SIZE)
+#define FLASH_AREA_IMAGE_0_OFFSET (0x20000)
+#define FLASH_AREA_IMAGE_0_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_AREA_IMAGE_SIZE)
+#define FLASH_AREA_IMAGE_1_OFFSET (0x120000)
+#define FLASH_AREA_IMAGE_1_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_AREA_IMAGE_SIZE)
+/* Not used, only RAM loading is supported on Musca A1 */
+#define FLASH_AREA_IMAGE_SCRATCH_OFFSET (0x220000)
+#define FLASH_AREA_IMAGE_SCRATCH_SIZE (0)
-/* Maximum number of status entries supported by the bootloader. */
-#define BOOT_STATUS_MAX_ENTRIES (FLASH_AREA_IMAGE_SIZE / \
- FLASH_AREA_IMAGE_SCRATCH_SIZE)
+/*
+ * Not used, only RAM loading is supported on Musca A1.
+ * 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_AREA_IMAGE_SIZE / \
+#define BOOT_MAX_IMG_SECTORS ((2 * FLASH_PARTITION_SIZE) / \
FLASH_AREA_IMAGE_SECTOR_SIZE)
/*
* Note: Though the SST_FLASH_AREA_ADDR is pointing to offset in flash, but
@@ -98,10 +96,10 @@
/* Offset and size definition in flash area, used by assemble.py */
#define SECURE_IMAGE_OFFSET 0x0
-#define SECURE_IMAGE_MAX_SIZE 0x20000
+#define SECURE_IMAGE_MAX_SIZE 0x80000
-#define NON_SECURE_IMAGE_OFFSET 0x20000
-#define NON_SECURE_IMAGE_MAX_SIZE 0x20000
+#define NON_SECURE_IMAGE_OFFSET 0x80000
+#define NON_SECURE_IMAGE_MAX_SIZE 0x80000
#define S_QSPI_ALIAS_BASE (0x10200000)
#define NS_QSPI_ALIAS_BASE (0x00200000)
@@ -112,10 +110,10 @@
/* 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 + 0x10000 = 0x10010000
+ * = 0x10000000 + 0x20000 = 0x10020000
* Please make sure the value is in the form of hex. here
*/
-#define IMAGE_LOAD_ADDRESS 0x10010000
+#define IMAGE_LOAD_ADDRESS 0x10020000
/* Flash device name used by BL2 and SST
* Name is defined in flash driver file: Driver_Flash.c
diff --git a/platform/ext/target/musca_a/partition/region_defs.h b/platform/ext/target/musca_a/partition/region_defs.h
index 726c732..c44b3ee 100755
--- a/platform/ext/target/musca_a/partition/region_defs.h
+++ b/platform/ext/target/musca_a/partition/region_defs.h
@@ -45,14 +45,8 @@
* It is less than the FLASH_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)
-#else
-/* No header if no bootloader, but keep IMAGE_CODE_SIZE the same */
-#define BL2_HEADER_SIZE (0x0)
-#define BL2_TRAILER_SIZE (0x800)
-#endif /* BL2 */
#define IMAGE_CODE_SIZE \
(FLASH_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
@@ -132,7 +126,6 @@
#define NS_CODE_SRAM_EXEC_LIMIT (NS_CODE_SRAM_EXEC_BASE + \
(TOTAL_CODE_SRAM_SIZE / 2) - 1)
-#ifdef BL2
/* Bootloader regions */
#define BL2_CODE_START (S_QSPI_ALIAS_BASE)
#define BL2_CODE_SIZE (FLASH_AREA_BL2_SIZE)
@@ -141,7 +134,6 @@
#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__ */