mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'master' of https://github.com/tkuyucu/mbed
commit
7ce4ec4820
|
@ -306,6 +306,8 @@ class LPC11U35_401(Target):
|
||||||
class nRF51822(Target):
|
class nRF51822(Target):
|
||||||
|
|
||||||
EXPECTED_SOFTDEVICE = 's110_nrf51822_6.0.0_softdevice.hex'
|
EXPECTED_SOFTDEVICE = 's110_nrf51822_6.0.0_softdevice.hex'
|
||||||
|
UICR_START = 0x10001000
|
||||||
|
APPCODE_OFFSET = 0x14000
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Target.__init__(self)
|
Target.__init__(self)
|
||||||
|
@ -327,15 +329,46 @@ class nRF51822(Target):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
# Generate hex file
|
||||||
|
# NOTE: this is temporary, it will be removed later and only the
|
||||||
|
# combined binary file (below) will be used
|
||||||
from intelhex import IntelHex
|
from intelhex import IntelHex
|
||||||
binh = IntelHex()
|
binh = IntelHex()
|
||||||
binh.loadbin(binf, offset = 0x14000)
|
binh.loadbin(binf, offset = nRF51822.APPCODE_OFFSET)
|
||||||
sdh = IntelHex(hexf)
|
sdh = IntelHex(hexf)
|
||||||
sdh.merge(binh)
|
sdh.merge(binh)
|
||||||
outname = binf.replace(".bin", ".hex")
|
outname = binf.replace(".bin", ".hex")
|
||||||
with open(outname, "w") as f:
|
with open(outname, "w") as f:
|
||||||
sdh.tofile(f, format = 'hex')
|
sdh.tofile(f, format = 'hex')
|
||||||
t_self.debug("Generated SoftDevice-enabled image in '%s'" % outname)
|
t_self.debug("Generated SoftDevice-enabled image in '%s'" % outname)
|
||||||
|
# Generate concatenated SoftDevice + application binary
|
||||||
|
# Currently, this is only supported for SoftDevice images that have
|
||||||
|
# an UICR area
|
||||||
|
sdh = IntelHex(hexf)
|
||||||
|
if sdh.maxaddr() < nRF51822.UICR_START:
|
||||||
|
t_self.error("SoftDevice image does not have UICR area, aborting")
|
||||||
|
return
|
||||||
|
addrlist = sdh.addresses()
|
||||||
|
try:
|
||||||
|
uicr_start_index = addrlist.index(nRF51822.UICR_START)
|
||||||
|
except ValueError:
|
||||||
|
t_self.error("UICR start address not found in the SoftDevice image, aborting")
|
||||||
|
return
|
||||||
|
# Assume that everything up to uicr_start_index are contiguous addresses
|
||||||
|
# in the SoftDevice code area
|
||||||
|
softdevice_code_size = addrlist[uicr_start_index - 1] + 1
|
||||||
|
t_self.debug("SoftDevice code size is %d bytes" % softdevice_code_size)
|
||||||
|
# First part: SoftDevice code
|
||||||
|
bindata = sdh[:softdevice_code_size].tobinstr()
|
||||||
|
# Second part: pad with 0xFF up to APPCODE_OFFSET
|
||||||
|
bindata = bindata + '\xFF' * (nRF51822.APPCODE_OFFSET - softdevice_code_size)
|
||||||
|
# Last part: the application code
|
||||||
|
with open(binf, 'r+b') as f:
|
||||||
|
bindata = bindata + f.read()
|
||||||
|
# Write back the binary
|
||||||
|
f.seek(0)
|
||||||
|
f.write(bindata)
|
||||||
|
t_self.debug("Generated concatenated binary of %d bytes" % len(bindata))
|
||||||
|
|
||||||
# Get a single instance for each target
|
# Get a single instance for each target
|
||||||
TARGETS = [
|
TARGETS = [
|
||||||
|
|
Loading…
Reference in New Issue