1# Copyright 2020-2023 NXP. All rights reserved. 2# SPDX-License-Identifier: BSD-3-Clause 3 4import os 5import platform 6 7# Move to the TFM build folder 8os.chdir('../../../../../../build/bin') 9 10# Parse flash base addresses of secure and non secure images stored in CMakeCache.txt 11if platform.system() == 'Windows': 12 BL2_S_IMAGE_START = os.popen('findstr BL2_S_IMAGE_START:STRING= ..\CMakeCache.txt').read().split('=')[1].rstrip() 13 BL2_NS_IMAGE_START = os.popen('findstr BL2_NS_IMAGE_START:STRING= ..\CMakeCache.txt').read().split('=')[1].rstrip() 14 15else: 16 BL2_S_IMAGE_START = os.popen('grep "BL2_S_IMAGE_START:STRING=" ../CMakeCache.txt').read().split('=')[1].rstrip() 17 BL2_NS_IMAGE_START = os.popen('grep "BL2_NS_IMAGE_START:STRING=" ../CMakeCache.txt').read().split('=')[1].rstrip() 18 19target = 'LPC55S69' 20 21# Flash with PyOCD 22os.system('pyocd erase --mass -t ' + target) # erase the flash memory 23os.system('pyocd flash bl2.hex -t ' + target) # flash the BL2 image into target 24os.system('pyocd flash tfm_s_ns_signed.bin --base-address ' + BL2_S_IMAGE_START + ' -t ' + target) # flash the signed image into target