Skip to content

Commit 8fca917

Browse files
committed
scripts: build: mergehex: Add --output-bin parameter
The optional --output-bin parameter instructs the IntexHex class to save the content as a binary instead intelhex format. Signed-off-by: BUDKE Gerson Fernando <[email protected]>
1 parent ab5e2d0 commit 8fca917

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/build/mergehex.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import argparse
1414

1515

16-
def merge_hex_files(output, input_hex_files, overlap):
16+
def merge_hex_files(output, input_hex_files, overlap, output_bin):
1717
ih = IntelHex()
1818

1919
for hex_file_path in input_hex_files:
@@ -29,7 +29,8 @@ def merge_hex_files(output, input_hex_files, overlap):
2929
except AddressOverlapError:
3030
raise AddressOverlapError("{} has merge issues".format(hex_file_path))
3131

32-
ih.write_hex_file(output)
32+
format = "bin" if output_bin else "hex"
33+
ih.tofile(output, format)
3334

3435

3536
def parse_args():
@@ -42,14 +43,16 @@ def parse_args():
4243
parser.add_argument("--overlap", default="error",
4344
help="What to do when files overlap (error, ignore, replace). "
4445
"See IntelHex.merge() for more info.")
46+
parser.add_argument("--output-bin", default=False,
47+
help="Save the merged content as binary file.")
4548
parser.add_argument("input_files", nargs='*')
4649
return parser.parse_args()
4750

4851

4952
def main():
5053
args = parse_args()
5154

52-
merge_hex_files(args.output, args.input_files, args.overlap)
55+
merge_hex_files(args.output, args.input_files, args.overlap, args.output_bin)
5356

5457

5558
if __name__ == "__main__":

0 commit comments

Comments
 (0)