psa: Remove exporters for TF-M targets

Targets that use TF-M for their PSA implementation are not compatible
with exporters at this time. Explicitly block use of exporters with TF-M
using targets, for better error messages.

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
pull/12737/head
Devaraj Ranganna 2019-11-28 16:49:23 +00:00 committed by Jaeden Amero
parent fd74d678a7
commit b79b33219b
9 changed files with 114 additions and 83 deletions

View File

@ -53,9 +53,12 @@ class CCES(Exporter):
target_name - the name of the target. target_name - the name of the target.
""" """
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
return (cls.TOOLCHAIN in target.supported_toolchains) \ if not target.is_TFM_target:
and hasattr(target, "device_name") \ return (cls.TOOLCHAIN in target.supported_toolchains) \
and (target.device_name in SUPPORTED_DEVICES) and hasattr(target, "device_name") \
and (target.device_name in SUPPORTED_DEVICES)
else:
return False
@property @property
def flags(self): def flags(self):

View File

@ -122,10 +122,13 @@ class EclipseArmc5(Eclipse, Armc5):
@classmethod @classmethod
def is_target_supported(cls, target_name): def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0: if not target.is_TFM_target:
return "ARMC5" in target.supported_toolchains if int(target.build_tools_metadata["version"]) > 0:
return "ARMC5" in target.supported_toolchains
else:
return True
else: else:
return True return False
class EclipseIAR(Eclipse, IAR): class EclipseIAR(Eclipse, IAR):
LOAD_EXE = True LOAD_EXE = True

View File

@ -129,7 +129,10 @@ class CMSIS(Exporter):
@classmethod @classmethod
def is_target_supported(cls, target_name): def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
return cls.TOOLCHAIN in target.supported_toolchains if not target.is_TFM_target:
return cls.TOOLCHAIN in target.supported_toolchains
else:
return False
def make_key(self, src): def make_key(self, src):
"""turn a source file into its group name""" """turn a source file into its group name"""

View File

@ -325,8 +325,11 @@ class Exporter(with_metaclass(ABCMeta, object)):
target_name - the name of the target. target_name - the name of the target.
""" """
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \ if not target.is_TFM_target:
and cls.TOOLCHAIN in target.supported_toolchains return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \
and cls.TOOLCHAIN in target.supported_toolchains
else:
return False
@classmethod @classmethod
@ -351,11 +354,14 @@ class Exporter(with_metaclass(ABCMeta, object)):
def apply_supported_whitelist(compiler, whitelist, target): def apply_supported_whitelist(compiler, whitelist, target):
"""Generate a list of supported targets for a given compiler and post-binary hook """Generate a list of supported targets for a given compiler and post-binary hook
white-list.""" white-list."""
if compiler not in target.supported_toolchains: if not target.is_TFM_target:
return False if compiler not in target.supported_toolchains:
if not hasattr(target, "post_binary_hook"): return False
return True if not hasattr(target, "post_binary_hook"):
if target.post_binary_hook['function'] in whitelist: return True
return True if target.post_binary_hook['function'] in whitelist:
return True
else:
return False
else: else:
return False return False

View File

@ -18,13 +18,16 @@ from multiprocessing import cpu_count
def _supported(mcu, iar_targets): def _supported(mcu, iar_targets):
if "IAR" not in mcu.supported_toolchains: if not mcu.is_TFM_target:
if "IAR" not in mcu.supported_toolchains:
return False
if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets:
return True
if mcu.name in iar_targets:
return True
return False
else:
return False return False
if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets:
return True
if mcu.name in iar_targets:
return True
return False
_iar_defs = os.path.join( _iar_defs = os.path.join(

View File

@ -289,18 +289,21 @@ class Armc5(Arm):
@classmethod @classmethod
def is_target_supported(cls, target_name): def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0: if not target.is_TFM_target:
#Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards if int(target.build_tools_metadata["version"]) > 0:
if "ARMC5" not in target.supported_toolchains: # Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
return False if "ARMC5" not in target.supported_toolchains:
return False
arm_res = apply_supported_whitelist( arm_res = apply_supported_whitelist(
"ARM", cls.POST_BINARY_WHITELIST, target "ARM", cls.POST_BINARY_WHITELIST, target
) )
armc5_res = apply_supported_whitelist( armc5_res = apply_supported_whitelist(
"ARMC5", cls.POST_BINARY_WHITELIST, target "ARMC5", cls.POST_BINARY_WHITELIST, target
) )
return arm_res or armc5_res return arm_res or armc5_res
else:
return False
class Armc6(Arm): class Armc6(Arm):
"""ARM Compiler 6 (armclang) specific generic makefile target""" """ARM Compiler 6 (armclang) specific generic makefile target"""
@ -310,23 +313,25 @@ class Armc6(Arm):
@classmethod @classmethod
def is_target_supported(cls, target_name): def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
if not target.is_TFM_target:
if int(target.build_tools_metadata["version"]) > 0:
if not (len(set(target.supported_toolchains).intersection(
set(["ARM", "ARMC6"]))) > 0):
return False
if int(target.build_tools_metadata["version"]) > 0: if not apply_supported_whitelist(
if not (len(set(target.supported_toolchains).intersection( cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target):
set(["ARM", "ARMC6"]))) > 0): # ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards
return False # and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use
return apply_supported_whitelist(
if not apply_supported_whitelist( "ARM", cls.POST_BINARY_WHITELIST, target)
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target): else:
#ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards return True
#and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use
return apply_supported_whitelist(
"ARM", cls.POST_BINARY_WHITELIST, target)
else: else:
return True return apply_supported_whitelist(
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
else: else:
return apply_supported_whitelist( return
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
class IAR(Makefile): class IAR(Makefile):

View File

@ -298,10 +298,12 @@ class Sw4STM32(GNUARMEclipse):
@classmethod @classmethod
def is_target_supported(cls, target_name): def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
target_supported = bool(set(target.resolution_order_names) if not target.is_TFM_target:
.intersection(set(cls.BOARDS.keys()))) target_supported = bool(set(target.resolution_order_names)
toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains .intersection(set(cls.BOARDS.keys())))
return target_supported and toolchain_supported toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains
return target_supported and toolchain_supported
return False
def __gen_dir(self, dir_name): def __gen_dir(self, dir_name):
""" """

View File

@ -390,23 +390,26 @@ class UvisionArmc5(Uvision):
@classmethod @classmethod
def is_target_supported(cls, target_name): def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0: if not target.is_TFM_target:
#Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5 if int(target.build_tools_metadata["version"]) > 0:
if "ARMC5" not in target.supported_toolchains: # Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5
return False if "ARMC5" not in target.supported_toolchains:
else: return False
if not (set(target.supported_toolchains).intersection( else:
set(["ARM", "uARM"]))): if not (set(target.supported_toolchains).intersection(
return False set(["ARM", "uARM"]))):
return False
if not DeviceCMSIS.check_supported(target_name): if not DeviceCMSIS.check_supported(target_name):
return False return False
if "Cortex-A" in target.core: if "Cortex-A" in target.core:
return False return False
if not hasattr(target, "post_binary_hook"): if not hasattr(target, "post_binary_hook"):
return True return True
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST: if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
return True return True
else:
return False
else: else:
return False return False
@ -419,21 +422,24 @@ class UvisionArmc6(Uvision):
@classmethod @classmethod
def is_target_supported(cls, target_name): def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name] target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0: if not target.is_TFM_target:
if not len(set(target.supported_toolchains).intersection( if int(target.build_tools_metadata["version"]) > 0:
set(["ARM", "ARMC6"]))) > 0: if not len(set(target.supported_toolchains).intersection(
return False set(["ARM", "ARMC6"]))) > 0:
else: return False
if "ARMC6" not in target.supported_toolchains: else:
return False if "ARMC6" not in target.supported_toolchains:
return False
if not DeviceCMSIS.check_supported(target_name): if not DeviceCMSIS.check_supported(target_name):
return False return False
if "Cortex-A" in target.core: if "Cortex-A" in target.core:
return False return False
if not hasattr(target, "post_binary_hook"): if not hasattr(target, "post_binary_hook"):
return True return True
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST: if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
return True return True
else:
return False
else: else:
return False return False

View File

@ -400,8 +400,8 @@ class Target(namedtuple(
return 'NSPE_Target' in self.labels return 'NSPE_Target' in self.labels
@property @property
def is_PSA_target(self): def is_TFM_target(self):
return self.is_PSA_secure_target or self.is_PSA_non_secure_target return getattr(self, 'tfm_target_name', False)
def get_post_build_hook(self, toolchain_labels): def get_post_build_hook(self, toolchain_labels):
"""Initialize the post-build hooks for a toolchain. For now, this """Initialize the post-build hooks for a toolchain. For now, this