7 def insert_crc(i_filename
, fbi_mode
=False, o_filename
=None):
9 o_filename
= i_filename
11 with
open(i_filename
, "rb") as f
:
13 fcrc
= binascii
.crc32(fdata
).to_bytes(4, byteorder
="big")
14 flength
= len(fdata
).to_bytes(4, byteorder
="big")
16 with
open(o_filename
, "wb") as f
:
27 parser
= argparse
.ArgumentParser(description
="CRC32 computation tool and MiSoC image file writer.")
28 parser
.add_argument("input", help="input file")
29 parser
.add_argument("-o", "--output", default
=None, help="output file (if not specified, use input file)")
30 parser
.add_argument("-f", "--fbi", default
=False, action
="store_true", help="build flash boot image (FBI) file")
31 args
= parser
.parse_args()
32 insert_crc(args
.input, args
.fbi
, args
.output
)
35 if __name__
== "__main__":