diff --git a/tools/targets/LPC55S69.py b/tools/targets/LPC55S69.py new file mode 100644 index 0000000000..eab0c77e21 --- /dev/null +++ b/tools/targets/LPC55S69.py @@ -0,0 +1,45 @@ + # + # Copyright (c) 2018 Arm Limited + # + # 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. + # + +import os +from os.path import abspath, basename, dirname, splitext +from os.path import join as path_join +import tempfile + +from tools.psa.tfm.bin_utils.assemble import Assembly + +SCRIPT_DIR = dirname(abspath(__file__)) +MBED_OS_ROOT = abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir)) +LPC55S69_BASE = path_join(MBED_OS_ROOT, 'targets', 'TARGET_NXP', 'TARGET_MCUXpresso_MCUS', 'TARGET_LPC55S69') + +def lpc55s69_tfm_bin(t_self, non_secure_bin): + tempdir = tempfile.mkdtemp() + flash_layout = path_join(LPC55S69_BASE, 'partition', 'flash_layout.h') + secure_bin = path_join(LPC55S69_BASE, 'TARGET_M33_NS', 'device', 'tfm.bin') + ns_bin_name, ns_bin_ext = splitext(basename(non_secure_bin)) + concatenated_bin = path_join(tempdir, 'tfm_' + ns_bin_name + ns_bin_ext) + + #1. Concatenate secure TFM and non-secure mbed binaries + output = Assembly(flash_layout, concatenated_bin) + output.add_image(secure_bin, "SECURE") + output.add_image(non_secure_bin, "NON_SECURE") + + #2. Delete the original binary file name + os.remove(non_secure_bin) + + #3. Rename to new concatenated binary to the original binary file name + os.rename(concatenated_bin, non_secure_bin) + diff --git a/tools/targets/__init__.py b/tools/targets/__init__.py index 451116338d..fda5d44f42 100644 --- a/tools/targets/__init__.py +++ b/tools/targets/__init__.py @@ -598,6 +598,13 @@ class PSOC6Code: else: psoc6_complete(t_self, elf, binf) +class LPC55S69Code: + """LPC55S69 Hooks""" + @staticmethod + def binary_hook(t_self, resources, elf, binf): + from tools.targets.LPC55S69 import lpc55s69_tfm_bin + lpc55s69_tfm_bin(t_self, binf) + ################################################################################ # Instantiate all public targets