aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/makehex.py
blob: 1735d860284ed000e8c45b56fb85f0e1e9a7f499 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python3
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.

from sys import argv

with open(argv[1], "rb") as f:
    bindata = f.read()

assert len(bindata) < 60*1024
assert len(bindata) % 4 == 0

for i in range(64*1024//4):
    if i < len(bindata) // 4:
        w = bindata[4*i : 4*i+4]
        print("%02x%02x%02x%02x" % (w[3], w[2], w[1], w[0]))
    else:
        print("0")