|
16 | 16 | # limitations under the License.
|
17 | 17 |
|
18 | 18 | import os
|
19 |
| -from os.path import abspath, basename, dirname, splitext |
| 19 | +from os.path import abspath, basename, dirname, splitext, isdir |
20 | 20 | from os.path import join as path_join
|
21 |
| -import tempfile |
22 | 21 | import re
|
23 |
| -import shutil |
24 | 22 | from argparse import Namespace
|
25 | 23 | from tools.psa.tfm.bin_utils.assemble import Assembly
|
26 | 24 | from tools.psa.tfm.bin_utils.imgtool import do_sign
|
|
30 | 28 | MBED_OS_ROOT = abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir))
|
31 | 29 | MUSCA_A1_BASE = path_join(MBED_OS_ROOT, 'targets', 'TARGET_ARM_SSG', 'TARGET_MUSCA_A1')
|
32 | 30 |
|
| 31 | + |
33 | 32 | 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) |
35 | 41 | flash_layout = path_join(MUSCA_A1_BASE, 'partition', 'flash_layout.h')
|
36 | 42 | mcuboot_bin = path_join(MUSCA_A1_BASE, 'TARGET_MUSCA_A1_NS', 'prebuilt', 'mcuboot.bin')
|
37 | 43 | ns_bin_name, ns_bin_ext = splitext(basename(non_secure_bin))
|
38 | 44 | concatenated_bin = path_join(tempdir, 'tfm_' + ns_bin_name + ns_bin_ext)
|
39 | 45 | signed_bin = path_join(tempdir, 'tfm_' + ns_bin_name + '_signed' + ns_bin_ext)
|
40 | 46 |
|
41 | 47 | assert os.path.isfile(flash_layout)
|
42 |
| - assert os.path.isfile(secure_bin) |
43 |
| - assert os.path.isfile(non_secure_bin) |
44 | 48 |
|
45 | 49 | #1. Concatenate secure TFM and non-secure mbed binaries
|
46 | 50 | output = Assembly(flash_layout, concatenated_bin)
|
@@ -70,8 +74,6 @@ def musca_tfm_bin(t_self, non_secure_bin, secure_bin):
|
70 | 74 | out_fh.seek(mcuboot_image_size)
|
71 | 75 | out_fh.write(signed_fh.read())
|
72 | 76 |
|
73 |
| - shutil.rmtree(tempdir) |
74 |
| - |
75 | 77 |
|
76 | 78 | def find_bl2_size(configFile):
|
77 | 79 | 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