Skip to content

Commit 74998d6

Browse files
committed
Change target hooks to use correct input format
The input format is now determined by the OUTPUT_EXT key in targets.json, and defaults to "bin" when not specified. This changes the Teensy3_1 and the NRF51x targets' post bulid hooks. Teensy3_1 just converted to intelhex, so we do nothing instead. NRF51x assumed that it was taking in a bin format file. I made it detect file type by extension.
1 parent 09afe23 commit 74998d6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tools/targets/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,9 @@ class TEENSY3_1Code(object):
386386
@staticmethod
387387
def binary_hook(t_self, resources, elf, binf):
388388
"""Hook that is run after elf is generated"""
389-
from intelhex import IntelHex
390-
binh = IntelHex()
391-
binh.loadbin(binf, offset=0)
392-
393-
with open(binf.replace(".bin", ".hex"), "w") as file_desc:
394-
binh.tofile(file_desc, format='hex')
389+
# This function is referenced by old versions of targets.json and should
390+
# be kept for backwards compatibility.
391+
pass
395392

396393
class MTSCode(object):
397394
"""Generic MTS code"""
@@ -475,7 +472,11 @@ def binary_hook(t_self, resources, _, binf):
475472
# Merge user code with softdevice
476473
from intelhex import IntelHex
477474
binh = IntelHex()
478-
binh.loadbin(binf, offset=softdevice_and_offset_entry['offset'])
475+
_, ext = os.path.splitext(binf)
476+
if ext == ".hex":
477+
binh.loadhex(binf)
478+
elif ext == ".bin":
479+
binh.loadbin(binf, softdevice_and_offset_entry['offset'])
479480

480481
if t_self.target.MERGE_SOFT_DEVICE is True:
481482
t_self.debug("Merge SoftDevice file %s"

0 commit comments

Comments
 (0)