From 6d8d4442b0330d15e92ec1b05b7bb5c45bd48cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 16 Jan 2019 14:23:40 +0100 Subject: [PATCH] mergehex: Improve the error feedback when merged hex files overlap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/mergehex.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/mergehex.py b/scripts/mergehex.py index 119fc0f0aa3..8e06638ac72 100644 --- a/scripts/mergehex.py +++ b/scripts/mergehex.py @@ -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)