From 67905bddae6dee313876500cbb0d83f0076b2d92 Mon Sep 17 00:00:00 2001 From: Alexander Zilberkant Date: Mon, 6 May 2019 10:12:29 +0300 Subject: [PATCH] Use build directory in postbuild Use build directory instead of temp directory for for intermediate files during binaries merge. --- tools/targets/ARM_MUSCA_A1.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/targets/ARM_MUSCA_A1.py b/tools/targets/ARM_MUSCA_A1.py index 2940c07227..6143fad32f 100644 --- a/tools/targets/ARM_MUSCA_A1.py +++ b/tools/targets/ARM_MUSCA_A1.py @@ -16,11 +16,9 @@ # limitations under the License. import os -from os.path import abspath, basename, dirname, splitext +from os.path import abspath, basename, dirname, splitext, isdir from os.path import join as path_join -import tempfile import re -import shutil from argparse import Namespace from tools.psa.tfm.bin_utils.assemble import Assembly from tools.psa.tfm.bin_utils.imgtool import do_sign @@ -30,8 +28,16 @@ SCRIPT_DIR = dirname(abspath(__file__)) MBED_OS_ROOT = abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir)) MUSCA_A1_BASE = path_join(MBED_OS_ROOT, 'targets', 'TARGET_ARM_SSG', 'TARGET_MUSCA_A1') + def musca_tfm_bin(t_self, non_secure_bin, secure_bin): - tempdir = tempfile.mkdtemp() + + assert os.path.isfile(secure_bin) + assert os.path.isfile(non_secure_bin) + + build_dir = dirname(non_secure_bin) + tempdir = path_join(build_dir, 'temp') + if not isdir(tempdir): + os.makedirs(tempdir) flash_layout = path_join(MUSCA_A1_BASE, 'partition', 'flash_layout.h') mcuboot_bin = path_join(MUSCA_A1_BASE, 'TARGET_MUSCA_A1_NS', 'prebuilt', 'mcuboot.bin') ns_bin_name, ns_bin_ext = splitext(basename(non_secure_bin)) @@ -39,8 +45,6 @@ def musca_tfm_bin(t_self, non_secure_bin, secure_bin): signed_bin = path_join(tempdir, 'tfm_' + ns_bin_name + '_signed' + ns_bin_ext) assert os.path.isfile(flash_layout) - assert os.path.isfile(secure_bin) - assert os.path.isfile(non_secure_bin) #1. Concatenate secure TFM and non-secure mbed binaries output = Assembly(flash_layout, concatenated_bin) @@ -70,8 +74,6 @@ def musca_tfm_bin(t_self, non_secure_bin, secure_bin): out_fh.seek(mcuboot_image_size) out_fh.write(signed_fh.read()) - shutil.rmtree(tempdir) - def find_bl2_size(configFile): bl2_size_re = re.compile(r"^#define\s+FLASH_AREA_BL2_SIZE\s+\({0,1}(0x[0-9a-fA-F]+)\){0,1}")