diff options
author | Yann Herklotz <git@yannherklotz.com> | 2022-11-24 18:49:44 +0000 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2022-11-24 18:49:44 +0000 |
commit | 46c49262fc9910ba5ff92e76d567ed2e4446fb41 (patch) | |
tree | 5bc1955e8fbf29ea454a0db3db1eaf4955e2ca28 /picorv32/firmware/makehex.py | |
parent | 08cf3d9a31b8acbf679b3c761edc95f3d27f7e2a (diff) | |
parent | 3291d86ec38031e191ec1e7e5e8ddfa74b77cb7c (diff) | |
download | butterstick-46c49262fc9910ba5ff92e76d567ed2e4446fb41.tar.gz butterstick-46c49262fc9910ba5ff92e76d567ed2e4446fb41.zip |
Merge commit '3291d86ec38031e191ec1e7e5e8ddfa74b77cb7c' as 'picorv32'
Diffstat (limited to 'picorv32/firmware/makehex.py')
-rw-r--r-- | picorv32/firmware/makehex.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/picorv32/firmware/makehex.py b/picorv32/firmware/makehex.py new file mode 100644 index 0000000..419b378 --- /dev/null +++ b/picorv32/firmware/makehex.py @@ -0,0 +1,27 @@ +#!/usr/bin/env 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 + +binfile = argv[1] +nwords = int(argv[2]) + +with open(binfile, "rb") as f: + bindata = f.read() + +assert len(bindata) < 4*nwords +assert len(bindata) % 4 == 0 + +for i in range(nwords): + 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") + |