pi3j The Raspberry Pi JTAG programmer

This is a Linux program for the Raspberry Pi that allows one to program a Digilent.inc Digilab 2 FPGA board via the parport with JTAG.

Source code is released under the GPL.

The Digilent.inc Digilab 2 has on it a Xilinx Spartan 2, and it can be programmed via JTAG or via a Xilinx parallel port cable from a PC.
As I do not always have a PC with a parport around (even bought a PCI parport card a while ago for one),
and still want to use this board, but then with a laptop,
and do not think the control lines in USB to serial adaptors are that much supported (not sure),
I decided to use the ethernet port of the laptop, connect a Raspberry Pi, ssh -Y to it,
and use its GPIO port to drive the parport on the Digilab 2, while doing the webpack stuff on a more powerful PC.
Of course you can also drive any JTAG chip directly, just write the soft :-)

This software is based on previous work by Rudolf Usselmann and Reinoud Lamberts,
in the past I changed it for direct I/O in Linux,
and now made a new version for the Raspberry Pi that uses the GPIO I/O pins.
The program takes a Xilinx bitfile (from webpack in my case) as input, use it like this
pi3j p1.bit

It works, that is all I can say about it.


pi3j in action:

Pi_breakout board close up:


Full source in C, compile it on the Raspberry Pi (NOT on the PC, the Raspberry has an ARM processor!) with:
gcc -o pi3j pi3j-0.2.c
then do:
cp pi3j /usr/local/bin/

Par port cable connections and signals as I used in this software version, and the Raspberry Pi version is board revision 2:

signalPi P1 headerPi GPIOdirectionparport signalparport pin

Used a little breakout board for testing, need to make a nice new cable sometime.

Session log

root@raspberrypi:~/compile/pantel/pi3j# ./pi3j frequency_counter.bit
Panteltje pi3j-0.1
Design Name: p1.ncd
Device: 2s200pq208
Date: 2007/ 9/26
Time: 19:27:14
Bitstream Length: 1335840 bits
Device ID: 8061c093
Manuf: 49, Part Size: 1c, Family Code: 3, Revision: 8
Programming ... *****
Programmed 1335840 bits
Ready, DONE=1

Scripting it all

A simple way to send .bit files from a laptop could be like this:
On the Raspberry Pi put the folling in /usr/local/sbin/jtag_programmer

echo "listening for connections on port 1234"
while [ 1 ]; do netcat -l 1234 | pi3j /dev/stdin; done
echo "user abort"
exit 0

Make it executable with:
chmod +x /usr/local/sbin/jtag_programmer

On the laptop put the following in /usr/local/sbin/prog_jtag

if [ "$1" == "" ]
echo "Usage: prog_jtag file.bit"
exit 1
echo "Programming device."
cat $1 | netcat -c $IP_OF_RASPBERRY_PI 1234
echo "Ready."
exit 0

Change the for the IP address of your Raspberry Pi
Make the file executable by typing:
chmod +x /usr/local/sbin/prog_jtag

Now to use it all (use your Raspberry Pi's IP address):
ssh -Y pi@
login with pasword
Change to root account
sudo su -

The Raspberri Pi is now a jtag programmer, always listening on TCP port 1234 for bitfiles (a ctrl C, or a power down on it will stop this script).

Now on the laptop, to program a bit file, in an other xterm, simply type:
prog_jtag name_of_file.bit

This example gives no feedback if the file actually arrived or programmed correctly,
but if you leave the ssh link open then you will see DONE=1 if OK, and DONE=0 if not OK.

This is just a simple example using netcat to automate things, it may need some more work.

return to main page