blob: 8bf9841d82d132093cc16e9b122b0d7c2e934162 [file] [log] [blame]
#!/usr/bin/env python3
# Copyright (c) 2022, Linaro
# SPDX-License-Identifier: Apache-2.0
Split a hex file signed by imagetool into its binary/image and
its header. This is needed to be able to pack these two parts
into the sample separately, saving flash space.
import argparse
from intelhex import IntelHex
def dump_header(infile, image, header):
inhex = IntelHex(infile)
(start, end) = inhex.segments()[0]
inhex.tobinfile(image, start=start, end=end-1)
(start, end) = inhex.segments()[-1]
inhex.tobinfile(header, start=start, end=end-1)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
args = parser.parse_args()
dump_header(args.input, args.image, args.header)