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.
pull/3994/head
Jimmy Brisson 2017-03-23 15:05:22 -05:00
parent 09afe23762
commit 74998d649a
1 changed files with 8 additions and 7 deletions

View File

@ -386,12 +386,9 @@ class TEENSY3_1Code(object):
@staticmethod
def binary_hook(t_self, resources, elf, binf):
"""Hook that is run after elf is generated"""
from intelhex import IntelHex
binh = IntelHex()
binh.loadbin(binf, offset=0)
with open(binf.replace(".bin", ".hex"), "w") as file_desc:
binh.tofile(file_desc, format='hex')
# This function is referenced by old versions of targets.json and should
# be kept for backwards compatibility.
pass
class MTSCode(object):
"""Generic MTS code"""
@ -475,7 +472,11 @@ class MCU_NRF51Code(object):
# Merge user code with softdevice
from intelhex import IntelHex
binh = IntelHex()
binh.loadbin(binf, offset=softdevice_and_offset_entry['offset'])
_, ext = os.path.splitext(binf)
if ext == ".hex":
binh.loadhex(binf)
elif ext == ".bin":
binh.loadbin(binf, softdevice_and_offset_entry['offset'])
if t_self.target.MERGE_SOFT_DEVICE is True:
t_self.debug("Merge SoftDevice file %s"