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>
diff --git a/bl2/ext/mcuboot/scripts/macro_parser.py b/bl2/ext/mcuboot/scripts/macro_parser.py
index 5d9418a..12e8a92 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