From f760f727572245546abe4c80013e6e25582f190e Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Mon, 7 Jan 2019 15:01:56 -0600 Subject: [PATCH 1/6] Update IAR flags for Armv8M devices. Cortex-M23 / Cortex-M33 CPU settings for baseline and mainline profile (with optional floating and dsp options) updated. --- tools/toolchains/iar.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index 37c085295b..df60e72e49 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -47,10 +47,12 @@ class IAR(mbedToolchain): build_profile=build_profile) if target.core == "Cortex-M7F" or target.core == "Cortex-M7FD": cpuchoice = "Cortex-M7" - elif target.core.startswith("Cortex-M23"): - cpuchoice = "8-M.baseline" + elif target.core.startswith("Cortex-M33FD"): + cpuchoice = "Cortex-M33" elif target.core.startswith("Cortex-M33"): - cpuchoice = "8-M.mainline" + cpuchoice = "Cortex-M33.no_dsp" + elif target.core.startswith("Cortex-M23"): + cpuchoice = "Cortex-M23" else: cpuchoice = target.core @@ -74,12 +76,15 @@ class IAR(mbedToolchain): elif target.core == "Cortex-M7F": asm_flags_cmd += ["--fpu", "VFPv5_sp"] c_flags_cmd.append("--fpu=VFPv5_sp") - elif target.core == "Cortex-M23" or target.core == "Cortex-M33" or target.core == "Cortex-M33F": - self.flags["asm"] += ["--cmse"] - self.flags["common"] += ["--cmse"] + elif target.core.startswith("Cortex-M33F"): + asm_flags_cmd += ["--fpu", "VFPv5_sp"] + c_flags_cmd.append("--fpu=VFPv5_sp") # Create Secure library - if target.core == "Cortex-M23" or self.target.core == "Cortex-M33" or self.target.core == "Cortex-M33F": + if ((target.core.startswith("Cortex-M23") or target.core.startswith("Cortex-M33")) + 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] From 80f6b0e0025ea200c95b7c48b8f852f7e7479f2e Mon Sep 17 00:00:00 2001 From: Deepika Date: Tue, 8 Jan 2019 14:38:22 -0600 Subject: [PATCH 2/6] M2351: Update code to support IAR 8.x builds --- .../TARGET_M2351/device/system_M2351.h | 13 ------------- tools/export/iar/iar_definitions.json | 3 +++ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M2351/device/system_M2351.h b/targets/TARGET_NUVOTON/TARGET_M2351/device/system_M2351.h index 414aa7130e..88be5e3ba6 100644 --- a/targets/TARGET_NUVOTON/TARGET_M2351/device/system_M2351.h +++ b/targets/TARGET_NUVOTON/TARGET_M2351/device/system_M2351.h @@ -130,19 +130,6 @@ extern void SystemInit(void); extern void SystemCoreClockUpdate(void); - - -#if defined (__ICCARM__) -uint32_t __TZ_get_PSP_NS(void); -void __TZ_set_PSP_NS(uint32_t topOfProcStack); -int32_t __TZ_get_MSP_NS(void); -void __TZ_set_MSP_NS(uint32_t topOfMainStack); -uint32_t __TZ_get_PRIMASK_NS(void); -void __TZ_set_PRIMASK_NS(uint32_t priMask); -#endif - - - #ifdef __cplusplus } #endif diff --git a/tools/export/iar/iar_definitions.json b/tools/export/iar/iar_definitions.json index 13492282c0..f5e588be61 100644 --- a/tools/export/iar/iar_definitions.json +++ b/tools/export/iar/iar_definitions.json @@ -341,5 +341,8 @@ "GBECoreSlave": 39, "FPU2": 6, "GFPUCoreSlave2": 39 + }, + "M2351KIAAEES": { + "OGChipSelectEditMenu": "M2351 series\tNuvoton M2351 series" } } From 0082474ef2473e129b9d6cf8ff6ccdf62ca2bbdf Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Wed, 23 Jan 2019 09:38:22 -0600 Subject: [PATCH 3/6] Update `cmse` flag based on core_arch instead of different cores --- tools/toolchains/iar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index df60e72e49..11d88a1c2a 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -19,6 +19,7 @@ from os import remove from os.path import join, splitext, exists 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 run_cmd, NotSupportedException @@ -81,8 +82,7 @@ class IAR(mbedToolchain): c_flags_cmd.append("--fpu=VFPv5_sp") # Create Secure library - if ((target.core.startswith("Cortex-M23") or target.core.startswith("Cortex-M33")) - and not target.core.endswith("-NS")): + 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") From fdbcae3830c0c6cd141821904276bfd0eb6872e1 Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Wed, 23 Jan 2019 10:09:21 -0600 Subject: [PATCH 4/6] 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") From 6097095de4282c5b5ce7df8595db0ea981755ca9 Mon Sep 17 00:00:00 2001 From: deepikabhavnani Date: Fri, 25 Jan 2019 11:52:46 -0600 Subject: [PATCH 5/6] Set the DSP option as `E` for Cortex-M33 --- tools/toolchains/iar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index c749bde5ac..ea30f53908 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -64,7 +64,7 @@ class IAR(mbedToolchain): "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) + "Cortex-M33FE": "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) From 811152da65c6b8448bd662260035bb6188da31c7 Mon Sep 17 00:00:00 2001 From: Brian Daniels Date: Fri, 1 Feb 2019 10:38:37 -0600 Subject: [PATCH 6/6] Add missing space - coding style nit Co-Authored-By: deepikabhavnani --- tools/toolchains/iar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index ea30f53908..dd3906a162 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -44,7 +44,7 @@ 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) + 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