This was a quick (and interesting) project, to get the BBB prepared for programming programmable logic. If you’re interested in implementing programmable logic, then this is a useful first step so that you have a tool for programming the devices.

 

The solution here allows you to program Xilinx parts (CPLDs and FPGAs) at zero cost (assuming you have a BeagleBone).

 

It is browser-based and simple to use with drag-and-drop programming. Just drag your programming file from the desktop onto the beagle in the browser.. no menu or CLI at all. It was surprisingly fast, too. It takes just a few seconds to program a small CPLD. For a simple project using this programmer, see here.

 

browser.png

How Does it Work?

Xilinx programmable logic chips (FPGAs and CPLDs) have a JTAG interface; the BBB runs some software that can take a programming file and send it over some I/O pins that are connected to the target device JTAG interface.

 

The code is easy to implement because Xilinx have done the hard work - they have code and a paper, and their existing code was adapted slightly. For the BBB I/O, the C library here was used and this made it a quick thing to get running.

 

For the web interface, Node.js is used (thanks to Drew for making me aware of it!), and some javascript code called dropzone found on the Internet is used to get the drag-and-drop functionality implemented. I had a little difficulty with MIME and UTF-8, and if anyone has a better solution than my quick hack, it would be appreciated. It needs some thorough testing still - I just tested with a small file, using FF, IE and Chrome.

Getting Ready for Programming

Creating the programmer described here, or using it, does not require the Xilinx development environment, but you do need to download it if you’re interested in programmable logic designs. Also, download it much in advance to requiring it because is quite large (multiple GBytes) so be prepared for a very long download. They also offer DVDs but they can take months to arrive, so really the only option is to download. The location to download is shown here.

ise.png

Obtain a Development Board

You will also need a test board to play with; there are a few options. In the CPLD space, these options are worth considering:

  1. Purchase a blank board and parts (Gazunty Pi) at low cost – Intended for the RPi, but it would be fine with the programmer here. The Gazunty Pi uses a XC9500XL device
  2. Purchase a pre-built board (£15) from Farnell (Digilent board) or Newark that uses a XC2C64A device
  3. Build your own test board on prototyping board (will supply more detail later if there is interest) – I chose a XC2C64A device (UK Farnell link / US Newark link).

 

Photos of the three options are below. (Derek from Gazunty Pi, I hope you don’t mind me using your photo).

gazunty.jpg

 

digilent.jpg

 

homemade.jpg

 

I went with options 2 and 3 because I’m familiar with that particular part. Despite it being surface-mount, it is large (0.8mm pitch pins) and easy to hand-solder with a normal iron. Also hardly any pins need wiring for test purposes so a SMD prototyping adapter board can be used rather than a custom PCB.

For the circuit diagram, you could follow the Digilent board circuit. The green bit in the photo above is a voltage regulator and you can see a few small capacitors were soldered directly on the prototyping adapter board.

 

Regardless of option you choose, it is worthwhile buying a small oscillator too for reasons to be explained later, and soldering it on somewhere. You can see it on the underside here, soldered upside down. I chose 32MHz - just gone out of stock! But any value in that ballpark will be fine, e.g. a 20MHz oscillator.

homemade_underside_marked.jpg

 

In the FPGA space there are several options too. Perhaps the lowest cost (but good value) board is the Papilio One from Seeed Studio ($38). However a CPLD is a better choice to start off with.

papilio_one.jpg

 

How to use the Programmer

There are just four signals and 0V that need connecting from the BBB to the Xilinx device. They are indicated in the diagram here (used the Digilent board as an example).

programmer_topology.png

Once you have the BBB powered up, type

node index.js

This will start up the web server, and then you can browse to:

http://xx.xx.xx.xx:8081/index.html

Then just drag the desired file onto the dog, and it will program the board within seconds. It doesn’t give any indicaton of completion today :-) I might get round to implementing that but, after programming, the target device will immediately begin execution so you can see that the programming is complete. There is no need for a power-cycle either; to reprogram the device, just drag another file onto the beagle. If you wish to use a command line option, the syntax is:

./xprog_app my_programming_file.xsvf

 

The photo shows a typical use scenario - there are six wires between the CPLD board and the BBB (TMS, TDI, TDO, TCK, GND) and also VCC so that the CPLD board is being powered from the BBB. The BBB is plugged into a DC supply and into the network so that it has an IP address, and a web browser can allow you to drag the file to be programmed into it.

in_use.jpg

 

Compiling the Software

For convenience, create a folder on the BBB off the home directory (e.g. call it development, and inside it another folder called xprog and unzip the code inside there. Install the GPIO library from here. To compile the code, type

make clean
make

(If you make any code changes, type make clean first - there is a bug in the makefile).

Then, plug in the wires to the CPLD board and run the code as described above.

The code is still fresh so there may be bugs. If you spot any, please let me know! It has been tested on a single CPLD so far.

(Code now attached).