Using Altera's USB-Blaster on Debian Linux

by GateForge Consulting Ltd.

I've tested this on a Terasic DE4 board, but in theory it should work with any board which uses a USB-Blaster interface to the JTAG chain for programming Altera FPGA devices, such as the DE2 commonly used for education.

The usbfs instructions are obsolete, as usbfs has ceased to exist in the Linux kernel as of 3.5. I'm keeping them here for historical interest, and also because the debugging guide at the end is still relevant.

Current working instructions can be found on the Arch Linux Wiki: Altera Design Software. The essential updated bit is:

Create a new udev rule:


# USB-Blaster
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6002", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6003", MODE="0666"
# USB-Blaster II
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6010", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6810", MODE="0666"

Then, reload that file using udevadm:

# udevadm control --reload

The rest of the instructions remain essentially the same: jtagd must run as root to ensure sufficient permissions.

Allowing non-root access to the USB-Blaster device

To do this, create a file called /etc/udev/rules.d/altera-usb-blaster.rules containing a single line:

ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="666"

This grants rw-rw-rw- permision to the device. A more proper configuration involves creating a group for the device, say usbblaster, placing your user(s) in that group, and defining the device permisions like so:

ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", GROUP="usbblaster"

Note that this is not perfect: multiple USB device entries are created for the USB-Blaster, and not all will have the new permissions, which is why jtagd must run as root. (see below)

Mounting the usbfs filesystem

Add the following entry to /etc/fstab and mount it:

none /proc/bus/usb usbfs defaults 0 0

You'll know its good if /proc/bus/usb/devices appears and spits out a bunch of textual device info when printed.

Note that Ubuntu no longer ships with usbfs enabled. This makes for more complicated workarounds, which you will find online.

Configuring jtagd

Quartus uses a daemon, jtagd, as intermediate bewteen the programming software and the device. This seems needlessly complicated, but does enable remote host programming apparently. The key points to configuring it correctly are: it must be able to access a list of FPGA descriptions, and run as root.

Copy the descriptions from your Quartus installation to the configuration directory of jtagd:

mkdir /etc/jtagd
cp <Quartus install path>/linux/quartus/linux/pgm_parts.txt /etc/jtagd/jtagd.pgm_parts (Note the change of name!)

Have jtagd start at boot by either placing it in the rc.d system, or simply place the followwing line in /etc/rc.local:

<Quartus install path>/linux/quartus/bin/jtagd

Although it might get created automatically, you can create an empty file named .jtagd.conf in your home directory. I hear it's possible to edit it to allow external hosts to connect and program/debug. This is only necessary if you want to use that feature.

Testing your setup

As a final test, plug in your device, run dmesg to see if the USB-Blaster device is found, then run (as your usual user) jtagconfig. You should see output similar to this:

1) USB-Blaster [USB 1-1.1]
  020B30DD   EP2C15/20

If USB device permissions are insufficient (they shouldn't, given the rule added in /etc/udev/rules.d/altera-usb-blaster.rules), you will instead get:

No JTAG hardware available

If USB permissions are OK, but jtagd is not running as root, you will see:

1) USB_Blaster [USB 4-1.2]
  Unable to lock chain (Insufficient port permissions)

Finally, if permissions are OK and jtagd is running as root, but it cannot access the FPGA device descriptions, you will see:

1) USB-Blaster [USB 4-1.2]

Programming your FPGA device

You should now be able to use the Programmer in Quartus to load a bitstream onto your target FPGA. Alternately, you can use the following shell script to do it at the command line:

quartus_pgm -z -m JTAG -o "p;$1"