Skip to content

Instantly share code, notes, and snippets.

@uyjulian
Created September 8, 2025 23:46
Show Gist options
  • Save uyjulian/3009f031cf15b46e466e83882cf833a3 to your computer and use it in GitHub Desktop.
Save uyjulian/3009f031cf15b46e466e83882cf833a3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# This script will extract the PEF NDRV from 1S2_512.ROM
# as posted here:
# https://68kmla.org/bb/index.php?threads/silicon-image-sil3112-flashing-easier-way-using-flashrom.7013/
a = []
d = b""
with open("1S2_512.ROM", "rb") as f:
f.seek(0x2922)
while True:
cmd = int.from_bytes(f.read(1), byteorder="little")
if cmd == 0x12: # delimit ""
d = f.read(int.from_bytes(f.read(1), byteorder="little"))
elif cmd == 0x01:
cmd2 = int.from_bytes(f.read(1), byteorder="little")
if cmd2 == 0x15: # encode-bytes
a.append(d)
elif cmd2 == 0x12: # encode+
pass
elif cmd2 == 0x10: # property
break
else:
raise Exception("?")
elif cmd == 0x15: # ???
pass
else:
raise Exception("?")
with open("out.ndrv", "wb") as f:
f.write(b"".join(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment