Skip to content

Commit c9e00cf

Browse files
author
Cruz Monrreal
authored
Merge pull request #9480 from deepikabhavnani/core_arch_v8m
Refactor core optional parameters (FPU + DSP + Security extensions)
2 parents ffc52e6 + febbeff commit c9e00cf

File tree

4 files changed

+81
-94
lines changed

4 files changed

+81
-94
lines changed

tools/targets/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"Cortex-M33-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
5353
"Cortex-M33F": ["M33", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
5454
"Cortex-M33F-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
55-
"Cortex-M33FD": ["M33", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
56-
"Cortex-M33FD-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"]
55+
"Cortex-M33FE": ["M33", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
56+
"Cortex-M33FE-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"]
5757
}
5858

5959
CORE_ARCH = {
@@ -73,8 +73,8 @@
7373
"Cortex-M33F": 8,
7474
"Cortex-M33-NS": 8,
7575
"Cortex-M33F-NS": 8,
76-
"Cortex-M33FD": 8,
77-
"Cortex-M33FD-NS": 8,
76+
"Cortex-M33FE": 8,
77+
"Cortex-M33FE-NS": 8,
7878
}
7979

8080
################################################################################

tools/toolchains/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class mbedToolchain:
7878
"Cortex-M33": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
7979
"Cortex-M33F-NS": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "DOMAIN_NS=1", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
8080
"Cortex-M33F": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
81-
"Cortex-M33FD-NS": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "DOMAIN_NS=1", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
82-
"Cortex-M33FD": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
81+
"Cortex-M33FE-NS": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "DOMAIN_NS=1", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
82+
"Cortex-M33FE": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
8383
}
8484

8585
MBED_CONFIG_FILE_NAME="mbed_config.h"

tools/toolchains/arm.py

Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from shutil import rmtree
2626
from distutils.version import LooseVersion
2727

28+
from tools.targets import CORE_ARCH
2829
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2930
from tools.hooks import hook_tool
3031
from tools.utils import mkdir, NotSupportedException, run_cmd
@@ -363,7 +364,7 @@ class ARMC6(ARM_STD):
363364
SUPPORTED_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4",
364365
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD",
365366
"Cortex-M23", "Cortex-M23-NS", "Cortex-M33", "Cortex-M33F",
366-
"Cortex-M33-NS", "Cortex-M33F-NS", "Cortex-M33FD-NS", "Cortex-M33FD",
367+
"Cortex-M33-NS", "Cortex-M33F-NS", "Cortex-M33FE-NS", "Cortex-M33FE",
367368
"Cortex-A9"]
368369
ARMCC_RANGE = (LooseVersion("6.10"), LooseVersion("7.0"))
369370

@@ -380,76 +381,67 @@ def __init__(self, target, *args, **kwargs):
380381
if not set(("ARM", "ARMC6")).intersection(set(target.supported_toolchains)):
381382
raise NotSupportedException("ARM/ARMC6 compiler support is required for ARMC6 build")
382383

383-
if target.core.lower().endswith("fd"):
384-
self.flags['common'].append("-mcpu=%s" % target.core.lower()[:-2])
385-
self.flags['ld'].append("--cpu=%s" % target.core.lower()[:-2])
386-
self.SHEBANG += " -mcpu=%s" % target.core.lower()[:-2]
387-
elif target.core.lower().endswith("fd-ns"):
388-
self.flags['common'].append("-mcpu=%s" % target.core.lower()[:-5])
389-
self.flags['ld'].append("--cpu=%s" % target.core.lower()[:-5])
390-
self.SHEBANG += " -mcpu=%s" % target.core.lower()[:-5]
391-
elif target.core.lower().endswith("f"):
392-
self.flags['common'].append("-mcpu=%s" % target.core.lower()[:-1])
393-
self.flags['ld'].append("--cpu=%s" % target.core.lower()[:-1])
394-
self.SHEBANG += " -mcpu=%s" % target.core.lower()[:-1]
395-
elif target.core.startswith("Cortex-M33"):
396-
self.flags['common'].append("-mcpu=cortex-m33+nodsp")
397-
self.flags['common'].append("-mfpu=none")
398-
self.flags['ld'].append("--cpu=Cortex-M33.no_dsp.no_fp")
399-
elif not target.core.startswith("Cortex-M23"):
400-
self.flags['common'].append("-mcpu=%s" % target.core.lower())
401-
self.flags['ld'].append("--cpu=%s" % target.core.lower())
402-
self.SHEBANG += " -mcpu=%s" % target.core.lower()
403-
404-
if target.core == "Cortex-M4F":
384+
core = target.core
385+
if CORE_ARCH[target.core] == 8:
386+
if (not target.core.endswith("-NS")) and kwargs.get('build_dir', False):
387+
# Create Secure library
388+
build_dir = kwargs['build_dir']
389+
secure_file = join(build_dir, "cmse_lib.o")
390+
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
391+
392+
# Add linking time preprocessor macro DOMAIN_NS
393+
if target.core.endswith("-NS"):
394+
define_string = self.make_ld_define("DOMAIN_NS", "0x1")
395+
self.flags["ld"].append(define_string)
396+
core = target.core[:-3]
397+
else:
398+
# Add secure build flag
399+
self.flags['cxx'].append("-mcmse")
400+
self.flags['c'].append("-mcmse")
401+
402+
cpu = {
403+
"Cortex-M0+": "cortex-m0plus",
404+
"Cortex-M4F": "cortex-m4",
405+
"Cortex-M7F": "cortex-m7",
406+
"Cortex-M7FD": "cortex-m7",
407+
"Cortex-M33": "cortex-m33+no_dsp+no_fp",
408+
"Cortex-M33F": "cortex-m33+no_dsp",
409+
"Cortex-M33FE": "cortex-m33"}.get(core, core)
410+
411+
cpu = cpu.lower()
412+
self.flags['common'].append("-mcpu=%s" % cpu)
413+
self.SHEBANG += " -mcpu=%s" % cpu
414+
415+
# FPU handling
416+
if core == "Cortex-M4F":
405417
self.flags['common'].append("-mfpu=fpv4-sp-d16")
406418
self.flags['common'].append("-mfloat-abi=hard")
407-
elif target.core == "Cortex-M7F":
419+
self.flags['ld'].append("--cpu=cortex-m4")
420+
elif core == "Cortex-M7F":
408421
self.flags['common'].append("-mfpu=fpv5-sp-d16")
409422
self.flags['common'].append("-mfloat-abi=hard")
410-
elif target.core == "Cortex-M7FD":
423+
self.flags['ld'].append("--cpu=cortex-m7.fp.sp")
424+
elif core == "Cortex-M7FD":
411425
self.flags['common'].append("-mfpu=fpv5-d16")
412426
self.flags['common'].append("-mfloat-abi=hard")
413-
elif target.core.startswith("Cortex-M23"):
414-
self.flags['common'].append("-march=armv8-m.base")
415-
elif target.core.startswith("Cortex-M33F"):
427+
self.flags['ld'].append("--cpu=cortex-m7")
428+
elif core == "Cortex-M33F":
416429
self.flags['common'].append("-mfpu=fpv5-sp-d16")
417430
self.flags['common'].append("-mfloat-abi=hard")
418-
419-
if ((target.core.startswith("Cortex-M23") or
420-
target.core.startswith("Cortex-M33")) and
421-
not target.core.endswith("-NS")):
422-
self.flags['cxx'].append("-mcmse")
423-
self.flags['c'].append("-mcmse")
424-
425-
# Create Secure library
426-
if ((target.core.startswith("Cortex-M23") or
427-
target.core.startswith("Cortex-M33")) and
428-
not target.core.endswith("-NS") and
429-
kwargs.get('build_dir', False)):
430-
build_dir = kwargs['build_dir']
431-
secure_file = join(build_dir, "cmse_lib.o")
432-
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
433-
434-
# Add linking time preprocessor macro DOMAIN_NS
435-
if ((target.core.startswith("Cortex-M23") or
436-
target.core.startswith("Cortex-M33")) and
437-
target.core.endswith("-NS")):
438-
define_string = self.make_ld_define("DOMAIN_NS", "0x1")
439-
self.flags["ld"].append(define_string)
431+
self.flags['ld'].append("--cpu=cortex-m33.no_dsp")
432+
elif core == "Cortex-M33":
433+
self.flags['ld'].append("--cpu=cortex-m33.no_dsp.no_fp")
434+
else:
435+
self.flags['ld'].append("--cpu=%s" % cpu)
440436

441437
asm_cpu = {
442438
"Cortex-M0+": "Cortex-M0",
443439
"Cortex-M4F": "Cortex-M4.fp",
444440
"Cortex-M7F": "Cortex-M7.fp.sp",
445441
"Cortex-M7FD": "Cortex-M7.fp.dp",
446-
"Cortex-M23-NS": "Cortex-M23",
447442
"Cortex-M33": "Cortex-M33.no_dsp.no_fp",
448-
"Cortex-M33-NS": "Cortex-M33.no_dsp.no_fp",
449443
"Cortex-M33F": "Cortex-M33.no_dsp",
450-
"Cortex-M33F-NS": "Cortex-M33.no_dsp",
451-
"Cortex-M33FD": "Cortex-M33",
452-
"Cortex-M33FD-NS": "Cortex-M33"}.get(target.core, target.core)
444+
"Cortex-M33FE": "Cortex-M33"}.get(core, core)
453445

454446
self.flags['asm'].append("--cpu=%s" % asm_cpu)
455447

tools/toolchains/gcc.py

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from distutils.spawn import find_executable
2121
from distutils.version import LooseVersion
2222

23+
from tools.targets import CORE_ARCH
2324
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2425
from tools.hooks import hook_tool
2526
from tools.utils import run_cmd, NotSupportedException
@@ -52,37 +53,46 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
5253
self.flags["common"].append("-DMBED_RTOS_SINGLE_THREAD")
5354
self.flags["ld"].append("--specs=nano.specs")
5455

55-
if target.core == "Cortex-M0+":
56-
self.cpu = ["-mcpu=cortex-m0plus"]
57-
elif target.core.startswith("Cortex-M4"):
58-
self.cpu = ["-mcpu=cortex-m4"]
59-
elif target.core.startswith("Cortex-M7"):
60-
self.cpu = ["-mcpu=cortex-m7"]
61-
elif target.core.startswith("Cortex-M23"):
62-
self.cpu = ["-mcpu=cortex-m23"]
63-
elif target.core.startswith("Cortex-M33FD"):
64-
self.cpu = ["-mcpu=cortex-m33"]
65-
elif target.core.startswith("Cortex-M33F"):
66-
self.cpu = ["-mcpu=cortex-m33+nodsp"]
67-
elif target.core.startswith("Cortex-M33"):
56+
core = target.core
57+
if CORE_ARCH[target.core] == 8:
58+
# Add linking time preprocessor macro DOMAIN_NS
59+
if target.core.endswith("-NS"):
60+
self.flags["ld"].append("-DDOMAIN_NS=1")
61+
core = target.core[:-3]
62+
else:
63+
self.cpu.append("-mcmse")
64+
self.flags["ld"].extend([
65+
"-Wl,--cmse-implib",
66+
"-Wl,--out-implib=%s" % join(build_dir, "cmse_lib.o")
67+
])
68+
69+
cpu = {
70+
"Cortex-M0+": "cortex-m0plus",
71+
"Cortex-M4F": "cortex-m4",
72+
"Cortex-M7F": "cortex-m7",
73+
"Cortex-M7FD": "cortex-m7",
74+
"Cortex-M33F": "cortex-m33+no_dsp",
75+
"Cortex-M33FE": "cortex-m33"}.get(core, core)
76+
77+
if core == "Cortex-M33":
6878
self.cpu = ["-march=armv8-m.main"]
6979
else:
70-
self.cpu = ["-mcpu={}".format(target.core.lower())]
80+
self.cpu = ["-mcpu={}".format(cpu.lower())]
7181

7282
if target.core.startswith("Cortex-M"):
7383
self.cpu.append("-mthumb")
7484

7585
# FPU handling, M7 possibly to have double FPU
76-
if target.core == "Cortex-M4F":
86+
if core == "Cortex-M4F":
7787
self.cpu.append("-mfpu=fpv4-sp-d16")
7888
self.cpu.append("-mfloat-abi=softfp")
79-
elif target.core == "Cortex-M7F":
89+
elif core == "Cortex-M7F":
8090
self.cpu.append("-mfpu=fpv5-sp-d16")
8191
self.cpu.append("-mfloat-abi=softfp")
82-
elif target.core == "Cortex-M7FD":
92+
elif core == "Cortex-M7FD":
8393
self.cpu.append("-mfpu=fpv5-d16")
8494
self.cpu.append("-mfloat-abi=softfp")
85-
elif target.core.startswith("Cortex-M33F"):
95+
elif core.startswith("Cortex-M33F"):
8696
self.cpu.append("-mfpu=fpv5-sp-d16")
8797
self.cpu.append("-mfloat-abi=softfp")
8898

@@ -94,21 +104,6 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
94104
self.cpu.append("-mfloat-abi=hard")
95105
self.cpu.append("-mno-unaligned-access")
96106

97-
if ((target.core.startswith("Cortex-M23") or
98-
target.core.startswith("Cortex-M33")) and
99-
not target.core.endswith("-NS")):
100-
self.cpu.append("-mcmse")
101-
self.flags["ld"].extend([
102-
"-Wl,--cmse-implib",
103-
"-Wl,--out-implib=%s" % join(build_dir, "cmse_lib.o")
104-
])
105-
106-
# Add linking time preprocessor macro DOMAIN_NS
107-
if ((target.core.startswith("Cortex-M23") or
108-
target.core.startswith("Cortex-M33")) and
109-
target.core.endswith("-NS")):
110-
self.flags["ld"].append("-DDOMAIN_NS=1")
111-
112107
self.flags["common"] += self.cpu
113108

114109
main_cc = join(tool_path, "arm-none-eabi-gcc")

0 commit comments

Comments
 (0)