Fix imgtool import for CYTFM_064B0S2_4343W signing

Fixes: #14153

The target CYTFM_064B0S2_4343W is signed using `cysecuretools` which
depends on `imgtool` managed by `pip`. However, Arm Musca targets
requires a modified/wrapped version of the image tool copied from
trusted-firmware-m + MCUboot.

To avoid conflicts in the version of `imgtool` used, we should only
add the copied version of `imgtool` to python's system path for
Musca targets instead of doing it globally for all targets.
pull/14362/head
Lingkai Dong 2021-02-23 17:34:23 +00:00
parent 76b2902f48
commit 5ef82f59cc
2 changed files with 6 additions and 5 deletions

View File

@ -20,6 +20,11 @@ from os.path import abspath, basename, dirname, splitext, isdir
from os.path import join as path_join from os.path import join as path_join
import re import re
import subprocess import subprocess
import sys
# Add PSA TF-M binary utility scripts in system path
TFM_SCRIPTS = abspath(path_join(dirname(__file__), '..', 'psa', 'tfm', 'bin_utils'))
sys.path.insert(0, TFM_SCRIPTS)
SCRIPT_DIR = dirname(abspath(__file__)) SCRIPT_DIR = dirname(abspath(__file__))
MBED_OS_ROOT = abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir)) MBED_OS_ROOT = abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir))

View File

@ -26,17 +26,13 @@ import sys
from collections import namedtuple from collections import namedtuple
from copy import copy from copy import copy
from future.utils import raise_from from future.utils import raise_from
from os.path import dirname, abspath, join
from tools.resources import FileType from tools.resources import FileType
from tools.settings import ROOT from tools.settings import ROOT
from tools.targets.LPC import patch from tools.targets.LPC import patch
from tools.paths import TOOLS_BOOTLOADERS from tools.paths import TOOLS_BOOTLOADERS
from tools.utils import json_file_to_dict, NotSupportedException from tools.utils import json_file_to_dict, NotSupportedException
# Add PSA TF-M binary utility scripts in system path
from os.path import dirname, abspath, join
TFM_SCRIPTS = abspath(join(dirname(__file__), '..', 'psa', 'tfm', 'bin_utils'))
sys.path.insert(0, TFM_SCRIPTS)
__all__ = ["target", "TARGETS", "TARGET_MAP", "TARGET_NAMES", "CORE_LABELS", __all__ = ["target", "TARGETS", "TARGET_MAP", "TARGET_NAMES", "CORE_LABELS",
"CORE_ARCH", "HookError", "generate_py_target", "Target", "CORE_ARCH", "HookError", "generate_py_target", "Target",