Skip to content

Commit ddf5060

Browse files
deepikabhavnaniadbridge
authored andcommitted
Correct the floating+dsp options for Cortex-M processors
As per the IAR Development guide, below options for CPU are valid 1. Cortex-M33 2. Cortex-M33.no_dsp (core without integer DSP extension) 3. Cortex-M33.fp (floating-point unit with support for single precision) 4. Cortex-M33.no_se (core without support for TrustZone) 5. Cortex-M4 6. Cortex-M4F 7. Cortex-M7 8. Cortex-M7.fp.dp (floating-point unit with support for double precision) 9. Cortex-M7.fp.sp (floating-point unit with support for single precision)
1 parent 3493e3e commit ddf5060

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

tools/toolchains/iar.py

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,34 @@ def check_executable():
4444

4545
def __init__(self, target, notify=None, macros=None, build_profile=None,
4646
build_dir=None):
47-
mbedToolchain.__init__(self, target, notify, macros, build_dir=build_dir,
48-
build_profile=build_profile)
49-
if target.core == "Cortex-M7F" or target.core == "Cortex-M7FD":
50-
cpuchoice = "Cortex-M7"
51-
elif target.core.startswith("Cortex-M33FD"):
52-
cpuchoice = "Cortex-M33"
53-
elif target.core.startswith("Cortex-M33"):
54-
cpuchoice = "Cortex-M33.no_dsp"
55-
elif target.core.startswith("Cortex-M23"):
56-
cpuchoice = "Cortex-M23"
57-
else:
58-
cpuchoice = target.core
47+
mbedToolchain.__init__(self, target, notify, macros, build_dir=build_dir,build_profile=build_profile)
48+
core = target.core
49+
if CORE_ARCH[target.core] == 8:
50+
# Add linking time preprocessor macro DOMAIN_NS
51+
if target.core.endswith("-NS"):
52+
define_string = self.make_ld_define("DOMAIN_NS", "0x1")
53+
self.flags["ld"].append(define_string)
54+
core = target.core[:-3]
55+
else:
56+
# Create Secure library
57+
self.flags["asm"] += ["--cmse"]
58+
self.flags["common"] += ["--cmse"]
59+
secure_file = join(build_dir, "cmse_lib.o")
60+
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
61+
62+
cpu = {
63+
"Cortex-M7FD": "Cortex-M7.fp.dp",
64+
"Cortex-M7F": "Cortex-M7.fp.sp",
65+
"Cortex-M33": "Cortex-M33.no_dsp",
66+
"Cortex-M33F": "Cortex-M33.fp.no_dsp",
67+
"Cortex-M33FD": "Cortex-M33.fp"}.get(core, core)
5968

6069
# flags_cmd are used only by our scripts, the project files have them already defined,
6170
# using this flags results in the errors (duplication)
6271
# asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core
63-
asm_flags_cmd = ["--cpu", cpuchoice]
72+
asm_flags_cmd = ["--cpu", cpu]
6473
# custom c flags
65-
c_flags_cmd = ["--cpu", cpuchoice]
74+
c_flags_cmd = ["--cpu", cpu]
6675

6776
c_flags_cmd.extend([
6877
"--thumb", "--dlib_config", "DLib_Config_Full.h"
@@ -71,22 +80,6 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
7180
cxx_flags_cmd = [
7281
"--c++", "--no_rtti", "--no_exceptions"
7382
]
74-
if target.core == "Cortex-M7FD":
75-
asm_flags_cmd += ["--fpu", "VFPv5"]
76-
c_flags_cmd.append("--fpu=VFPv5")
77-
elif target.core == "Cortex-M7F":
78-
asm_flags_cmd += ["--fpu", "VFPv5_sp"]
79-
c_flags_cmd.append("--fpu=VFPv5_sp")
80-
elif target.core.startswith("Cortex-M33F"):
81-
asm_flags_cmd += ["--fpu", "VFPv5_sp"]
82-
c_flags_cmd.append("--fpu=VFPv5_sp")
83-
84-
# Create Secure library
85-
if CORE_ARCH[target.core] == 8 and not target.core.endswith("-NS"):
86-
self.flags["asm"] += ["--cmse"]
87-
self.flags["common"] += ["--cmse"]
88-
secure_file = join(build_dir, "cmse_lib.o")
89-
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
9083

9184
IAR_BIN = join(TOOLCHAIN_PATHS['IAR'], "bin")
9285
main_cc = join(IAR_BIN, "iccarm")

0 commit comments

Comments
 (0)