mirror of https://github.com/ARMmbed/mbed-os.git
tools: process bootloader chunks
NRF Softdevice hex file can be in chunks. Make sure we account for the space where the bootloader resides by including all the chunks within the end of rom marker. This will clearly mark out the initial bootloader region.pull/8097/head
parent
fac5ff45ed
commit
2da8950b2a
|
@ -401,6 +401,11 @@ def _fill_header(region_list, current_region):
|
|||
start += Config.header_member_size(member)
|
||||
return header
|
||||
|
||||
def _end_addr_inclusive(addr):
|
||||
if addr is not None:
|
||||
return addr + 1
|
||||
return addr
|
||||
|
||||
def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
|
||||
"""Merge the region_list into a single image
|
||||
|
||||
|
@ -429,12 +434,15 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
|
|||
# make same assumption as in region builder; first segment must fit.
|
||||
# this is only to get a neat ToolException anyway, since IntelHex.merge will
|
||||
# throw intelhex.AddressOverlapError if there's overlapping
|
||||
part_size = part.segments()[0][1] - part.segments()[0][0]
|
||||
part_size = 0
|
||||
for es in part.segments():
|
||||
part_size += es[1] - es[0]
|
||||
merged.merge(part[es[0]:_end_addr_inclusive(es[1])])
|
||||
|
||||
if part_size > region.size:
|
||||
raise ToolException("Contents of region %s does not fit"
|
||||
% region.name)
|
||||
merged.merge(part)
|
||||
|
||||
pad_size = region.size - part_size
|
||||
if pad_size > 0 and region != region_list[-1] and format != ".hex":
|
||||
notify.info(" Padding region %s with 0x%x bytes" %
|
||||
|
|
|
@ -711,9 +711,17 @@ class Config(object):
|
|||
raise ConfigException("bootloader executable does not "
|
||||
"start at 0x%x" % rom_start)
|
||||
|
||||
# segments returns start address and 'next after end' address
|
||||
part_size = part.segments()[0][1] - part.segments()[0][0]
|
||||
part_size = Config._align_ceiling(rom_start + part_size, self.sectors) - rom_start
|
||||
# find the last valid address that's within rom_end and use that
|
||||
# to compute the bootloader size
|
||||
end_address = None
|
||||
for each in part.segments():
|
||||
if (each[1] < rom_end):
|
||||
end_address = each[1]
|
||||
else:
|
||||
break
|
||||
if end_address == None:
|
||||
raise ConfigException("bootloader segments don't fit within rom region")
|
||||
part_size = Config._align_ceiling(rom_start + (end_address - start), self.sectors) - rom_start
|
||||
|
||||
yield Region("bootloader", rom_start, part_size, False,
|
||||
filename)
|
||||
|
|
Loading…
Reference in New Issue