Skip to content

Instantly share code, notes, and snippets.

@jpenalbae
Last active November 6, 2017 07:26
Show Gist options
  • Save jpenalbae/15cdfdf5eefa7e7cbc8afba9b7aa89b1 to your computer and use it in GitHub Desktop.
Save jpenalbae/15cdfdf5eefa7e7cbc8afba9b7aa89b1 to your computer and use it in GitHub Desktop.
Programmer for blackice
#!/usr/bin/python
import sys
import serial
def send_data(devname, filename):
wrote = 0
try:
port = serial.Serial(devname)
bstream = open(filename, 'r')
while True:
data = bstream.read(1024)
if data == '':
break
wrote += port.write(data)
except Exception as e:
print 'Error uploading bitstream'
print e
sys.exit(1)
print 'Wrote %d bytes' % wrote
if len(sys.argv) != 3:
print 'Usage: %s serial_device bitstream_file' % sys.argv[0]
sys.exit(1)
send_data(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment