Skip to content

Commit

Permalink
TFM: MUSCA: Import partition maps from upstream
Browse files Browse the repository at this point in the history
Import the latest partition headers from upstream. We no longer need to
patch the headers to define the BL2 macro as we now define it in the
scatter files for the MUSCA targets.
  • Loading branch information
rwalton-arm committed Sep 14, 2021
1 parent 33e57ee commit a43103f
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 81 deletions.
120 changes: 95 additions & 25 deletions targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/partition/flash_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#ifndef __FLASH_LAYOUT_H__
#define __FLASH_LAYOUT_H__

/* Flash layout on Musca-B1 with BL2 (multiple image boot, boot from eFlash 0):
#ifndef FORWARD_PROT_MSG
/* Flash layouts if FORWARD_PROT_MSG is OFF
*
*
* Flash layout on Musca-B1 with BL2 (multiple image boot, boot from eFlash 0):
*
* 0x0A00_0000 BL2 - MCUBoot (128 KB)
* 0x0A02_0000 Secure image primary slot (384 KB)
Expand Down Expand Up @@ -81,7 +85,6 @@
#define QSPI_FLASH_TOTAL_SIZE (0x800000) /* 8 MB */

/* Flash layout info for BL2 bootloader */
/* Same as MUSCA_B1_EFLASH0_S_BASE */
#define FLASH_BASE_ADDRESS (0x1A000000)

/* Offset and size definitions of the flash partitions that are handled by the
Expand Down Expand Up @@ -179,41 +182,39 @@
* Note: Further documentation of these definitions can be found in the
* TF-M PS Integration Guide.
*/
#define PS_FLASH_DEV_NAME Driver_QSPI_FLASH0
#define TFM_HAL_PS_FLASH_DRIVER Driver_QSPI_FLASH0

/* In this target the CMSIS driver requires only the offset from the base
* address instead of the full memory address.
*/
#define PS_FLASH_AREA_ADDR FLASH_PS_AREA_OFFSET
/* Dedicated flash area for PS */
#define PS_FLASH_AREA_SIZE FLASH_PS_AREA_SIZE
#define PS_RAM_FS_SIZE PS_FLASH_AREA_SIZE
#define PS_SECTOR_SIZE QSPI_FLASH_AREA_IMAGE_SECTOR_SIZE
/* Number of PS_SECTOR_SIZE per block */
#define PS_SECTORS_PER_BLOCK (0x1)
/* Specifies the smallest flash programmable unit in bytes */
#define PS_FLASH_PROGRAM_UNIT (0x1)
/* Base address of dedicated flash area for PS */
#define TFM_HAL_PS_FLASH_AREA_ADDR FLASH_PS_AREA_OFFSET
/* Size of dedicated flash area for PS */
#define TFM_HAL_PS_FLASH_AREA_SIZE FLASH_PS_AREA_SIZE
#define PS_RAM_FS_SIZE TFM_HAL_PS_FLASH_AREA_SIZE
/* Number of physical erase sectors per logical FS block */
#define TFM_HAL_PS_SECTORS_PER_BLOCK (1)
/* Smallest flash programmable unit in bytes */
#define TFM_HAL_PS_PROGRAM_UNIT (0x1)

/* Internal Trusted Storage (ITS) Service definitions
* Note: Further documentation of these definitions can be found in the
* TF-M ITS Integration Guide. The ITS should be in the internal flash, but is
* allocated in the external flash just for development platforms that don't
* have internal flash available.
* TF-M ITS Integration Guide.
*/
#define ITS_FLASH_DEV_NAME Driver_EFLASH0
#define TFM_HAL_ITS_FLASH_DRIVER Driver_EFLASH0

/* In this target the CMSIS driver requires only the offset from the base
* address instead of the full memory address.
*/
#define ITS_FLASH_AREA_ADDR FLASH_ITS_AREA_OFFSET
/* Dedicated flash area for ITS */
#define ITS_FLASH_AREA_SIZE FLASH_ITS_AREA_SIZE
#define ITS_RAM_FS_SIZE ITS_FLASH_AREA_SIZE
#define ITS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
/* Number of ITS_SECTOR_SIZE per block */
#define ITS_SECTORS_PER_BLOCK (0x1)
/* Specifies the smallest flash programmable unit in bytes */
#define ITS_FLASH_PROGRAM_UNIT (0x4)
/* Base address of dedicated flash area for ITS */
#define TFM_HAL_ITS_FLASH_AREA_ADDR FLASH_ITS_AREA_OFFSET
/* Size of dedicated flash area for ITS */
#define TFM_HAL_ITS_FLASH_AREA_SIZE FLASH_ITS_AREA_SIZE
#define ITS_RAM_FS_SIZE TFM_HAL_ITS_FLASH_AREA_SIZE
/* Number of physical erase sectors per logical FS block */
#define TFM_HAL_ITS_SECTORS_PER_BLOCK (1)
/* Smallest flash programmable unit in bytes */
#define TFM_HAL_ITS_PROGRAM_UNIT (0x4)

/* NV Counters definitions */
#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
Expand All @@ -232,4 +233,73 @@
#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
#define TOTAL_RAM_SIZE (0x80000) /* 512 KB */

#else /* FORWARD_PROT_MSG */

/* Flash layout information if FORWARD_PROT_MSG is ON.
* For information you can check Musca-B1 Secure Enclave's flash_layout.h
*/

#define FLASH_S_PARTITION_SIZE (0x30000) /* S partition: 192 KB */
#define FLASH_NS_PARTITION_SIZE (0x50000) /* NS partition: 320 KB */

/* 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 (SECURE_IMAGE_OFFSET + \
SECURE_IMAGE_MAX_SIZE)
#define NON_SECURE_IMAGE_MAX_SIZE FLASH_NS_PARTITION_SIZE

/* Image placed in eFlash 1 */
#define FLASH_BASE_ADDRESS (0x1A200000)

#if (MCUBOOT_IMAGE_NUMBER != 1)
#error "If FORWARD_PROT_MSG is ON MCUBOOT_IMAGE_NUMBER must be 1"
#endif

/* Secure + Non-secure image primary slot */
#define FLASH_AREA_0_ID (1)
#define FLASH_AREA_0_OFFSET (0x60000) /* Address comes from SE */
#define FLASH_AREA_0_SIZE (FLASH_S_PARTITION_SIZE + \
FLASH_NS_PARTITION_SIZE)
/* Secure + Non-secure secondary slot */
#define FLASH_AREA_2_ID (FLASH_AREA_0_ID + 1)
#define FLASH_AREA_2_OFFSET (0x160000) /* Address comes from SE */
#define FLASH_AREA_2_SIZE (FLASH_S_PARTITION_SIZE + \
FLASH_NS_PARTITION_SIZE)

/* Image placed in eFlash 1 */
#define S_ROM_ALIAS_BASE (0x1A200000)
#define NS_ROM_ALIAS_BASE (0x0A200000)

#define S_RAM_ALIAS_BASE (0x30000000)
#define NS_RAM_ALIAS_BASE (0x20000000)

#define TOTAL_RAM_SIZE (0x80000) /* 512 KB */

/* Macros needed for BL2 build with dummy values.
* This BL2 instance is not used, but the BL2 macro needs to be set, and this
* macro and BL2 build is entangled. If this is fixed the following macros can
* be deleted.
*/
#define FLASH_AREA_IMAGE_SECTOR_SIZE 0

#define MCUBOOT_STATUS_MAX_ENTRIES 0
#define MCUBOOT_MAX_IMG_SECTORS 32

#define FLASH_AREA_SCRATCH_ID 0
#define FLASH_AREA_SCRATCH_OFFSET 0
#define FLASH_AREA_SCRATCH_SIZE 0

#define FLASH_DEV_NAME Driver_EFLASH0
#define FLASH_AREA_BL2_OFFSET 0
#define FLASH_AREA_BL2_SIZE 0x20000

#define TFM_NV_COUNTERS_AREA_ADDR 0
#define TFM_NV_COUNTERS_AREA_SIZE 8
#define TFM_NV_COUNTERS_SECTOR_ADDR 0
#define TFM_NV_COUNTERS_SECTOR_SIZE 8

#endif /* FORWARD_PROT_MSG */

#endif /* __FLASH_LAYOUT_H__ */
28 changes: 21 additions & 7 deletions targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/partition/region_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

#include "flash_layout.h"

#ifndef BL2
#define BL2
#endif

#define BL2_HEAP_SIZE (0x0001000)
#define BL2_MSP_STACK_SIZE (0x0001800)

Expand Down Expand Up @@ -89,7 +85,7 @@
#define IMAGE_NS_CODE_SIZE \
(FLASH_NS_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)

#define CMSE_VENEER_REGION_SIZE (0x340)
#define CMSE_VENEER_REGION_SIZE (0x380)

/* Alias definitions for secure and non-secure areas*/
#define S_ROM_ALIAS(x) (S_ROM_ALIAS_BASE + (x))
Expand All @@ -112,6 +108,12 @@
/* CMSE Veneers region */
#define CMSE_VENEER_REGION_START (S_CODE_LIMIT + 1)

/* Shared memory used by PSA Proxy partition */
#ifdef TFM_PARTITION_PSA_PROXY
#define PSA_PROXY_SHARED_MEMORY_BASE (0x1A408000)
#define PSA_PROXY_SHARED_MEMORY_SIZE (0x00078000) /* 476 KiB */
#endif /* TFM_PARTITION_PSA_PROXY */

/* Non-secure regions */
#define NS_IMAGE_PRIMARY_AREA_OFFSET \
(NS_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
Expand Down Expand Up @@ -157,11 +159,23 @@
#define BL2_DATA_LIMIT (BL2_DATA_START + BL2_DATA_SIZE - 1)
#endif /* BL2 */

/* Shared symbol area between bootloader and runtime firmware. Global variables
* in the shared code can be placed here.
*/
#ifdef CODE_SHARING
#define SHARED_SYMBOL_AREA_BASE S_RAM_ALIAS_BASE
#define SHARED_SYMBOL_AREA_SIZE 0x20
#else
#define SHARED_SYMBOL_AREA_BASE S_RAM_ALIAS_BASE
#define SHARED_SYMBOL_AREA_SIZE 0x0
#endif /* CODE_SHARING */

/* Shared data area between bootloader and runtime firmware.
* Shared data area is allocated at the beginning of the RAM, it is overlapping
* These areas are 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_BASE (SHARED_SYMBOL_AREA_BASE + \
SHARED_SYMBOL_AREA_SIZE)
#define BOOT_TFM_SHARED_DATA_SIZE (0x400)
#define BOOT_TFM_SHARED_DATA_LIMIT (BOOT_TFM_SHARED_DATA_BASE + \
BOOT_TFM_SHARED_DATA_SIZE - 1)
Expand Down
82 changes: 37 additions & 45 deletions targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/partition/flash_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
* 0x0A10_0000 Secure image secondary (384 KB)
* 0x0A16_0000 Non-secure image secondary (512 KB)
* 0x0A1E_0000 Scratch Area (16 KB)
* 0x0A1E_4000 Protected Storage Area (20 KB)
* 0x0A1E_9000 Internal Trusted Storage Area (16 KB)
* 0x0A1E_D000 NV counters area (4 KB)
* 0x0A1E_E000 TF-M key area (256 bytes) This area is referred to in
* /lib/ext/cryptocell-312-runtime/shared/hw/include/musca_s1/ \
* 0x0A1E_4000 Internal Trusted Storage Area (16 KB)
* 0x0A1E_8000 NV counters area (4 KB)
* 0x0A1E_9000 TF-M key area (256 bytes) This area is referred to in
* /lib/ext/cryptocell-312-runtime/shared/hw/include/arm/musca_s1/ \
* dx_reg_base_host.h Do not change one without changing the other.
* 0x0A1E_E100 Unused
* 0x0A1E_9100 Unused
* 0x0020_0000 Protected storage area (20 KB) This area is placed in the QSPI
* flash
*
* Flash layout on Musca-S1 with BL2(single image boot):
* 0x0A00_0000 BL2 - MCUBoot(128 KB)
Expand All @@ -44,13 +45,14 @@
* 0x0A10_0000 Secure image secondary (384 KB)
* 0x0A16_0000 Non-secure image secondary (512 KB)
* 0x0A1E_0000 Scratch Area (16 KB)
* 0x0A1E_4000 Protected Storage Area (20 KB)
* 0x0A1E_9000 Internal Trusted Storage Area (16 KB)
* 0x0A1E_D000 NV counters area (4 KB)
* 0x0A1E_E000 TF-M key area (256 bytes) This area is referred to in
* /lib/ext/cryptocell-312-runtime/shared/hw/include/musca_s1/ \
* 0x0A1E_4000 Internal Trusted Storage Area (16 KB)
* 0x0A1E_8000 NV counters area (4 KB)
* 0x0A1E_9000 TF-M key area (256 bytes) This area is referred to in
* /lib/ext/cryptocell-312-runtime/shared/hw/include/arm/musca_s1/ \
* dx_reg_base_host.h Do not change one without changing the other.
* 0x0A1E_E100 Unused
* 0x0A1E_9100 Unused
* 0x0020_0000 Protected storage area (20 KB) This area is placed in the QSPI
* flash
*
* Flash layout on Musca-S1 without BL2:
* 0x0A00_0000 Secure image
Expand Down Expand Up @@ -142,17 +144,9 @@
#error "Only MCUBOOT_IMAGE_NUMBER 1 and 2 are supported!"
#endif /* MCUBOOT_IMAGE_NUMBER */

/* Note: FLASH_PS_AREA_OFFSET, FLASH_ITS_AREA_OFFSET and
* FLASH_NV_COUNTERS_AREA_OFFSET point to offsets in flash, but reads and writes
* to these addresses are redirected to Code SRAM by Driver_Flash.c.
*/
#define FLASH_PS_AREA_OFFSET (FLASH_AREA_SCRATCH_OFFSET + \
FLASH_AREA_SCRATCH_SIZE)
#define FLASH_PS_AREA_SIZE (0x5000) /* 20 KB */

/* Internal Trusted Storage (ITS) Service definitions */
#define FLASH_ITS_AREA_OFFSET (FLASH_PS_AREA_OFFSET + \
FLASH_PS_AREA_SIZE)
#define FLASH_ITS_AREA_OFFSET (FLASH_AREA_SCRATCH_OFFSET + \
FLASH_AREA_SCRATCH_SIZE)
#define FLASH_ITS_AREA_SIZE (0x4000) /* 16 KB */

/* NV Counters definitions */
Expand Down Expand Up @@ -182,41 +176,39 @@
* Note: Further documentation of these definitions can be found in the
* TF-M PS Integration Guide.
*/
#define PS_FLASH_DEV_NAME Driver_FLASH0
#define TFM_HAL_PS_FLASH_DRIVER Driver_QSPI_FLASH0

/* In this target the CMSIS driver requires only the offset from the base
* address instead of the full memory address.
*/
#define PS_FLASH_AREA_ADDR FLASH_PS_AREA_OFFSET
/* Dedicated flash area for PS */
#define PS_FLASH_AREA_SIZE FLASH_PS_AREA_SIZE
#define PS_RAM_FS_SIZE PS_FLASH_AREA_SIZE
#define PS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
/* Number of PS_SECTOR_SIZE per block */
#define PS_SECTORS_PER_BLOCK (0x1)
/* Specifies the smallest flash programmable unit in bytes */
#define PS_FLASH_PROGRAM_UNIT (0x1)
/* Base address of dedicated flash area for PS */
#define TFM_HAL_PS_FLASH_AREA_ADDR 0x0
/* Size of dedicated flash area for PS */
#define TFM_HAL_PS_FLASH_AREA_SIZE (0x5000) /* 20 KB */
#define PS_RAM_FS_SIZE TFM_HAL_PS_FLASH_AREA_SIZE
/* Number of physical erase sectors per logical FS block */
#define TFM_HAL_PS_SECTORS_PER_BLOCK (1)
/* Smallest flash programmable unit in bytes */
#define TFM_HAL_PS_PROGRAM_UNIT (0x1)

/* Internal Trusted Storage (ITS) Service definitions
* Note: Further documentation of these definitions can be found in the
* TF-M ITS Integration Guide. The ITS should be in the internal flash, but is
* allocated in the external flash just for development platforms that don't
* have internal flash available.
* TF-M ITS Integration Guide.
*/
#define ITS_FLASH_DEV_NAME Driver_FLASH0
#define TFM_HAL_ITS_FLASH_DRIVER Driver_FLASH0

/* In this target the CMSIS driver requires only the offset from the base
* address instead of the full memory address.
*/
#define ITS_FLASH_AREA_ADDR FLASH_ITS_AREA_OFFSET
/* Dedicated flash area for ITS */
#define ITS_FLASH_AREA_SIZE FLASH_ITS_AREA_SIZE
#define ITS_RAM_FS_SIZE ITS_FLASH_AREA_SIZE
#define ITS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
/* Number of ITS_SECTOR_SIZE per block */
#define ITS_SECTORS_PER_BLOCK (0x1)
/* Specifies the smallest flash programmable unit in bytes */
#define ITS_FLASH_PROGRAM_UNIT (0x1)
/* Base address of dedicated flash area for ITS */
#define TFM_HAL_ITS_FLASH_AREA_ADDR FLASH_ITS_AREA_OFFSET
/* Size of dedicated flash area for ITS */
#define TFM_HAL_ITS_FLASH_AREA_SIZE FLASH_ITS_AREA_SIZE
#define ITS_RAM_FS_SIZE TFM_HAL_ITS_FLASH_AREA_SIZE
/* Number of physical erase sectors per logical FS block */
#define TFM_HAL_ITS_SECTORS_PER_BLOCK (1)
/* Smallest flash programmable unit in bytes */
#define TFM_HAL_ITS_PROGRAM_UNIT (0x1)

/* NV Counters definitions */
#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
#ifndef __REGION_DEFS_H__
#define __REGION_DEFS_H__

#ifndef BL2
#define BL2
#endif

#include "flash_layout.h"

#define BL2_HEAP_SIZE (0x0001000)
Expand Down

0 comments on commit a43103f

Please sign in to comment.