Skip to content

Commit b79b332

Browse files
urutvaPatater
authored andcommitted
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 <[email protected]>
1 parent fd74d67 commit b79b332

File tree

9 files changed

+114
-83
lines changed

9 files changed

+114
-83
lines changed

tools/export/cces/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ def is_target_supported(cls, target_name):
5353
target_name - the name of the target.
5454
"""
5555
target = TARGET_MAP[target_name]
56-
return (cls.TOOLCHAIN in target.supported_toolchains) \
57-
and hasattr(target, "device_name") \
58-
and (target.device_name in SUPPORTED_DEVICES)
56+
if not target.is_TFM_target:
57+
return (cls.TOOLCHAIN in target.supported_toolchains) \
58+
and hasattr(target, "device_name") \
59+
and (target.device_name in SUPPORTED_DEVICES)
60+
else:
61+
return False
5962

6063
@property
6164
def flags(self):

tools/export/cdt/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,13 @@ class EclipseArmc5(Eclipse, Armc5):
122122
@classmethod
123123
def is_target_supported(cls, target_name):
124124
target = TARGET_MAP[target_name]
125-
if int(target.build_tools_metadata["version"]) > 0:
126-
return "ARMC5" in target.supported_toolchains
125+
if not target.is_TFM_target:
126+
if int(target.build_tools_metadata["version"]) > 0:
127+
return "ARMC5" in target.supported_toolchains
128+
else:
129+
return True
127130
else:
128-
return True
131+
return False
129132

130133
class EclipseIAR(Eclipse, IAR):
131134
LOAD_EXE = True

tools/export/cmsis/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ class CMSIS(Exporter):
129129
@classmethod
130130
def is_target_supported(cls, target_name):
131131
target = TARGET_MAP[target_name]
132-
return cls.TOOLCHAIN in target.supported_toolchains
132+
if not target.is_TFM_target:
133+
return cls.TOOLCHAIN in target.supported_toolchains
134+
else:
135+
return False
133136

134137
def make_key(self, src):
135138
"""turn a source file into its group name"""

tools/export/exporters.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,11 @@ def is_target_supported(cls, target_name):
325325
target_name - the name of the target.
326326
"""
327327
target = TARGET_MAP[target_name]
328-
return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \
329-
and cls.TOOLCHAIN in target.supported_toolchains
328+
if not target.is_TFM_target:
329+
return bool(set(target.resolution_order_names).intersection(set(cls.TARGETS))) \
330+
and cls.TOOLCHAIN in target.supported_toolchains
331+
else:
332+
return False
330333

331334

332335
@classmethod
@@ -351,11 +354,14 @@ def filter_dot(str):
351354
def apply_supported_whitelist(compiler, whitelist, target):
352355
"""Generate a list of supported targets for a given compiler and post-binary hook
353356
white-list."""
354-
if compiler not in target.supported_toolchains:
355-
return False
356-
if not hasattr(target, "post_binary_hook"):
357-
return True
358-
if target.post_binary_hook['function'] in whitelist:
359-
return True
357+
if not target.is_TFM_target:
358+
if compiler not in target.supported_toolchains:
359+
return False
360+
if not hasattr(target, "post_binary_hook"):
361+
return True
362+
if target.post_binary_hook['function'] in whitelist:
363+
return True
364+
else:
365+
return False
360366
else:
361367
return False

tools/export/iar/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818

1919

2020
def _supported(mcu, iar_targets):
21-
if "IAR" not in mcu.supported_toolchains:
21+
if not mcu.is_TFM_target:
22+
if "IAR" not in mcu.supported_toolchains:
23+
return False
24+
if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets:
25+
return True
26+
if mcu.name in iar_targets:
27+
return True
28+
return False
29+
else:
2230
return False
23-
if hasattr(mcu, 'device_name') and mcu.device_name in iar_targets:
24-
return True
25-
if mcu.name in iar_targets:
26-
return True
27-
return False
2831

2932

3033
_iar_defs = os.path.join(

tools/export/makefile/__init__.py

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,21 @@ class Armc5(Arm):
289289
@classmethod
290290
def is_target_supported(cls, target_name):
291291
target = TARGET_MAP[target_name]
292-
if int(target.build_tools_metadata["version"]) > 0:
293-
#Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
294-
if "ARMC5" not in target.supported_toolchains:
295-
return False
296-
297-
arm_res = apply_supported_whitelist(
298-
"ARM", cls.POST_BINARY_WHITELIST, target
299-
)
300-
armc5_res = apply_supported_whitelist(
301-
"ARMC5", cls.POST_BINARY_WHITELIST, target
302-
)
303-
return arm_res or armc5_res
292+
if not target.is_TFM_target:
293+
if int(target.build_tools_metadata["version"]) > 0:
294+
# Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
295+
if "ARMC5" not in target.supported_toolchains:
296+
return False
297+
298+
arm_res = apply_supported_whitelist(
299+
"ARM", cls.POST_BINARY_WHITELIST, target
300+
)
301+
armc5_res = apply_supported_whitelist(
302+
"ARMC5", cls.POST_BINARY_WHITELIST, target
303+
)
304+
return arm_res or armc5_res
305+
else:
306+
return False
304307

305308
class Armc6(Arm):
306309
"""ARM Compiler 6 (armclang) specific generic makefile target"""
@@ -310,23 +313,25 @@ class Armc6(Arm):
310313
@classmethod
311314
def is_target_supported(cls, target_name):
312315
target = TARGET_MAP[target_name]
313-
314-
if int(target.build_tools_metadata["version"]) > 0:
315-
if not (len(set(target.supported_toolchains).intersection(
316-
set(["ARM", "ARMC6"]))) > 0):
317-
return False
318-
319-
if not apply_supported_whitelist(
320-
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target):
321-
#ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards
322-
#and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use
323-
return apply_supported_whitelist(
324-
"ARM", cls.POST_BINARY_WHITELIST, target)
316+
if not target.is_TFM_target:
317+
if int(target.build_tools_metadata["version"]) > 0:
318+
if not (len(set(target.supported_toolchains).intersection(
319+
set(["ARM", "ARMC6"]))) > 0):
320+
return False
321+
322+
if not apply_supported_whitelist(
323+
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target):
324+
# ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards
325+
# and still keep cls.TOOLCHAIN as ARMC6 as thats the toolchain we want to use
326+
return apply_supported_whitelist(
327+
"ARM", cls.POST_BINARY_WHITELIST, target)
328+
else:
329+
return True
325330
else:
326-
return True
331+
return apply_supported_whitelist(
332+
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
327333
else:
328-
return apply_supported_whitelist(
329-
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
334+
return
330335

331336

332337
class IAR(Makefile):

tools/export/sw4stm32/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,12 @@ class Sw4STM32(GNUARMEclipse):
298298
@classmethod
299299
def is_target_supported(cls, target_name):
300300
target = TARGET_MAP[target_name]
301-
target_supported = bool(set(target.resolution_order_names)
302-
.intersection(set(cls.BOARDS.keys())))
303-
toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains
304-
return target_supported and toolchain_supported
301+
if not target.is_TFM_target:
302+
target_supported = bool(set(target.resolution_order_names)
303+
.intersection(set(cls.BOARDS.keys())))
304+
toolchain_supported = cls.TOOLCHAIN in target.supported_toolchains
305+
return target_supported and toolchain_supported
306+
return False
305307

306308
def __gen_dir(self, dir_name):
307309
"""

tools/export/uvision/__init__.py

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -390,23 +390,26 @@ class UvisionArmc5(Uvision):
390390
@classmethod
391391
def is_target_supported(cls, target_name):
392392
target = TARGET_MAP[target_name]
393-
if int(target.build_tools_metadata["version"]) > 0:
394-
#Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5
395-
if "ARMC5" not in target.supported_toolchains:
393+
if not target.is_TFM_target:
394+
if int(target.build_tools_metadata["version"]) > 0:
395+
# Just check for ARMC5 as ARMC5 must be there irrespective of whether uARM is there or not if the target is staying with ARMC5
396+
if "ARMC5" not in target.supported_toolchains:
397+
return False
398+
else:
399+
if not (set(target.supported_toolchains).intersection(
400+
set(["ARM", "uARM"]))):
401+
return False
402+
403+
if not DeviceCMSIS.check_supported(target_name):
396404
return False
397-
else:
398-
if not (set(target.supported_toolchains).intersection(
399-
set(["ARM", "uARM"]))):
405+
if "Cortex-A" in target.core:
406+
return False
407+
if not hasattr(target, "post_binary_hook"):
408+
return True
409+
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
410+
return True
411+
else:
400412
return False
401-
402-
if not DeviceCMSIS.check_supported(target_name):
403-
return False
404-
if "Cortex-A" in target.core:
405-
return False
406-
if not hasattr(target, "post_binary_hook"):
407-
return True
408-
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
409-
return True
410413
else:
411414
return False
412415

@@ -419,21 +422,24 @@ class UvisionArmc6(Uvision):
419422
@classmethod
420423
def is_target_supported(cls, target_name):
421424
target = TARGET_MAP[target_name]
422-
if int(target.build_tools_metadata["version"]) > 0:
423-
if not len(set(target.supported_toolchains).intersection(
424-
set(["ARM", "ARMC6"]))) > 0:
425+
if not target.is_TFM_target:
426+
if int(target.build_tools_metadata["version"]) > 0:
427+
if not len(set(target.supported_toolchains).intersection(
428+
set(["ARM", "ARMC6"]))) > 0:
429+
return False
430+
else:
431+
if "ARMC6" not in target.supported_toolchains:
432+
return False
433+
434+
if not DeviceCMSIS.check_supported(target_name):
425435
return False
426-
else:
427-
if "ARMC6" not in target.supported_toolchains:
436+
if "Cortex-A" in target.core:
437+
return False
438+
if not hasattr(target, "post_binary_hook"):
439+
return True
440+
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
441+
return True
442+
else:
428443
return False
429-
430-
if not DeviceCMSIS.check_supported(target_name):
431-
return False
432-
if "Cortex-A" in target.core:
433-
return False
434-
if not hasattr(target, "post_binary_hook"):
435-
return True
436-
if target.post_binary_hook['function'] in cls.POST_BINARY_WHITELIST:
437-
return True
438444
else:
439445
return False

tools/targets/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ def is_PSA_non_secure_target(self):
400400
return 'NSPE_Target' in self.labels
401401

402402
@property
403-
def is_PSA_target(self):
404-
return self.is_PSA_secure_target or self.is_PSA_non_secure_target
403+
def is_TFM_target(self):
404+
return getattr(self, 'tfm_target_name', False)
405405

406406
def get_post_build_hook(self, toolchain_labels):
407407
"""Initialize the post-build hooks for a toolchain. For now, this

0 commit comments

Comments
 (0)