Skip to content

Commit 0e24b53

Browse files
author
Rohit Grover
committed
Allow combining against one from a set of Nordic soft-devices in decreasing order of preference.
1 parent 41b8b1d commit 0e24b53

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

workspace_tools/targets.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,19 @@ def __init__(self):
400400

401401

402402
class NRF51822(Target):
403-
EXPECTED_SOFTDEVICE = 's110_nrf51822_7.0.0_softdevice.hex'
403+
# the following is a list of possible Nordic softdevices in decreasing order
404+
# of preference.
405+
EXPECTED_SOFTDEVICES_WITH_OFFSETS = [
406+
{
407+
'name' : 's110_nrf51822_7.0.0_softdevice.hex',
408+
'offset' : 0x16000
409+
},
410+
{
411+
'name' : 's110_nrf51822_6.0.0_softdevice.hex',
412+
'offset' : 0x14000
413+
}
414+
]
404415
OUTPUT_EXT = '.hex'
405-
APPCODE_OFFSET = 0x16000
406416

407417
def __init__(self):
408418
Target.__init__(self)
@@ -421,16 +431,17 @@ def init_hooks(self, hook, toolchain_name):
421431
@staticmethod
422432
def binary_hook(t_self, resources, elf, binf):
423433
for hexf in resources.hex_files:
424-
if hexf.find(NRF51822.EXPECTED_SOFTDEVICE) != -1:
425-
break
434+
for softdeviceAndOffsetEntry in NRF51822.EXPECTED_SOFTDEVICES_WITH_OFFSETS:
435+
if hexf.find(softdeviceAndOffsetEntry['name']) != -1:
436+
break
426437
else:
427438
t_self.debug("Hex file not found. Aborting.")
428439
return
429440

430441
# Merge user code with softdevice
431442
from intelhex import IntelHex
432443
binh = IntelHex()
433-
binh.loadbin(binf, offset=NRF51822.APPCODE_OFFSET)
444+
binh.loadbin(binf, offset=softdeviceAndOffsetEntry['offset'])
434445

435446
sdh = IntelHex(hexf)
436447
sdh.merge(binh)

0 commit comments

Comments
 (0)