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 = TARGET_MAP[target_name]
return (cls.TOOLCHAIN in target.supported_toolchains) \
and hasattr(target, "device_name") \
and (target.device_name in SUPPORTED_DEVICES)
if not target.is_TFM_target:
return (cls.TOOLCHAIN in target.supported_toolchains) \
and hasattr(target, "device_name") \
and (target.device_name in SUPPORTED_DEVICES)
else:
return False
@property
def flags(self):

View File

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

View File

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

View File

@ -18,13 +18,16 @@ from multiprocessing import cpu_count
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
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(

View File

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

View File

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

View File

@ -390,23 +390,26 @@ class UvisionArmc5(Uvision):
@classmethod
def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0:
#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 "ARMC5" not in target.supported_toolchains:
return False
else:
if not (set(target.supported_toolchains).intersection(
set(["ARM", "uARM"]))):
return False
if not target.is_TFM_target:
if int(target.build_tools_metadata["version"]) > 0:
# 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 "ARMC5" not in target.supported_toolchains:
return False
else:
if not (set(target.supported_toolchains).intersection(
set(["ARM", "uARM"]))):
return False
if not DeviceCMSIS.check_supported(target_name):
return False
if "Cortex-A" in target.core:
return False
if not hasattr(target, "post_binary_hook"):
return True
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
return True
if not DeviceCMSIS.check_supported(target_name):
return False
if "Cortex-A" in target.core:
return False
if not hasattr(target, "post_binary_hook"):
return True
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
return True
else:
return False
else:
return False
@ -419,21 +422,24 @@ class UvisionArmc6(Uvision):
@classmethod
def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0:
if not len(set(target.supported_toolchains).intersection(
set(["ARM", "ARMC6"]))) > 0:
return False
else:
if "ARMC6" not in target.supported_toolchains:
return False
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
else:
if "ARMC6" not in target.supported_toolchains:
return False
if not DeviceCMSIS.check_supported(target_name):
return False
if "Cortex-A" in target.core:
return False
if not hasattr(target, "post_binary_hook"):
return True
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
return True
if not DeviceCMSIS.check_supported(target_name):
return False
if "Cortex-A" in target.core:
return False
if not hasattr(target, "post_binary_hook"):
return True
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
return True
else:
return False
else:
return False

View File

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