From ddf5060ef923f929f3673f9fc542e0824c5fb61d Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Wed, 23 Jan 2019 10:09:21 -0600 Subject: [PATCH] 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) --- tools/toolchains/iar.py | 53 ++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index 11d88a1c2a..c749bde5ac 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -44,25 +44,34 @@ class IAR(mbedToolchain): def __init__(self, target, notify=None, macros=None, build_profile=None, build_dir=None): - mbedToolchain.__init__(self, target, notify, macros, build_dir=build_dir, - build_profile=build_profile) - if target.core == "Cortex-M7F" or target.core == "Cortex-M7FD": - cpuchoice = "Cortex-M7" - elif target.core.startswith("Cortex-M33FD"): - cpuchoice = "Cortex-M33" - elif target.core.startswith("Cortex-M33"): - cpuchoice = "Cortex-M33.no_dsp" - elif target.core.startswith("Cortex-M23"): - cpuchoice = "Cortex-M23" - else: - cpuchoice = target.core + mbedToolchain.__init__(self, target, notify, macros, build_dir=build_dir,build_profile=build_profile) + core = target.core + if CORE_ARCH[target.core] == 8: + # Add linking time preprocessor macro DOMAIN_NS + if target.core.endswith("-NS"): + define_string = self.make_ld_define("DOMAIN_NS", "0x1") + self.flags["ld"].append(define_string) + core = target.core[:-3] + else: + # Create Secure library + self.flags["asm"] += ["--cmse"] + self.flags["common"] += ["--cmse"] + secure_file = join(build_dir, "cmse_lib.o") + self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file] + + cpu = { + "Cortex-M7FD": "Cortex-M7.fp.dp", + "Cortex-M7F": "Cortex-M7.fp.sp", + "Cortex-M33": "Cortex-M33.no_dsp", + "Cortex-M33F": "Cortex-M33.fp.no_dsp", + "Cortex-M33FD": "Cortex-M33.fp"}.get(core, core) # flags_cmd are used only by our scripts, the project files have them already defined, # using this flags results in the errors (duplication) # asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core - asm_flags_cmd = ["--cpu", cpuchoice] + asm_flags_cmd = ["--cpu", cpu] # custom c flags - c_flags_cmd = ["--cpu", cpuchoice] + c_flags_cmd = ["--cpu", cpu] c_flags_cmd.extend([ "--thumb", "--dlib_config", "DLib_Config_Full.h" @@ -71,22 +80,6 @@ class IAR(mbedToolchain): cxx_flags_cmd = [ "--c++", "--no_rtti", "--no_exceptions" ] - if target.core == "Cortex-M7FD": - asm_flags_cmd += ["--fpu", "VFPv5"] - c_flags_cmd.append("--fpu=VFPv5") - elif target.core == "Cortex-M7F": - asm_flags_cmd += ["--fpu", "VFPv5_sp"] - c_flags_cmd.append("--fpu=VFPv5_sp") - elif target.core.startswith("Cortex-M33F"): - asm_flags_cmd += ["--fpu", "VFPv5_sp"] - c_flags_cmd.append("--fpu=VFPv5_sp") - - # Create Secure library - if CORE_ARCH[target.core] == 8 and not target.core.endswith("-NS"): - self.flags["asm"] += ["--cmse"] - self.flags["common"] += ["--cmse"] - secure_file = join(build_dir, "cmse_lib.o") - self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file] IAR_BIN = join(TOOLCHAIN_PATHS['IAR'], "bin") main_cc = join(IAR_BIN, "iccarm")