mirror of https://github.com/ARMmbed/mbed-os.git
tools: Update build_api padding method
Update the padding sequence so that the gaps are padded after all the regions are merged. This avoids overwriting active regions and serializes the process.pull/8097/head
parent
e28c260763
commit
bd40457f27
|
@ -433,13 +433,9 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
|
||||||
|
|
||||||
# make same assumption as in region builder; first segment must fit.
|
# make same assumption as in region builder; first segment must fit.
|
||||||
# this is only to get a neat ToolException anyway, since IntelHex.merge will
|
# this is only to get a neat ToolException anyway, since IntelHex.merge will
|
||||||
# throw intelhex.AddressOverlapError if there's overlapping
|
# throw IntelHex.AddressOverlapError if there's overlapping
|
||||||
part_size = 0
|
part_size = 0
|
||||||
for es in part.segments():
|
for es in part.segments():
|
||||||
# Add padding in between segments starting from end of first segment
|
|
||||||
if (len(part.segments()) > 1 and (merged.maxaddr() != None)):
|
|
||||||
pad_size = es[0] - (merged.maxaddr() + 1)
|
|
||||||
merged.puts(merged.maxaddr()+1, padding * pad_size)
|
|
||||||
part_size += es[1] - es[0]
|
part_size += es[1] - es[0]
|
||||||
merged.merge(part[es[0]:_end_addr_inclusive(es[1])])
|
merged.merge(part[es[0]:_end_addr_inclusive(es[1])])
|
||||||
|
|
||||||
|
@ -447,16 +443,15 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
|
||||||
raise ToolException("Contents of region %s does not fit"
|
raise ToolException("Contents of region %s does not fit"
|
||||||
% region.name)
|
% region.name)
|
||||||
|
|
||||||
# This padding applies for only files with one segment
|
# Hex file can have gaps, so no padding needed. While other formats may
|
||||||
if (len(part.segments()) == 1):
|
# need padding. Iterate through segments and pad the gaps.
|
||||||
pad_size = region.size - part_size
|
if (format != ".hex"):
|
||||||
else:
|
begin = 0
|
||||||
pad_size = 0
|
for es in merged.segments():
|
||||||
|
if (begin < es[0]):
|
||||||
if pad_size > 0 and region != region_list[-1] and format != ".hex":
|
pad_size = es[0] - begin
|
||||||
notify.info(" Padding region %s with 0x%x bytes" %
|
merged.puts(begin, padding * pad_size)
|
||||||
(region.name, pad_size))
|
begin = es[1] + 1
|
||||||
merged.puts(merged.maxaddr() + 1, padding * pad_size)
|
|
||||||
|
|
||||||
if not exists(dirname(destination)):
|
if not exists(dirname(destination)):
|
||||||
makedirs(dirname(destination))
|
makedirs(dirname(destination))
|
||||||
|
|
Loading…
Reference in New Issue