Skip to content

Commit 67905bd

Browse files
Alexander ZilberkantOren Cohen
authored andcommitted
Use build directory in postbuild
Use build directory instead of temp directory for for intermediate files during binaries merge.
1 parent 40627a5 commit 67905bd

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tools/targets/ARM_MUSCA_A1.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
# limitations under the License.
1717

1818
import os
19-
from os.path import abspath, basename, dirname, splitext
19+
from os.path import abspath, basename, dirname, splitext, isdir
2020
from os.path import join as path_join
21-
import tempfile
2221
import re
23-
import shutil
2422
from argparse import Namespace
2523
from tools.psa.tfm.bin_utils.assemble import Assembly
2624
from tools.psa.tfm.bin_utils.imgtool import do_sign
@@ -30,17 +28,23 @@
3028
MBED_OS_ROOT = abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir))
3129
MUSCA_A1_BASE = path_join(MBED_OS_ROOT, 'targets', 'TARGET_ARM_SSG', 'TARGET_MUSCA_A1')
3230

31+
3332
def musca_tfm_bin(t_self, non_secure_bin, secure_bin):
34-
tempdir = tempfile.mkdtemp()
33+
34+
assert os.path.isfile(secure_bin)
35+
assert os.path.isfile(non_secure_bin)
36+
37+
build_dir = dirname(non_secure_bin)
38+
tempdir = path_join(build_dir, 'temp')
39+
if not isdir(tempdir):
40+
os.makedirs(tempdir)
3541
flash_layout = path_join(MUSCA_A1_BASE, 'partition', 'flash_layout.h')
3642
mcuboot_bin = path_join(MUSCA_A1_BASE, 'TARGET_MUSCA_A1_NS', 'prebuilt', 'mcuboot.bin')
3743
ns_bin_name, ns_bin_ext = splitext(basename(non_secure_bin))
3844
concatenated_bin = path_join(tempdir, 'tfm_' + ns_bin_name + ns_bin_ext)
3945
signed_bin = path_join(tempdir, 'tfm_' + ns_bin_name + '_signed' + ns_bin_ext)
4046

4147
assert os.path.isfile(flash_layout)
42-
assert os.path.isfile(secure_bin)
43-
assert os.path.isfile(non_secure_bin)
4448

4549
#1. Concatenate secure TFM and non-secure mbed binaries
4650
output = Assembly(flash_layout, concatenated_bin)
@@ -70,8 +74,6 @@ def musca_tfm_bin(t_self, non_secure_bin, secure_bin):
7074
out_fh.seek(mcuboot_image_size)
7175
out_fh.write(signed_fh.read())
7276

73-
shutil.rmtree(tempdir)
74-
7577

7678
def find_bl2_size(configFile):
7779
bl2_size_re = re.compile(r"^#define\s+FLASH_AREA_BL2_SIZE\s+\({0,1}(0x[0-9a-fA-F]+)\){0,1}")

0 commit comments

Comments
 (0)