diff --git a/tools/build_api.py b/tools/build_api.py index 0b127700ac6..dfd4895dfa0 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -44,7 +44,7 @@ BUILD_DIR) from .resources import Resources, FileType, FileRef from .notifier.mock import MockNotifier -from .targets import TARGET_NAMES, TARGET_MAP +from .targets import TARGET_NAMES, TARGET_MAP, CORE_ARCH from .libraries import Library from .toolchains import TOOLCHAIN_CLASSES from .config import Config @@ -316,6 +316,8 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name, raise NotSupportedException( "Target {} is not supported by toolchain {}".format( target.name, toolchain_name)) + if (toolchain_name == "ARM" and CORE_ARCH[target.core] == 8): + toolchain_name = "ARMC6" try: cur_tc = TOOLCHAIN_CLASSES[toolchain_name] @@ -1196,9 +1198,13 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None, row.append(text) for unique_toolchain in unique_supported_toolchains: - if (unique_toolchain in TARGET_MAP[target].supported_toolchains or + tgt_obj = TARGET_MAP[target] + if (unique_toolchain in tgt_obj.supported_toolchains or (unique_toolchain == "ARMC6" and - "ARM" in TARGET_MAP[target].supported_toolchains)): + "ARM" in tgt_obj.supported_toolchains) or + (unique_toolchain == "ARM" and + "ARMC6" in tgt_obj.supported_toolchains and + CORE_ARCH[tgt_obj.core] == 8)): text = "Supported" perm_counter += 1 else: diff --git a/tools/targets/__init__.py b/tools/targets/__init__.py index bf1864554de..594381cc075 100644 --- a/tools/targets/__init__.py +++ b/tools/targets/__init__.py @@ -30,7 +30,7 @@ from tools.utils import json_file_to_dict __all__ = ["target", "TARGETS", "TARGET_MAP", "TARGET_NAMES", "CORE_LABELS", - "HookError", "generate_py_target", "Target", + "CORE_ARCH", "HookError", "generate_py_target", "Target", "CUMULATIVE_ATTRIBUTES", "get_resolution_order"] CORE_LABELS = { @@ -50,6 +50,23 @@ "Cortex-M33-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"] } +CORE_ARCH = { + "Cortex-M0": 6, + "Cortex-M0+": 6, + "Cortex-M1": 6, + "Cortex-M3": 7, + "Cortex-M4": 7, + "Cortex-M4F": 7, + "Cortex-M7": 7, + "Cortex-M7F": 7, + "Cortex-M7FD": 7, + "Cortex-A9": 7, + "Cortex-M23": 8, + "Cortex-M23-NS": 8, + "Cortex-M33": 8, + "Cortex-M33-NS": 8, +} + ################################################################################ # Generic Target class that reads and interprets the data in targets.json diff --git a/tools/test/toolchains/api_test.py b/tools/test/toolchains/api_test.py index 3b8985fbd00..53fe6454b5e 100644 --- a/tools/test/toolchains/api_test.py +++ b/tools/test/toolchains/api_test.py @@ -184,7 +184,7 @@ def test_toolchain_profile_asm(profile, source_file): with patch('os.mkdir') as _mkdir: for _, tc_class in TOOLCHAIN_CLASSES.items(): toolchain = tc_class(TARGET_MAP["K64F"], build_profile=profile, - notify=MockNotifier) + notify=MockNotifier()) toolchain.inc_md5 = "" toolchain.build_dir = "" for parameter in profile['asm']: diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index ee3d9702d6c..0ad6174f2fb 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -25,6 +25,7 @@ from shutil import rmtree from distutils.version import LooseVersion +from tools.targets import CORE_ARCH from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.hooks import hook_tool from tools.utils import mkdir, NotSupportedException, run_cmd @@ -368,6 +369,14 @@ def __init__(self, target, *args, **kwargs): if target.core not in self.SUPPORTED_CORES: raise NotSupportedException( "this compiler does not support the core %s" % target.core) + if CORE_ARCH[target.core] < 8: + self.notify.cc_info({ + 'severity': "Error", 'file': "", 'line': "", 'col': "", + 'message': "ARMC6 does not support ARM architecture v{}" + " targets".format(CORE_ARCH[target.core]), + 'text': '', 'target_name': self.target.name, + 'toolchain_name': self.name + }) if not set(("ARM", "ARMC6")).intersection(set(target.supported_toolchains)): raise NotSupportedException("ARM/ARMC6 compiler support is required for ARMC6 build")