Software for the 68000 SBC I'm designing
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
923 B

import serial
import sys
import time
if (len(sys.argv) != 3):
print(f"Usage: {sys.argv[0]} port image")
print(f"Ex. {sys.argv[0]} /dev/ttyUSB0 firmware.bin")
exit(1)
ser = None
try:
ser = serial.Serial(
port=sys.argv[1],
baudrate=9600
)
except:
print("Could not open serial port")
exit(1)
ser.isOpen()
time.sleep(2)
imagefile = open(sys.argv[2], "rb")
img = imagefile.read()
imagefile.close()
print(f"Have {str(len(img))} bytes to send")
# magic hex
ser.write([0xBE, 0xEF])
ser.write(str(len(img)).encode())
ser.write([0x55]) # garbage - is thrown away
# throw away "OK\r\n" from arduino
ser.read()
ser.read()
ser.read()
ser.read()
ser.write(img)
print("Writing complete. Verifying result...")
i = 0
good = True
while i < len(img):
x = ser.read()
if ord(x) != img[i]:
print(img[i])
print(ord(x))
good = False
break
i += 1
if good:
print("Success! :)")
else:
print("Failure! :(")
ser.close()