Skip to content

Commit b81c0e5

Browse files
committed
Fix build tool with ARMC6/ARMv8M
1. Add linking time preprocessor macro __DOMAIN_NS for non-secure build 2. For output .hex format, combine multiple .hex files (for multiple load regions) into one This can help for Greentea test. 3. Fix 'None' build_dir with cmse_lib.o on Greentea test
1 parent df47efc commit b81c0e5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

tools/toolchains/arm.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ def link(self, output, objects, libraries, lib_dirs, scatter_file):
233233
cmd_pre = self.ld + args
234234
cmd = self.hook.get_cmdline_linker(cmd_pre)
235235

236+
# Create Secure library
237+
if self.target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
238+
secure_file = join(dirname(output), "cmse_lib.o")
239+
cmd.extend(["--import_cmse_lib_out=%s" % secure_file])
240+
236241
if self.RESPONSE_FILES:
237242
cmd_linker = cmd[0]
238243
link_files = self.get_link_file(cmd[1:])
@@ -252,7 +257,8 @@ def archive(self, objects, lib_path):
252257
@hook_tool
253258
def binary(self, resources, elf, bin):
254259
_, fmt = splitext(bin)
255-
bin_arg = {".bin": "--bin", ".hex": "--i32"}[fmt]
260+
# On .hex format, combine multiple .hex files (for multiple load regions) into one
261+
bin_arg = {".bin": "--bin", ".hex": "--i32combined"}[fmt]
256262
cmd = [self.elf2bin, bin_arg, '-o', bin, elf]
257263
cmd = self.hook.get_cmdline_binary(cmd)
258264

@@ -357,13 +363,12 @@ def __init__(self, target, *args, **kwargs):
357363

358364
if target.core == "Cortex-M23" or target.core == "Cortex-M33":
359365
self.flags['common'].append("-mcmse")
360-
361-
# Create Secure library
362-
if target.core == "Cortex-M23" or self.target.core == "Cortex-M33":
363-
build_dir = kwargs['build_dir']
364-
secure_file = join(build_dir, "cmse_lib.o")
365-
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
366-
366+
367+
# Add linking time preprocessor macro __DOMAIN_NS
368+
if target.core == "Cortex-M23-NS" or self.target.core == "Cortex-M33-NS":
369+
define_string = self.make_ld_define("__DOMAIN_NS", 1)
370+
self.flags["ld"].append(define_string)
371+
367372
asm_cpu = {
368373
"Cortex-M0+": "Cortex-M0",
369374
"Cortex-M4F": "Cortex-M4.fp",

0 commit comments

Comments
 (0)