mirror of https://github.com/ARMmbed/mbed-os.git
M2354: Use TF-M exported region_defs.h to replace target.mbed_rom_start and friends
parent
7db441401b
commit
9fee7d9b18
|
@ -13,3 +13,15 @@ mbed_post_build_nuvoton_tfm_sign_image_tgt(
|
|||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
nuvoton_m2354-root-rsa-3072.pem
|
||||
)
|
||||
|
||||
set(bl2 true)
|
||||
set(mcuboot_image_number 1)
|
||||
set(region_defs_h_path "${CMAKE_CURRENT_SOURCE_DIR}/partition/region_defs.h")
|
||||
|
||||
target_compile_definitions(mbed-m2354-tfm
|
||||
INTERFACE
|
||||
NU_TFM_S_BL2=$<IF:$<BOOL:${bl2}>,1,0>
|
||||
NU_TFM_S_MCUBOOT_IMAGE_NUMBER=${mcuboot_image_number}
|
||||
# TODO: Fix escape sequence in NU_TFM_S_REGION_DEFS_H_PATH
|
||||
#NU_TFM_S_REGION_DEFS_H_PATH=\"${region_defs_h_path}\"
|
||||
)
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* @copyright SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright (c) 2017-2020 Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2020 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __REGION_DEFS_H__
|
||||
#define __REGION_DEFS_H__
|
||||
|
||||
#include "flash_layout.h"
|
||||
|
||||
#define BL2_HEAP_SIZE (0x0001000)
|
||||
#define BL2_MSP_STACK_SIZE (0x0001800)
|
||||
|
||||
#define S_HEAP_SIZE (0x0001000)
|
||||
#define S_MSP_STACK_SIZE_INIT (0x0000400)
|
||||
#define S_MSP_STACK_SIZE (0x0000800)
|
||||
#define S_PSP_STACK_SIZE (0x0000800)
|
||||
|
||||
#define NS_HEAP_SIZE (0x0001000)
|
||||
#define NS_MSP_STACK_SIZE (0x0000800)
|
||||
#define NS_PSP_STACK_SIZE (0x0000800)
|
||||
|
||||
/* This size of buffer is big enough to store an attestation
|
||||
* token produced by initial attestation service
|
||||
*/
|
||||
#define PSA_INITIAL_ATTEST_TOKEN_MAX_SIZE (0x250)
|
||||
|
||||
/* MPC granularity is 128 KB on AN519 MPS2 FPGA image. Alignment
|
||||
* of partitions is defined in accordance with this constraint.
|
||||
*/
|
||||
|
||||
#ifdef BL2
|
||||
#ifndef LINK_TO_SECONDARY_PARTITION
|
||||
#define S_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_0_OFFSET)
|
||||
#define S_IMAGE_SECONDARY_PARTITION_OFFSET (FLASH_AREA_0_OFFSET)
|
||||
#else
|
||||
#error "No secondary partition supported!"
|
||||
#endif /* !LINK_TO_SECONDARY_PARTITION */
|
||||
#else
|
||||
#define S_IMAGE_PRIMARY_PARTITION_OFFSET (0x0)
|
||||
#endif /* BL2 */
|
||||
|
||||
#ifndef LINK_TO_SECONDARY_PARTITION
|
||||
#define NS_IMAGE_PRIMARY_PARTITION_OFFSET (FLASH_AREA_0_OFFSET + FLASH_S_PARTITION_SIZE)
|
||||
#else
|
||||
#error "No secondary partition supported!"
|
||||
#endif /* !LINK_TO_SECONDARY_PARTITION */
|
||||
|
||||
/* Boot partition structure if MCUBoot is used:
|
||||
* 0x0_0000 Bootloader header
|
||||
* 0x0_0400 Image area
|
||||
* 0x7_0000 Trailer
|
||||
*/
|
||||
/* IMAGE_CODE_SIZE is the space available for the software binary image.
|
||||
* It is less than the FLASH_S_PARTITION_SIZE + FLASH_NS_PARTITION_SIZE
|
||||
* because we reserve space for the image header and trailer introduced
|
||||
* by the bootloader.
|
||||
*/
|
||||
#ifdef BL2
|
||||
#define BL2_HEADER_SIZE (0x400) /* 1 KB */
|
||||
#define BL2_TRAILER_SIZE (0x800) /* 2 KB */
|
||||
#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_S_CODE_SIZE (FLASH_S_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
|
||||
#define IMAGE_NS_CODE_SIZE (FLASH_NS_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
|
||||
|
||||
#define CMSE_VENEER_REGION_SIZE (0x340)
|
||||
|
||||
/* Alias definitions for secure and non-secure areas*/
|
||||
#define S_ROM_ALIAS(x) (S_ROM_ALIAS_BASE + (x))
|
||||
#define NS_ROM_ALIAS(x) (NS_ROM_ALIAS_BASE + (x))
|
||||
|
||||
#define S_RAM_ALIAS(x) (S_RAM_ALIAS_BASE + (x))
|
||||
#define NS_RAM_ALIAS(x) (NS_RAM_ALIAS_BASE + (x))
|
||||
|
||||
/* Secure regions */
|
||||
#define S_IMAGE_PRIMARY_AREA_OFFSET \
|
||||
(S_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE) /* 0x8400 */
|
||||
#define S_CODE_START (S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET)) /* 0x8400 */
|
||||
#define S_CODE_SIZE (IMAGE_S_CODE_SIZE - CMSE_VENEER_REGION_SIZE)
|
||||
#define S_CODE_LIMIT (S_CODE_START + S_CODE_SIZE - 1)
|
||||
|
||||
#define S_DATA_START (S_RAM_ALIAS(0x0))
|
||||
#define S_DATA_SIZE (80 * 1024)
|
||||
#define S_DATA_LIMIT (S_DATA_START + S_DATA_SIZE - 1)
|
||||
|
||||
/* CMSE Veneers region */
|
||||
#define CMSE_VENEER_REGION_START (S_CODE_LIMIT + 1)
|
||||
|
||||
/* Non-secure regions */
|
||||
#define NS_IMAGE_PRIMARY_AREA_OFFSET \
|
||||
(NS_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
|
||||
#define NS_CODE_START (NS_ROM_ALIAS(NS_IMAGE_PRIMARY_AREA_OFFSET))
|
||||
#define NS_CODE_SIZE (IMAGE_NS_CODE_SIZE)
|
||||
#define NS_CODE_LIMIT (NS_CODE_START + NS_CODE_SIZE - 1)
|
||||
|
||||
#define NS_DATA_START (NS_RAM_ALIAS(S_DATA_SIZE))
|
||||
#define NS_DATA_SIZE (TOTAL_RAM_SIZE - S_DATA_SIZE)
|
||||
#define NS_DATA_LIMIT (NS_DATA_START + NS_DATA_SIZE - 1)
|
||||
|
||||
/* NS partition information is used for MPC and SAU configuration */
|
||||
#define NS_PARTITION_START \
|
||||
(NS_ROM_ALIAS(NS_IMAGE_PRIMARY_PARTITION_OFFSET))
|
||||
#define NS_PARTITION_SIZE (FLASH_NS_PARTITION_SIZE)
|
||||
|
||||
/* Secondary partition for new images in case of firmware upgrade */
|
||||
#define SECONDARY_PARTITION_START \
|
||||
(NS_ROM_ALIAS(S_IMAGE_SECONDARY_PARTITION_OFFSET))
|
||||
#define SECONDARY_PARTITION_SIZE (FLASH_S_PARTITION_SIZE + \
|
||||
FLASH_NS_PARTITION_SIZE)
|
||||
|
||||
#ifdef BL2
|
||||
/* Bootloader regions */
|
||||
#define BL2_CODE_START (S_ROM_ALIAS(FLASH_AREA_BL2_OFFSET))
|
||||
#define BL2_CODE_SIZE (FLASH_AREA_BL2_SIZE)
|
||||
#define BL2_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1)
|
||||
|
||||
#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 */
|
||||
|
||||
/* Shared data area between bootloader and runtime firmware.
|
||||
* Shared data area is 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_SIZE (0x400)
|
||||
#define BOOT_TFM_SHARED_DATA_LIMIT (BOOT_TFM_SHARED_DATA_BASE + BOOT_TFM_SHARED_DATA_SIZE - 1)
|
||||
|
||||
#endif /* __REGION_DEFS_H__ */
|
|
@ -33,25 +33,55 @@
|
|||
* (already there or via copy).
|
||||
*/
|
||||
|
||||
/* Resolve non-secure ROM start */
|
||||
#ifndef MBED_ROM_START
|
||||
#error("MBED_ROM_START must be present!!!")
|
||||
/* Update NU_TFM_S_BL2 and friends on redoing TF-M import
|
||||
*
|
||||
* We expect NU_TFM_S_BL2 and friends are passed along from build tool, esp. Mbed CLI2,
|
||||
* If not, NU_TFM_S_BL2 and friends must update manually. */
|
||||
|
||||
#ifndef NU_TFM_S_BL2
|
||||
#define NU_TFM_S_BL2 1
|
||||
#endif
|
||||
|
||||
#ifndef NU_TFM_S_MCUBOOT_IMAGE_NUMBER
|
||||
#define NU_TFM_S_MCUBOOT_IMAGE_NUMBER 1
|
||||
#endif
|
||||
|
||||
#ifndef NU_TFM_S_REGION_DEFS_H_PATH
|
||||
#define NU_TFM_S_REGION_DEFS_H_PATH "../TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/region_defs.h"
|
||||
#endif
|
||||
|
||||
/* TF-M exported region_defs.h depends on BL2 and MCUBOOT_IMAGE_NUMBER, so the
|
||||
* following order is significant. */
|
||||
#if NU_TFM_S_BL2
|
||||
#define BL2
|
||||
#endif
|
||||
#define MCUBOOT_IMAGE_NUMBER NU_TFM_S_MCUBOOT_IMAGE_NUMBER
|
||||
#include NU_TFM_S_REGION_DEFS_H_PATH
|
||||
|
||||
/* Avoid polluting name space, esp. BL2 */
|
||||
#undef BL2
|
||||
#undef MCUBOOT_IMAGE_NUMBER
|
||||
|
||||
/* Resolve MBED_ROM_START and friends
|
||||
*
|
||||
* TF-M exported region_defs.h essentially resolves MBED_ROM_START and friends.
|
||||
* target.mbed_rom_start and friends get unnecessary.
|
||||
*/
|
||||
/* Resolve non-secure ROM start */
|
||||
#undef MBED_ROM_START
|
||||
#define MBED_ROM_START NS_CODE_START
|
||||
|
||||
/* Resolve non-secure ROM size */
|
||||
#ifndef MBED_ROM_SIZE
|
||||
#error("MBED_ROM_SIZE must be present!!!")
|
||||
#endif
|
||||
#undef MBED_ROM_SIZE
|
||||
#define MBED_ROM_SIZE NS_CODE_SIZE
|
||||
|
||||
/* Resolve non-secure RAM start */
|
||||
#ifndef MBED_RAM_START
|
||||
#error("MBED_RAM_START must be present!!!")
|
||||
#endif
|
||||
#undef MBED_RAM_START
|
||||
#define MBED_RAM_START NS_DATA_START
|
||||
|
||||
/* Resolve non-secure RAM size */
|
||||
#ifndef MBED_RAM_SIZE
|
||||
#error("MBED_RAM_SIZE must be present!!!")
|
||||
#endif
|
||||
#undef MBED_RAM_SIZE
|
||||
#define MBED_RAM_SIZE NS_DATA_SIZE
|
||||
|
||||
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
|
||||
* MBED_APP_xxx macros to linker files even though they mean the same thing.
|
||||
|
|
|
@ -18,25 +18,28 @@
|
|||
|
||||
/* See partition_M2354_mem.h for documentation */
|
||||
|
||||
/* Update MBED_ROM_START and friends on redoing TF-M import (for IAR)
|
||||
*
|
||||
* IAR doesn't support CPP, so we cannot resolve MBED_ROM_START and friends by
|
||||
* TF-M exported region_defs.h.
|
||||
*
|
||||
* Without target.mbed_rom_start and friends (replaced with TF-M exported region_defs.h),
|
||||
* MBED_ROM_START and friends passed along are incorrect. Because IAR doesn't allow symbol
|
||||
* redefinition, we change to MBED_ROM_START_ORIDE and friends instead for a temporary
|
||||
* solution.
|
||||
*/
|
||||
|
||||
/* Resolve non-secure ROM start */
|
||||
if (! isdefinedsymbol(MBED_ROM_START)) {
|
||||
error "MBED_ROM_START must be present!!!";
|
||||
}
|
||||
define symbol MBED_ROM_START_ORIDE = 0x10070400;
|
||||
|
||||
/* Resolve non-secure ROM size */
|
||||
if (! isdefinedsymbol(MBED_ROM_SIZE)) {
|
||||
error "MBED_ROM_SIZE must be present!!!";
|
||||
}
|
||||
define symbol MBED_ROM_SIZE_ORIDE = 0x8F400;
|
||||
|
||||
/* Resolve non-secure RAM start */
|
||||
if (! isdefinedsymbol(MBED_RAM_START)) {
|
||||
error "MBED_RAM_START must be present!!!";
|
||||
}
|
||||
define symbol MBED_RAM_START_ORIDE = 0x30014000;
|
||||
|
||||
/* Resolve non-secure RAM size */
|
||||
if (! isdefinedsymbol(MBED_RAM_SIZE)) {
|
||||
error "MBED_RAM_SIZE must be present!!!";
|
||||
}
|
||||
define symbol MBED_RAM_SIZE_ORIDE = 0x2C000;
|
||||
|
||||
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
|
||||
* MBED_APP_xxx macros to linker files even though they mean the same thing.
|
||||
|
@ -48,7 +51,7 @@ if (!isdefinedsymbol(APPLICATION_ADDR)) {
|
|||
if (isdefinedsymbol(MBED_APP_START)) {
|
||||
define symbol APPLICATION_ADDR = MBED_APP_START;
|
||||
} else {
|
||||
define symbol APPLICATION_ADDR = MBED_ROM_START;
|
||||
define symbol APPLICATION_ADDR = MBED_ROM_START_ORIDE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +59,7 @@ if (!isdefinedsymbol(APPLICATION_SIZE)) {
|
|||
if (isdefinedsymbol(MBED_APP_SIZE)) {
|
||||
define symbol APPLICATION_SIZE = MBED_APP_SIZE;
|
||||
} else {
|
||||
define symbol APPLICATION_SIZE = MBED_ROM_SIZE;
|
||||
define symbol APPLICATION_SIZE = MBED_ROM_SIZE_ORIDE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +67,7 @@ if (!isdefinedsymbol(APPLICATION_RAM_ADDR)) {
|
|||
if (isdefinedsymbol(MBED_RAM_APP_START)) {
|
||||
define symbol APPLICATION_RAM_ADDR = MBED_RAM_APP_START;
|
||||
} else {
|
||||
define symbol APPLICATION_RAM_ADDR = MBED_RAM_START;
|
||||
define symbol APPLICATION_RAM_ADDR = MBED_RAM_START_ORIDE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +75,7 @@ if (!isdefinedsymbol(APPLICATION_RAM_SIZE)) {
|
|||
if (isdefinedsymbol(MBED_RAM_APP_SIZE)) {
|
||||
define symbol APPLICATION_RAM_SIZE = MBED_RAM_APP_SIZE;
|
||||
} else {
|
||||
define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE;
|
||||
define symbol APPLICATION_RAM_SIZE = MBED_RAM_SIZE_ORIDE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6968,11 +6968,7 @@
|
|||
"ARMCLANG",
|
||||
"GNUARM"
|
||||
],
|
||||
"tfm_delivery_dir": "TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW",
|
||||
"mbed_rom_start": "0x10070400",
|
||||
"mbed_rom_size": "0x8F400",
|
||||
"mbed_ram_start": "0x30014000",
|
||||
"mbed_ram_size": "0x2C000"
|
||||
"tfm_delivery_dir": "TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW"
|
||||
},
|
||||
"MCU_M251": {
|
||||
"core": "Cortex-M23",
|
||||
|
|
Loading…
Reference in New Issue