aboutsummaryrefslogtreecommitdiff
path: root/bl2
diff options
context:
space:
mode:
authorSherry Zhang <sherry.zhang2@arm.com>2021-05-13 14:49:48 +0800
committerDavid Hu <david.hu@arm.com>2021-06-04 08:31:01 +0200
commitae25f05966effa9f706a9b330fc4ebaaad9895ad (patch)
treef767211c5681f2b8f3906cd1d84dbada45a873e9 /bl2
parent6364f613a6ad09bb4e71672f569055a9ec4b0b57 (diff)
downloadtrusted-firmware-m-ae25f05966effa9f706a9b330fc4ebaaad9895ad.tar.gz
Boot: Add checking build address in DIRECT_XIP strategy
In DIRECT_XIP MCUboot upgrade strategy, MCUboot checks the image running address if the IMAGE_F_ROM_FIXED flag is set in image header. This commit sets this flag and the target running address in the image header in DIRECT_XIP strategy. Change-Id: I8168e176e8fe47847abca1278bf05de1c1ff6d64 Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Diffstat (limited to 'bl2')
-rw-r--r--bl2/ext/mcuboot/CMakeLists.txt4
-rw-r--r--bl2/ext/mcuboot/scripts/macro_parser.py5
-rwxr-xr-xbl2/ext/mcuboot/scripts/wrapper/wrapper.py8
-rw-r--r--bl2/ext/mcuboot/signing_layout.c.in7
4 files changed, 17 insertions, 7 deletions
diff --git a/bl2/ext/mcuboot/CMakeLists.txt b/bl2/ext/mcuboot/CMakeLists.txt
index 3cb8749b2..454851569 100644
--- a/bl2/ext/mcuboot/CMakeLists.txt
+++ b/bl2/ext/mcuboot/CMakeLists.txt
@@ -62,6 +62,7 @@ configure_file(include/mcuboot_config/mcuboot_config.h.in
find_package(Python3)
set(FLASH_AREA_NUM 0)
+set(IMAGE_TYPE "S_IMAGE")
if (MCUBOOT_IMAGE_NUMBER GREATER 1)
configure_file(signing_layout.c.in signing_layout_s.c @ONLY)
add_library(signing_layout_s OBJECT ${CMAKE_CURRENT_BINARY_DIR}/signing_layout_s.c)
@@ -82,6 +83,7 @@ target_compile_definitions(signing_layout_s
PRIVATE
$<$<BOOL:${BL2}>:BL2>
$<$<BOOL:${MCUBOOT_IMAGE_NUMBER}>:MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}>
+ $<$<STREQUAL:${MCUBOOT_UPGRADE_STRATEGY},DIRECT_XIP>:IMAGE_ROM_FIXED>
)
target_link_libraries(signing_layout_s
PRIVATE
@@ -135,6 +137,7 @@ add_custom_command(OUTPUT tfm_s_signed.bin
)
set(FLASH_AREA_NUM 1)
+set(IMAGE_TYPE "NS_IMAGE")
configure_file(signing_layout.c.in signing_layout_ns.c @ONLY)
add_library(signing_layout_ns OBJECT ${CMAKE_CURRENT_BINARY_DIR}/signing_layout_ns.c)
@@ -148,6 +151,7 @@ target_compile_definitions(signing_layout_ns
PRIVATE
$<$<BOOL:${BL2}>:BL2>
$<$<BOOL:${MCUBOOT_IMAGE_NUMBER}>:MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}>
+ $<$<STREQUAL:${MCUBOOT_UPGRADE_STRATEGY},DIRECT_XIP>:IMAGE_ROM_FIXED>
)
target_link_libraries(signing_layout_ns
PRIVATE
diff --git a/bl2/ext/mcuboot/scripts/macro_parser.py b/bl2/ext/mcuboot/scripts/macro_parser.py
index 5d9418a4e..12e8a92f1 100644
--- a/bl2/ext/mcuboot/scripts/macro_parser.py
+++ b/bl2/ext/mcuboot/scripts/macro_parser.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python3
#
# -----------------------------------------------------------------------------
-# Copyright (c) 2019, Arm Limited. All rights reserved.
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -11,7 +11,8 @@
import re
import os
-expression_re = re.compile(r"[(]?(([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*([\+\-]\s*([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*)*)[)]?")
+# Match (((x) + (y))) mode and ((x) + (y)) mode. x, y can be HEX or DEC value.
+expression_re = re.compile(r"([(]?[(]?[(]?(([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*([\+\-]\s*([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*)*)[)]?\s*([\+\-])\s*[(]?(([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*([\+\-]\s*([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*)*)[)]?[)]?[)]?)|([(]?[(]?[(]?(([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*([\+\-]\s*([(]?(((0x)[0-9a-fA-F]+)|([0-9]+))[)]?)\s*)*)[)]?[)]?[)]?)")
# Simple parser that takes a string and evaluates an expression from it.
# The expression might contain additions and subtractions amongst numbers that
diff --git a/bl2/ext/mcuboot/scripts/wrapper/wrapper.py b/bl2/ext/mcuboot/scripts/wrapper/wrapper.py
index 7799ce06d..247cb1042 100755
--- a/bl2/ext/mcuboot/scripts/wrapper/wrapper.py
+++ b/bl2/ext/mcuboot/scripts/wrapper/wrapper.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python3
#
# -----------------------------------------------------------------------------
-# Copyright (c) 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -26,6 +26,7 @@ import macro_parser
sign_bin_size_re = re.compile(r"^\s*RE_SIGN_BIN_SIZE\s*=\s*(.*)")
load_addr_re = re.compile(r"^\s*RE_IMAGE_LOAD_ADDRESS\s*=\s*(.*)")
+rom_fixed_re = re.compile(r"^\s*RE_IMAGE_ROM_FIXED\s*=\s*(.*)")
#This works around Python 2 and Python 3 handling character encodings
#differently. More information about this issue at
@@ -91,7 +92,7 @@ def wrap(key, align, version, header_size, pad_header, layout, pad, confirm,
slot_size = macro_parser.evaluate_macro(layout, sign_bin_size_re, 0, 1)
load_addr = macro_parser.evaluate_macro(layout, load_addr_re, 0, 1)
-
+ rom_fixed = macro_parser.evaluate_macro(layout, rom_fixed_re, 0, 1)
if "_s" in layout:
boot_record = "SPE"
elif "_ns" in layout:
@@ -104,7 +105,8 @@ def wrap(key, align, version, header_size, pad_header, layout, pad, confirm,
pad=pad, confirm=confirm, align=int(align),
slot_size=slot_size, max_sectors=max_sectors,
overwrite_only=overwrite_only, endian=endian,
- load_addr=load_addr, erased_val=erased_val,
+ load_addr=load_addr, rom_fixed=rom_fixed,
+ erased_val=erased_val,
save_enctlv=save_enctlv,
security_counter=security_counter)
diff --git a/bl2/ext/mcuboot/signing_layout.c.in b/bl2/ext/mcuboot/signing_layout.c.in
index f0d490c69..e9f69b1d0 100644
--- a/bl2/ext/mcuboot/signing_layout.c.in
+++ b/bl2/ext/mcuboot/signing_layout.c.in
@@ -1,10 +1,10 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-#include "flash_layout.h"
+#include "region_defs.h"
/* Enumeration that is used by the assemble.py and imgtool.py scripts
* for correct binary generation when nested macros are used
*/
@@ -17,4 +17,7 @@ enum image_attributes {
RE_IMAGE_LOAD_ADDRESS = IMAGE_LOAD_ADDRESS,
#endif
RE_SIGN_BIN_SIZE = FLASH_AREA_@FLASH_AREA_NUM@_SIZE,
+#ifdef IMAGE_ROM_FIXED
+ RE_IMAGE_ROM_FIXED = @IMAGE_TYPE@_PRIMARY_PARTITION_OFFSET
+#endif
};