Saturday, May 3, 2014

A Programming Utility for the Avnet Spartan-6 Evaluation Kit

While playing around with FPGA-based sparse-matrix vector accelerators on the Avnet Spartan-6 LX16 Evaluation Kit I realized I needed a utility for uploading binary files to the board for testing. The board supports programming over a USB serial connection, but Avnet only provides a Windows-only utility for this purpose, which doesn't have the option to select and send binary files. I was also getting rather sick of having to switch to a Windows virtual machine just to run the programming utility, not to mention this beautiful user interface with jelly buttons and everything:


So I decided to make a small utility that would run on Linux, with simple text-based rx/tx as well as support for FPGA bitfile configuration and sending binary files. The "hardest" part was deciphering the text-based protocol for talking to the on-board PSoC, which is responsible for manipulating the necessary FPGA pins and pushing in the new configuration file. Since the PSoC firmware documentation was nowhere to be found on Avnet's download pages, I ended up using a serial port sniffer to see what the protocol looked like, which was something like this:

(lines prefixed with >> are TX from the progutil to the board)
>> get_config
ack
>> get_ver
3.0.2 ack
>> load_config 1
ack
>> drive_prog 0
ack
>> drive_mode 7
ack
>> spi_mode 1
ack
>> drive_prog 1
ack
>> read_init
ack ack
>> drive_mode 8
ack
>> fpga_rst 1
ack
>> ss_program
ack
>> 
ack
>> read_init
ack ack
>> read_done
ack ack
>> spi_mode 0
ack
>> load_config 0
ack
>> fpga_rst 0
ack

It took a little bit of trial-and-error and some reading of documentation on QThreads (for data rx-tx without blocking the user interface), and the result ended up looking like the following:



I cannot claim huge improvements on the user interface front, but at least it works on Linux and supports the minimal feature set needed to be useful.  I'm planning to add support for power measurements, and the code certainly could use lots of cleanup, but we'll see how much time I have for that. If you are interested, the sources are available at:

https://github.com/maltanar/s6lxek-progutil

I eventually managed to Google my way into finding the firmware documentation, which I've also put on github, in case someone has need of it at some point.