Skip to content

Commit 907c517

Browse files
author
deepikabhavnani
committed
Use core arch for setting secure/non-secure flags
1 parent daefce6 commit 907c517

File tree

2 files changed

+27
-35
lines changed

2 files changed

+27
-35
lines changed

tools/toolchains/arm.py

Lines changed: 16 additions & 21 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
@@ -416,27 +417,21 @@ def __init__(self, target, *args, **kwargs):
416417
self.flags['common'].append("-mfpu=fpv5-sp-d16")
417418
self.flags['common'].append("-mfloat-abi=hard")
418419

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)
420+
if CORE_ARCH[target.core] == 8:
421+
# Add linking time preprocessor macro DOMAIN_NS
422+
if target.core.endswith("-NS"):
423+
define_string = self.make_ld_define("DOMAIN_NS", "0x1")
424+
self.flags["ld"].append(define_string)
425+
else:
426+
# Add secure build flag
427+
self.flags['cxx'].append("-mcmse")
428+
self.flags['c'].append("-mcmse")
429+
430+
if (not target.core.endswith("-NS")) and kwargs.get('build_dir', False):
431+
# Create Secure library
432+
build_dir = kwargs['build_dir']
433+
secure_file = join(build_dir, "cmse_lib.o")
434+
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
440435

441436
asm_cpu = {
442437
"Cortex-M0+": "Cortex-M0",

tools/toolchains/gcc.py

Lines changed: 11 additions & 14 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
@@ -94,20 +95,16 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
9495
self.cpu.append("-mfloat-abi=hard")
9596
self.cpu.append("-mno-unaligned-access")
9697

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")
98+
if CORE_ARCH[target.core] == 8:
99+
# Add linking time preprocessor macro DOMAIN_NS
100+
if target.core.endswith("-NS"):
101+
self.flags["ld"].append("-DDOMAIN_NS=1")
102+
else:
103+
self.cpu.append("-mcmse")
104+
self.flags["ld"].extend([
105+
"-Wl,--cmse-implib",
106+
"-Wl,--out-implib=%s" % join(build_dir, "cmse_lib.o")
107+
])
111108

112109
self.flags["common"] += self.cpu
113110

0 commit comments

Comments
 (0)