Skip to content

Instantly share code, notes, and snippets.

@xobs
Created April 5, 2019 11:10
Show Gist options
  • Save xobs/410328e964f78d37979e8f483e8310e1 to your computer and use it in GitHub Desktop.
Save xobs/410328e964f78d37979e8f483e8310e1 to your computer and use it in GitHub Desktop.
Contents of matching rom
fomu@fomu-dev:~/patch-rom $ cat make-multi.sh
#!/bin/sh
icepack -u /home/fomu/top.bin > top.txt
./convert-to-hex.py
icebram random.hex foboot.hex < top.txt > top-patched.txt
icepack -s < top-patched.txt > top-patched.bin
cp multiboot.bin top-multi.bin
cat top-patched.bin >> top-multi.bin
fomu@fomu-dev:~/patch-rom $ cat convert-to-hex.py
#!/usr/bin/env python3
def swap32(d):
d = list(d)
while len(d) < 4:
d.append(0)
t = d[0]
d[0] = d[3]
d[3] = t
t = d[1]
d[1] = d[2]
d[2] = t
return bytes(d)
with open("/home/fomu/foboot.bin", "rb") as inp:
with open("foboot.hex", "w", newline="\n") as outp:
while True:
d = inp.read(4)
if len(d) == 0:
break
print(swap32(d).hex(), file=outp)
fomu@fomu-dev:~/patch-rom $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment