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.
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.
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.
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:
- 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
- Purchase a pre-built board (£15) from Farnell (Digilent board) or Newark that uses a XC2C64A device
- 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).
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.
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.
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).
Once you have the BBB powered up, type
This will start up the web server, and then you can browse to:
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:
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.
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).
xprog_v1.zip 125.7 KB