Skip to content

Commit 281fcc7

Browse files
committed
Add 8.3 naming support for ST HDK limitations
1 parent bbbd869 commit 281fcc7

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

workspace_tools/targets.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ def __init__(self):
271271

272272
self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
273273

274+
self.binary_naming = "8.3"
275+
274276

275277
class NUCLEO_L152RE(Target):
276278
def __init__(self):
@@ -281,6 +283,8 @@ def __init__(self):
281283
self.extra_labels = ['STM', 'STM32L1', 'STM32L152RE']
282284

283285
self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
286+
287+
self.binary_naming = "8.3"
284288

285289

286290
class NUCLEO_F401RE(Target):
@@ -292,6 +296,8 @@ def __init__(self):
292296
self.extra_labels = ['STM', 'STM32F4', 'STM32F401RE']
293297

294298
self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
299+
300+
self.binary_naming = "8.3"
295301

296302

297303
class NUCLEO_F030R8(Target):
@@ -303,6 +309,8 @@ def __init__(self):
303309
self.extra_labels = ['STM', 'STM32F0', 'STM32F030R8']
304310

305311
self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
312+
313+
self.binary_naming = "8.3"
306314

307315

308316
class MBED_MCU(Target):

workspace_tools/toolchains/__init__.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,24 +426,38 @@ def build_library(self, objects, dir, name):
426426
self.archive(objects, fout)
427427

428428
def link_program(self, r, tmp_path, name):
429+
if hasattr(self.target, 'binary_format'):
430+
ext = self.target.binary_format
431+
else:
432+
ext = 'bin'
433+
434+
if hasattr(self.target, 'binary_naming'):
435+
if self.target.binary_naming == "8.3":
436+
name = name[0:8]
437+
ext = ext[0:3]
438+
439+
filename = name+'.'+ext
440+
429441
elf = join(tmp_path, name + '.elf')
430-
bin = join(tmp_path, name + '.bin')
442+
bin = join(tmp_path, filename)
431443

432444
if self.need_update(elf, r.objects + r.libraries + [r.linker_script]):
433445
self.progress("link", name)
434446
self.link(elf, r.objects, r.libraries, r.lib_dirs, r.linker_script)
435-
447+
436448
if self.need_update(bin, [elf]):
437449
self.progress("elf2bin", name)
438450
self.binary(elf, bin)
439451

440452
if self.target.name.startswith('LPC'):
441-
self.debug("LPC Patch %s" % (name + '.bin'))
453+
self.debug("LPC Patch %s" % filename)
442454
patch(bin)
443455

444456
self.var("compile_succeded", True)
445-
self.var("binary", name+'.bin')
446-
457+
self.var("binary", filename)
458+
if hasattr(self.target, 'binary_naming'):
459+
self.var("binary_naming", self.target.binary_naming)
460+
447461
return bin
448462

449463
def default_cmd(self, command):

workspace_tools/toolchains/arm.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,27 @@ def archive(self, objects, lib_path):
114114
self.default_cmd([self.ar, '-r', lib_path] + objects)
115115

116116
def link(self, output, objects, libraries, lib_dirs, mem_map):
117-
args = ["-o", output, "--userlibpath", ",".join(lib_dirs), "--info=totals", "--list=.link_totals.txt"]
117+
if len(lib_dirs):
118+
args = ["-o", output, "--userlibpath", ",".join(lib_dirs), "--info=totals", "--list=.link_totals.txt"]
119+
else:
120+
args = ["-o", output, "--info=totals", "--list=.link_totals.txt"]
121+
118122
if mem_map:
119123
args.extend(["--scatter", mem_map])
120-
121-
self.default_cmd(self.hook.get_cmdline_linker(self.ld + args + objects + libraries + self.sys_libs))
124+
125+
if hasattr(self.target, "link_cmdline_hook"):
126+
args = self.target.link_cmdline_hook(self.__class__.__name__, args)
127+
128+
self.default_cmd(self.ld + args + objects + libraries + self.sys_libs)
122129

123130
@hook_tool
124131
def binary(self, elf, bin):
125-
self.default_cmd(self.hook.get_cmdline_binary([self.elf2bin, '--bin', '-o', bin, elf]))
132+
args = [self.elf2bin, '--bin', '-o', bin, elf]
133+
134+
if hasattr(self.target, "binary_cmdline_hook"):
135+
args = self.target.binary_cmdline_hook(self.__class__.__name__, args)
126136

137+
self.default_cmd(args)
127138

128139
class ARM_STD(ARM):
129140
def __init__(self, target, options=None, notify=None, macros=None):

0 commit comments

Comments
 (0)