mergehex: Improve the error feedback when merged hex files overlap

When merging hex files, and there is an overlap between the hex files,
display the hex file that failed to merge.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2019-01-16 14:23:40 +01:00 committed by Carles Cufí
commit 6d8d4442b0

View file

@ -8,6 +8,7 @@
# Any conflicts will result in an error being reported.
from intelhex import IntelHex
from intelhex import AddressOverlapError
import argparse
@ -18,11 +19,18 @@ def merge_hex_files(output, input_hex_files):
for hex_file_path in input_hex_files:
to_merge = IntelHex(hex_file_path)
# Since 'arm-none-eabi-objcopy' incorrectly inserts record type '03 - Start Segment Address', we need to remove
# the start_addr to avoid conflicts when merging.
# Since 'arm-none-eabi-objcopy' incorrectly inserts record
# type '03 - Start Segment Address', we need to remove the
# start_addr to avoid conflicts when merging.
to_merge.start_addr = None
ih.merge(to_merge)
try:
ih.merge(to_merge)
except AddressOverlapError as e:
raise AddressOverlapError("{} has merge issues".format(hex_file_path))
print("Merged {}".format(hex_file_path))
ih.write_hex_file(output)