From 79d2e31cffa507c18a11cffd6a0b0d3dcd39913a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20R=C3=B8nningstad?= Date: Wed, 15 May 2019 10:33:09 +0200 Subject: [PATCH] scripts: mergehex: Add --overlap argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allows specifying the 'overlap' argument in IntelHex::merge(). This is identical to the --overlap argument in hexmerge.py, which is bundled with IntelHex. Signed-off-by: Øyvind Rønningstad --- scripts/mergehex.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/mergehex.py b/scripts/mergehex.py index bf23cb2ce7..8dcc7d911e 100644 --- a/scripts/mergehex.py +++ b/scripts/mergehex.py @@ -13,7 +13,7 @@ from intelhex import AddressOverlapError import argparse -def merge_hex_files(output, input_hex_files): +def merge_hex_files(output, input_hex_files, overlap): ih = IntelHex() for hex_file_path in input_hex_files: @@ -25,7 +25,7 @@ def merge_hex_files(output, input_hex_files): to_merge.start_addr = None try: - ih.merge(to_merge) + ih.merge(to_merge, overlap=overlap) except AddressOverlapError: raise AddressOverlapError("{} has merge issues".format(hex_file_path)) @@ -41,6 +41,9 @@ def parse_args(): parser.add_argument("-o", "--output", required=False, default="merged.hex", type=argparse.FileType('w', encoding='UTF-8'), help="Output file name.") + parser.add_argument("--overlap", default="error", + help="What to do when files overlap (error, ignore, replace). " + "See IntelHex.merge() for more info.") parser.add_argument("input_files", nargs='*') return parser.parse_args() @@ -48,7 +51,7 @@ def parse_args(): def main(): args = parse_args() - merge_hex_files(args.output, args.input_files) + merge_hex_files(args.output, args.input_files, args.overlap) if __name__ == "__main__":