dsp: add bootloader

It works!!
This commit is contained in:
Paul Mathieu
2021-04-17 23:13:20 -07:00
parent a864ca3d7e
commit c12c28fb44
5 changed files with 133 additions and 2 deletions

46
dsp/prog.py Normal file
View File

@@ -0,0 +1,46 @@
import serial
import struct
import sys
offset = 0x1100
tty = 'tty'
baud = 1000000
def write(s, offset, dat):
for i in range(0, len(dat), 128):
chunk = dat[i: i + 128]
cmd = struct.pack('>cHB', b'c', offset + i, len(chunk))
print(f'Sending {len(chunk)} bytes @0x{offset + i:04x}')
s.write(cmd)
s.write(chunk)
ack = s.read(2)
if len(ack) < 2:
raise RuntimeError(f'timeout waiting for full ack. got {ack}')
if ack[0] != b'a'[0]:
raise RuntimeError(f'expected ack, got this instead: {ack}')
print(f'Ack! len={ack[1]}')
def jump(s, offset):
addr = struct.pack('>H', offset)
s.write(b'j')
s.write(addr)
def main():
binfile = sys.argv[1]
with open(binfile, 'rb') as f:
dat = f.read()
s = serial.Serial(tty, baud, timeout=1)
write(s, offset, dat)
jump(s, offset)
if __name__ == "__main__":
main()