aboutsummaryrefslogtreecommitdiff
path: root/platform/ext
diff options
context:
space:
mode:
authorMartinaHanusovaNXP <martina.hanusova@nxp.com>2021-07-01 14:50:14 +0200
committerDavid Hu <david.hu@arm.com>2021-07-05 04:47:08 +0200
commitc79cdf8ffc7918a8ec95957aa70b5cddbb5a7055 (patch)
treee6b699a9227aa076b733ab4cc336c5b7843407c9 /platform/ext
parent442bc9361462cd8472aadff1f4c74621ef134af9 (diff)
downloadtrusted-firmware-m-c79cdf8ffc7918a8ec95957aa70b5cddbb5a7055.tar.gz
Platform: LPCXpresso55s69: Added flash layout parser into flash scripts
Added flash layout parser into scripts with BL2 to update flash base addresses for the signed binaries of secure and non secure images according to the memory offsets in flash_layout.h. Signed-off-by: MartinaHanusovaNXP <martina.hanusova@nxp.com> Change-Id: I1f647ef89f2762ffbe41d08ca28b2bf9aea28e75
Diffstat (limited to 'platform/ext')
-rw-r--r--platform/ext/target/nxp/lpcxpresso55s69/config.cmake5
-rw-r--r--platform/ext/target/nxp/lpcxpresso55s69/scripts/build_tfm_demo_bl2.py31
-rw-r--r--platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_JLink.py27
-rw-r--r--platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_PyOCD.py18
4 files changed, 66 insertions, 15 deletions
diff --git a/platform/ext/target/nxp/lpcxpresso55s69/config.cmake b/platform/ext/target/nxp/lpcxpresso55s69/config.cmake
index 03edf0b337..1a4da6d876 100644
--- a/platform/ext/target/nxp/lpcxpresso55s69/config.cmake
+++ b/platform/ext/target/nxp/lpcxpresso55s69/config.cmake
@@ -11,4 +11,7 @@ set(NXP_SDK_GIT_TAG "MCUX_2.9.0" CACHE STRING "The ver
############################ Partitions ########################################
set(PS_NUM_ASSETS "5" CACHE STRING "The maximum number of assets to be stored in the Protected Storage area")
-set(PS_MAX_ASSET_SIZE "512" CACHE STRING "The maximum asset size to be stored in the Protected Storage area") \ No newline at end of file
+set(PS_MAX_ASSET_SIZE "512" CACHE STRING "The maximum asset size to be stored in the Protected Storage area")
+
+set(BL2_S_IMAGE_START "0x8000" CACHE STRING "Base address of the secure image in configuration with BL2")
+set(BL2_NS_IMAGE_START "0x30000" CACHE STRING "Base address of the non secure image in configuration with BL2")
diff --git a/platform/ext/target/nxp/lpcxpresso55s69/scripts/build_tfm_demo_bl2.py b/platform/ext/target/nxp/lpcxpresso55s69/scripts/build_tfm_demo_bl2.py
index 12409e34bf..733892bc1b 100644
--- a/platform/ext/target/nxp/lpcxpresso55s69/scripts/build_tfm_demo_bl2.py
+++ b/platform/ext/target/nxp/lpcxpresso55s69/scripts/build_tfm_demo_bl2.py
@@ -6,6 +6,35 @@
import os
import platform
+# Declaration of the default flash base addresses parsed from config.cmake
+if platform.system() == 'Windows':
+ BL2_S_IMAGE_START = os.popen('findstr BL2_S_IMAGE_START ..\config.cmake').read().split("set(BL2_S_IMAGE_START")[1].split("\"")[1]
+ BL2_NS_IMAGE_START = os.popen('findstr BL2_NS_IMAGE_START ..\config.cmake').read().split("set(BL2_NS_IMAGE_START")[1].split("\"")[1]
+else:
+ BL2_S_IMAGE_START = os.popen('grep "BL2_S_IMAGE_START" ../config.cmake').read().split("set(BL2_S_IMAGE_START")[1].split("\"")[1]
+ BL2_NS_IMAGE_START = os.popen('grep "BL2_NS_IMAGE_START" ../config.cmake').read().split("set(BL2_NS_IMAGE_START")[1].split("\"")[1]
+
+# Update flash base addresses according to the flash_layout.h if pyclibrary is present
+try:
+ import pyclibrary
+
+ # Parse the flash_layout.h header file with the BL2 configuration
+ parser = pyclibrary.CParser('../partition/flash_layout.h', macros={'BL2': 'ON'})
+
+ # Update secure image flash base address according to FLASH_AREA_0_OFFSET
+ BL2_S_IMAGE_START = parser.defs['values']['FLASH_AREA_0_OFFSET']
+ # Update non secure image flash base address according to BL2_S_IMAGE_START + FLASH_S_PARTITION_SIZE
+ BL2_NS_IMAGE_START = BL2_S_IMAGE_START + parser.defs['values']['FLASH_S_PARTITION_SIZE']
+
+# Use the default values if the previous step was not successful
+except:
+ print("*** WARNING: pyclibrary is not installed ***")
+ print("Please install pyclibrary for updating flash base addresses in case of flash_layout.h modification")
+ print("Using default values:")
+ print("BL2_S_IMAGE_START = " + BL2_S_IMAGE_START)
+ print("BL2_NS_IMAGE_START = " + BL2_NS_IMAGE_START)
+ print("")
+
# Move to the TF-M root directory
os.chdir('../../../../../../')
@@ -17,7 +46,7 @@ if os.path.isdir("build"):
os.system('rm -rf build')
# Generate the S and NS makefiles
-os.system('cmake -S . -B build -DTFM_PLATFORM=nxp/lpcxpresso55s69 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Relwithdebinfo -DTFM_PSA_API=ON -DTFM_ISOLATION_LEVEL=2 -G"Unix Makefiles"')
+os.system('cmake -S . -B build -DBL2_S_IMAGE_START=' + BL2_S_IMAGE_START + ' -DBL2_NS_IMAGE_START=' + BL2_NS_IMAGE_START + ' -DTFM_PLATFORM=nxp/lpcxpresso55s69 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Relwithdebinfo -DTFM_PSA_API=ON -DTFM_ISOLATION_LEVEL=2 -G"Unix Makefiles"')
# Build the binaries
os.chdir('build')
diff --git a/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_JLink.py b/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_JLink.py
index 88f2ccfd3c..b2a8c87cab 100644
--- a/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_JLink.py
+++ b/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_JLink.py
@@ -9,6 +9,15 @@ import platform
# Move to the TFM build folder
os.chdir('../../../../../../build/bin')
+# Parse flash base addresses of secure and non secure images stored in CMakeCache.txt
+if platform.system() == 'Windows':
+ BL2_S_IMAGE_START = os.popen('findstr BL2_S_IMAGE_START:STRING= ..\CMakeCache.txt').read().split('=')[1].rstrip()
+ BL2_NS_IMAGE_START = os.popen('findstr BL2_NS_IMAGE_START:STRING= ..\CMakeCache.txt').read().split('=')[1].rstrip()
+
+else:
+ BL2_S_IMAGE_START = os.popen('grep "BL2_S_IMAGE_START:STRING=" ../CMakeCache.txt').read().split('=')[1].rstrip()
+ BL2_NS_IMAGE_START = os.popen('grep "BL2_NS_IMAGE_START:STRING=" ../CMakeCache.txt').read().split('=')[1].rstrip()
+
# Define JLink configuration script file
FILE = "flash.jlink"
@@ -19,15 +28,15 @@ if os.path.isfile(FILE):
else:
os.system('rm -rf FILE')
-# Write the JLink configuration into flash.jlink script
-os.system('echo r >> ' + FILE) # reset the target
-os.system('echo erase >> ' + FILE) # erase the flash memory
-os.system('echo loadfile bl2.hex >> ' + FILE) # flash the bootloader file into target
-os.system('echo loadfile tfm_s_signed.bin 0x8000 >> ' + FILE) # flash the signed secure image into target
-os.system('echo loadfile tfm_ns_signed.bin 0x30000 >> ' + FILE) # flash the signed non-secure image into target
-os.system('echo r >> ' + FILE) # reset the target
-os.system('echo go >> ' + FILE) # run the program
-os.system('echo exit >> ' + FILE) # exit the JLinkCommander
+# Write the JLink configuration into flash.jlink script
+os.system('echo r >> ' + FILE) # reset the target
+os.system('echo erase >> ' + FILE) # erase the flash memory
+os.system('echo loadfile bl2.hex >> ' + FILE) # flash the bootloader file into target
+os.system('echo loadfile tfm_s_signed.bin ' + BL2_S_IMAGE_START + ' >> ' + FILE) # flash the signed secure image into target
+os.system('echo loadfile tfm_ns_signed.bin ' + BL2_NS_IMAGE_START + ' >> ' + FILE) # flash the signed non-secure image into target
+os.system('echo r >> ' + FILE) # reset the target
+os.system('echo go >> ' + FILE) # run the program
+os.system('echo exit >> ' + FILE) # exit the JLinkCommander
# Upload the configuration from flash.jlink script into the target device
if platform.system() == 'Windows':
diff --git a/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_PyOCD.py b/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_PyOCD.py
index 0949899060..76ec6eb736 100644
--- a/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_PyOCD.py
+++ b/platform/ext/target/nxp/lpcxpresso55s69/scripts/flash_bl2_PyOCD.py
@@ -2,14 +2,24 @@
# SPDX-License-Identifier: BSD-3-Clause
import os
+import platform
# Move to the TFM build folder
os.chdir('../../../../../../build/bin')
+# Parse flash base addresses of secure and non secure images stored in CMakeCache.txt
+if platform.system() == 'Windows':
+ BL2_S_IMAGE_START = os.popen('findstr BL2_S_IMAGE_START:STRING= ..\CMakeCache.txt').read().split('=')[1].rstrip()
+ BL2_NS_IMAGE_START = os.popen('findstr BL2_NS_IMAGE_START:STRING= ..\CMakeCache.txt').read().split('=')[1].rstrip()
+
+else:
+ BL2_S_IMAGE_START = os.popen('grep "BL2_S_IMAGE_START:STRING=" ../CMakeCache.txt').read().split('=')[1].rstrip()
+ BL2_NS_IMAGE_START = os.popen('grep "BL2_NS_IMAGE_START:STRING=" ../CMakeCache.txt').read().split('=')[1].rstrip()
+
target = 'LPC55S69'
# Flash with PyOCD
-os.system('pyocd erase --mass -t ' + target) # erase the flash memory
-os.system('pyocd flash bl2.hex -t ' + target) # flash the secure image into target
-os.system('pyocd flash tfm_s_signed.bin --base-address 0x8000 -t ' + target) # flash the signed secure image into target
-os.system('pyocd flash tfm_ns_signed.bin --base-address 0x30000 -t ' + target) # flash the signed non-secure image into target
+os.system('pyocd erase --mass -t ' + target) # erase the flash memory
+os.system('pyocd flash bl2.hex -t ' + target) # flash the secure image into target
+os.system('pyocd flash tfm_s_signed.bin --base-address ' + BL2_S_IMAGE_START + ' -t ' + target) # flash the signed secure image into target
+os.system('pyocd flash tfm_ns_signed.bin --base-address ' + BL2_NS_IMAGE_START + ' -t ' + target) # flash the signed non-secure image into target