diff options
author | Guy Hutchison <guy@dryv.io> | 2018-10-18 18:47:06 +0000 |
---|---|---|
committer | Guy Hutchison <guy@dryv.io> | 2018-10-18 18:47:06 +0000 |
commit | f47ac81c89a517a57fd3c0656cab7a4075334328 (patch) | |
tree | d61ff99f2271a3ef55245b1fda0c6556cdf34215 /scripts/romload/hex8tohex32.py | |
parent | ef386e8f177519b86579b04a1b906f4cfaa09379 (diff) | |
download | picorv32-f47ac81c89a517a57fd3c0656cab7a4075334328.tar.gz picorv32-f47ac81c89a517a57fd3c0656cab7a4075334328.zip |
Passing with custom linker file
Diffstat (limited to 'scripts/romload/hex8tohex32.py')
-rw-r--r-- | scripts/romload/hex8tohex32.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/romload/hex8tohex32.py b/scripts/romload/hex8tohex32.py new file mode 100644 index 0000000..ae44101 --- /dev/null +++ b/scripts/romload/hex8tohex32.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import fileinput +import itertools + +ptr = 0 +data = [] + +def write_data(): + if len(data) != 0: + print("@%08x" % (ptr >> 2)) + while len(data) % 4 != 0: + data.append(0) + for word_bytes in zip(*([iter(data)]*4)): + print("".join(["%02x" % b for b in reversed(word_bytes)])) + +for line in fileinput.input(): + if line.startswith("@"): + addr = int(line[1:], 16) + if addr > ptr+4: + write_data() + ptr = addr + data = [] + while ptr % 4 != 0: + data.append(0) + ptr -= 1 + else: + while ptr + len(data) < addr: + data.append(0) + else: + data += [int(tok, 16) for tok in line.split()] + +write_data() + |