Skip to content

Commit 38ce7b1

Browse files
Naveen KajeNaveen Kaje
authored andcommitted
tools: fix up build_api padding logic and clean up unused code
Patch from the end of the first segment. Remove unused code.
1 parent 858a7a8 commit 38ce7b1

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

tools/build_api.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,6 @@ def _fill_header(region_list, current_region):
401401
start += Config.header_member_size(member)
402402
return header
403403

404-
def _end_addr_inclusive(addr):
405-
if addr is not None:
406-
return addr + 1
407-
return addr
408404

409405
def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
410406
"""Merge the region_list into a single image
@@ -430,24 +426,14 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
430426
notify.info(" Filling region %s with %s" % (region.name, region.filename))
431427
part = intelhex_offset(region.filename, offset=region.start)
432428
part.start_addr = None
433-
434-
# make same assumption as in region builder; first segment must fit.
435-
# this is only to get a neat ToolException anyway, since IntelHex.merge will
436-
# throw IntelHex.AddressOverlapError if there's overlapping
437-
part_size = 0
438-
for start, stop in part.segments():
439-
part_size += stop - start
440429
merged.merge(part)
441430

442-
if part_size > region.size:
443-
raise ToolException("Contents of region %s does not fit"
444-
% region.name)
445-
446431
# Hex file can have gaps, so no padding needed. While other formats may
447432
# need padding. Iterate through segments and pad the gaps.
448433
if format != ".hex":
449-
begin = 0
450-
for start, stop in merged.segments():
434+
# begin patching from the end of the first segment
435+
_, begin = merged.segments()[0]
436+
for start, stop in merged.segments()[1:]:
451437
pad_size = start - begin
452438
merged.puts(begin, padding * pad_size)
453439
begin = stop + 1

0 commit comments

Comments
 (0)