From: Luke Kenneth Casson Leighton Date: Mon, 4 Apr 2022 17:14:46 +0000 (+0100) Subject: write out firmware to correct location, X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6823b6ca4d21722a00df756a479249d3cd375934;p=ls2.git write out firmware to correct location, adapt to 64/32 bit output --- diff --git a/runsimsoc_hyperram.sh b/runsimsoc_hyperram.sh index 0fc1fe1..f9ed794 100755 --- a/runsimsoc_hyperram.sh +++ b/runsimsoc_hyperram.sh @@ -10,7 +10,7 @@ QSPI_DIR=./qspi_model/Cy15b104qs/model/ FIRMWARE=./coldboot/coldboot.bin # convert firmware to 32-bit hex -python3 scripts/bin2hex.py ${FIRMWARE} 32 > ${QSPI_DIR}/firmware.hex +python3 scripts/bin2hex.py ${FIRMWARE} 32 > firmware.hex # create the build_simsoc/top.il file with firmware baked-in python3 src/ls2.py isim ./coldboot/coldboot.bin diff --git a/scripts/bin2hex.py b/scripts/bin2hex.py new file mode 100755 index 0000000..09e3a14 --- /dev/null +++ b/scripts/bin2hex.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import sys +import subprocess +import struct + +if len(sys.argv) == 3: + wordlen = int(sys.argv[2]) // 8 +else: + wordlen = 8 + +with open(sys.argv[1], "rb") as f: + while True: + word = f.read(wordlen) + if len(word) == 8: + print("%016x" % struct.unpack('