Skip to content

Commit ebab23c

Browse files
kjbraceyadbridge
authored andcommitted
Correct some CPU selections in tools
* For ARMC6, core types `Cortex-M4` and `Cortex-M7` did not explicitly add `--fpu=none`, so it defaulted to assuming FPU present. This would cause a compilation error if the target's cmsis.h had `__FPU_PRESENT` defined to 0. * For GCC, `Cortex-M33FE` did not include `+dsp` in the architecture selection. * For ARMC5 and ARMC6, `Cortex-M0+` did not pass `M0plus` to the non-Clang tools.
1 parent bd74b46 commit ebab23c

File tree

3 files changed

+23
-35
lines changed

3 files changed

+23
-35
lines changed

tools/toolchains/arm.py

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,11 @@ def __init__(self, target, notify=None, macros=None,
8282
if "--library_type=microlib" not in self.flags['common']:
8383
self.flags['common'].append("--library_type=microlib")
8484

85-
if target.core == "Cortex-M0+":
86-
cpu = "Cortex-M0"
87-
elif target.core == "Cortex-M4F":
88-
cpu = "Cortex-M4.fp"
89-
elif target.core == "Cortex-M7FD":
90-
cpu = "Cortex-M7.fp.dp"
91-
elif target.core == "Cortex-M7F":
92-
cpu = "Cortex-M7.fp.sp"
93-
else:
94-
cpu = target.core
85+
cpu = {
86+
"Cortex-M0+": "Cortex-M0plus",
87+
"Cortex-M4F": "Cortex-M4.fp.sp",
88+
"Cortex-M7F": "Cortex-M7.fp.sp",
89+
"Cortex-M7FD": "Cortex-M7.fp.dp"}.get(target.core, target.core)
9590

9691
ARM_BIN = join(TOOLCHAIN_PATHS['ARM'], "bin")
9792

@@ -559,38 +554,31 @@ def __init__(self, target, *args, **kwargs):
559554
self.SHEBANG += " -mcpu=%s" % cpu
560555

561556
# FPU handling
562-
if core == "Cortex-M4F":
557+
if core == "Cortex-M4" or core == "Cortex-M7" or "core" == "Cortex-M33":
558+
self.flags['common'].append("-mfpu=none")
559+
elif core == "Cortex-M4F":
563560
self.flags['common'].append("-mfpu=fpv4-sp-d16")
564561
self.flags['common'].append("-mfloat-abi=hard")
565-
self.flags['ld'].append("--cpu=cortex-m4")
566-
elif core == "Cortex-M7F":
562+
elif core == "Cortex-M7F" or core.startswith("Cortex-M33F"):
567563
self.flags['common'].append("-mfpu=fpv5-sp-d16")
568564
self.flags['common'].append("-mfloat-abi=hard")
569-
self.flags['ld'].append("--cpu=cortex-m7.fp.sp")
570565
elif core == "Cortex-M7FD":
571566
self.flags['common'].append("-mfpu=fpv5-d16")
572567
self.flags['common'].append("-mfloat-abi=hard")
573-
self.flags['ld'].append("--cpu=cortex-m7")
574-
elif core == "Cortex-M33F":
575-
self.flags['common'].append("-mfpu=fpv5-sp-d16")
576-
self.flags['common'].append("-mfloat-abi=hard")
577-
self.flags['ld'].append("--cpu=cortex-m33.no_dsp")
578-
elif core == "Cortex-M33":
579-
self.flags['common'].append("-mfpu=none")
580-
self.flags['ld'].append("--cpu=cortex-m33.no_dsp.no_fp")
581-
else:
582-
self.flags['ld'].append("--cpu=%s" % cpu)
583568

584-
asm_cpu = {
585-
"Cortex-M0+": "Cortex-M0",
586-
"Cortex-M4F": "Cortex-M4.fp",
569+
asm_ld_cpu = {
570+
"Cortex-M0+": "Cortex-M0plus",
571+
"Cortex-M4": "Cortex-M4.no_fp",
572+
"Cortex-M4F": "Cortex-M4",
573+
"Cortex-M7": "Cortex-M7.no_fp",
587574
"Cortex-M7F": "Cortex-M7.fp.sp",
588-
"Cortex-M7FD": "Cortex-M7.fp.dp",
575+
"Cortex-M7FD": "Cortex-M7",
589576
"Cortex-M33": "Cortex-M33.no_dsp.no_fp",
590577
"Cortex-M33F": "Cortex-M33.no_dsp",
591578
"Cortex-M33FE": "Cortex-M33"}.get(core, core)
592579

593-
self.flags['asm'].append("--cpu=%s" % asm_cpu)
580+
self.flags['asm'].append("--cpu=%s" % asm_ld_cpu)
581+
self.flags['ld'].append("--cpu=%s" % asm_ld_cpu)
594582

595583
self.cc = ([join(TOOLCHAIN_PATHS["ARMC6"], "armclang")] +
596584
self.flags['common'] + self.flags['c'])

tools/toolchains/gcc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
7878
"Cortex-M4F": "cortex-m4",
7979
"Cortex-M7F": "cortex-m7",
8080
"Cortex-M7FD": "cortex-m7",
81+
"Cortex-M33": "cortex-m33+nodsp",
8182
"Cortex-M33F": "cortex-m33+nodsp",
8283
"Cortex-M33FE": "cortex-m33"}.get(core, core)
8384

84-
if core == "Cortex-M33":
85+
if cpu == "cortex-m33+nodsp":
8586
self.cpu.append("-march=armv8-m.main")
87+
elif cpu == "cortex-m33":
88+
self.cpu.append("-march=armv8-m.main+dsp")
8689
else:
8790
self.cpu.append("-mcpu={}".format(cpu.lower()))
8891

@@ -93,15 +96,12 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
9396
if core == "Cortex-M4F":
9497
self.cpu.append("-mfpu=fpv4-sp-d16")
9598
self.cpu.append("-mfloat-abi=softfp")
96-
elif core == "Cortex-M7F":
99+
elif core == "Cortex-M7F" or core.startswith("Cortex-M33F"):
97100
self.cpu.append("-mfpu=fpv5-sp-d16")
98101
self.cpu.append("-mfloat-abi=softfp")
99102
elif core == "Cortex-M7FD":
100103
self.cpu.append("-mfpu=fpv5-d16")
101104
self.cpu.append("-mfloat-abi=softfp")
102-
elif core.startswith("Cortex-M33F"):
103-
self.cpu.append("-mfpu=fpv5-sp-d16")
104-
self.cpu.append("-mfloat-abi=softfp")
105105

106106
if target.core == "Cortex-A9":
107107
self.cpu.append("-mthumb-interwork")

tools/toolchains/iar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
6969
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
7070

7171
cpu = {
72-
"Cortex-M7FD": "Cortex-M7.fp.dp",
7372
"Cortex-M7F": "Cortex-M7.fp.sp",
73+
"Cortex-M7FD": "Cortex-M7.fp.dp",
7474
"Cortex-M33": "Cortex-M33.no_dsp",
7575
"Cortex-M33F": "Cortex-M33.fp.no_dsp",
7676
"Cortex-M33FE": "Cortex-M33.fp"}.get(core, core)

0 commit comments

Comments
 (0)