Skip to content

Commit e28c260

Browse files
Naveen KajeNaveen Kaje
authored andcommitted
tools: update build_api and __init__ as per review comments
1 parent 2da8950 commit e28c260

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

tools/build_api.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,14 +436,23 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
436436
# throw intelhex.AddressOverlapError if there's overlapping
437437
part_size = 0
438438
for es in part.segments():
439+
# Add padding in between segments starting from end of first segment
440+
if (len(part.segments()) > 1 and (merged.maxaddr() != None)):
441+
pad_size = es[0] - (merged.maxaddr() + 1)
442+
merged.puts(merged.maxaddr()+1, padding * pad_size)
439443
part_size += es[1] - es[0]
440444
merged.merge(part[es[0]:_end_addr_inclusive(es[1])])
441445

442446
if part_size > region.size:
443447
raise ToolException("Contents of region %s does not fit"
444448
% region.name)
445449

446-
pad_size = region.size - part_size
450+
# This padding applies for only files with one segment
451+
if (len(part.segments()) == 1):
452+
pad_size = region.size - part_size
453+
else:
454+
pad_size = 0
455+
447456
if pad_size > 0 and region != region_list[-1] and format != ".hex":
448457
notify.info(" Padding region %s with 0x%x bytes" %
449458
(region.name, pad_size))

tools/config/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,14 +714,14 @@ def _generate_bootloader_build(self, rom_start, rom_size):
714714
# find the last valid address that's within rom_end and use that
715715
# to compute the bootloader size
716716
end_address = None
717-
for each in part.segments():
718-
if (each[1] < rom_end):
719-
end_address = each[1]
717+
for start, stop in part.segments():
718+
if (stop < rom_end):
719+
end_address = stop
720720
else:
721721
break
722722
if end_address == None:
723723
raise ConfigException("bootloader segments don't fit within rom region")
724-
part_size = Config._align_ceiling(rom_start + (end_address - start), self.sectors) - rom_start
724+
part_size = Config._align_ceiling(end_address, self.sectors) - rom_start
725725

726726
yield Region("bootloader", rom_start, part_size, False,
727727
filename)

0 commit comments

Comments
 (0)