Merge pull request #406 from 0xc0170/dev_target_fix

[tools] Fixed iterating through the available hex files
pull/407/head
Martin Kojtal 2014-07-17 15:15:45 +02:00
commit 4fe0feaf41
1 changed files with 5 additions and 0 deletions

View File

@ -431,14 +431,19 @@ class NRF51822(Target):
@staticmethod
def binary_hook(t_self, resources, elf, binf):
for hexf in resources.hex_files:
found = False
for softdeviceAndOffsetEntry in NRF51822.EXPECTED_SOFTDEVICES_WITH_OFFSETS:
if hexf.find(softdeviceAndOffsetEntry['name']) != -1:
found = True
break
if found:
break
else:
t_self.debug("Hex file not found. Aborting.")
return
# Merge user code with softdevice
t_self.debug("Patching Hex file %s" % softdeviceAndOffsetEntry['name'])
from intelhex import IntelHex
binh = IntelHex()
binh.loadbin(binf, offset=softdeviceAndOffsetEntry['offset'])