Welcome to AtomMiner Blog

News, updates and useful how-to guides for our miners

Fighting Altera USB-Blaster on Ubuntu

Today I was really surprised by realizing that  Quartus Prime Programmer doesn’t see USB blaster connected to my laptop and cant program the FPGA from linux OS. It took me good couple of hours to figure out how to marry USB blaster with Programmer app on my Ubuntu 17.04 install. Unfortunately, Altera USB Blaster User Guide doesn’t shed any light on this problem so I had to find my own way out.

Altera Quartus on Ubuntu 17.04

If you already have Quartus up and running on your linux you can skip to the next part where actual USB Blaster problems and configuration is described.

Let’s start from the beginning during active debug and testing we decided it is bad practice to disconnect test board and run back and force between computer every time firmware is changed so I decided to have running version of Quartus on my development laptop. From my previous experience I know it runs nice and easy in Windows environment, so I tried to run with wine. And surprise, surprise it doesn’t work from wine. Not a biggie, heading up to Altera Download Center and downloading Linux distro. Quartus setup is straight forward. Libpng or something like that is missing.

sudo apt update && sudo apt install libpng2.0

fixed the problem and we’re ready to roll.

Running the icon on the desktop did nothing. Ok, it seems like Quartus had been installed into my home folder, console command

~/altera_lite/15.1/quartus/bin/quartus --64bit

actually starts Quartus:

altera quartus running

Kinda inconvenient to type in full path to the quartus every time you need it, but I can understand, they are making FPGAs, not the linux software. Now I can create an alias to run it via full path by typing quartus, but I’m suspecting it’ll need access to the bin folder later on so adding Quartus’s bin folder on the PATH. To do that edit your ~/.profile with nano or whatever text editor you like:

nano ~/.profile

Add this at the end of file:

PATH="$PATH:$HOME/altera_lite/15.1/quartus/bin"

Save file, log out, log back in and type quartus in the console. Now it starts right away, good deal!

Now creating new project, adding files, compiling source code, etc. A lot of USB blaster unrelated actions been taken to bring project into ready-to-program state. I will post another article with all these steps explaining how to create a project and and compile AtomMiner project in Quartus later when we publish Verilog sources on the GitHub.

(Re)Discovering USB Blaster

Now that the project is done it is time to program it into the FPGA board and start testing. You can access Quartus Programmer from the main menu, or by typing quartus_pgmw --64bit in command line. Programmer interface opens up, but there’s no compatible hardware detected. Unplugging test board, plugging it back in and no result. Does it look familiar?

altera programmer no usb blaster ubuntu

Now I gotta find my USB Blaster and figure out how to make programmer app to talk to it. For that, unplug test board, plug it back in and type on the command line:

$ dmesg|tail
[433421.422645] usb 1-1.2: Product: USB-Blaster
[433421.422648] usb 1-1.2: Manufacturer: Altera
[433421.422650] usb 1-1.2: SerialNumber: ARTLIYPB
[434452.280039] usb 1-1.2: USB disconnect, device number 6
[434458.907628] usb 1-1.2: new full-speed USB device number 7 using ehci-pci
[434459.023318] usb 1-1.2: New USB device found, idVendor=09fb, idProduct=6001
[434459.023322] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[434459.023325] usb 1-1.2: Product: USB-Blaster
[434459.023327] usb 1-1.2: Manufacturer: Altera

Great news! USB Blaster is here and recognized by the system, let’s go ahead and verify it is still there:

$ lsusb|grep Blaster
Bus 001 Device 006: ID 09fb:6001 Altera Blaster

Perfect! The Blaster is here, it is connected and seems to be operational. I’ve noticed idVendor and idProduct looks way too familiar. Quick google search shows that they are just using FTDI chip on board as an USB Blaster, which supposedly makes things easier. On most linux installs users don’t have raw access to any physical port. In our case we’re looking at FTDI’s USB-Serial type of port. Typical work around for that problem is to run whatever you need as root. This is real bad practice though due to security issues, but let’s give it a shot. sudo quartus_pgmw --64bit brings up programmer interface but USB blaster is still not on the list of available hardware. Do not run any application as root unless you’re 100% sure this app has to have root access!!!

Closer look at programmer tool shows that it is just a GUI over jtagd daemon, that does all the programming and communication. Quartus’s bin folder contains 2 files we need to look at jtagconfig and jtagd. jtagconfig talking to the jtag daemon and only shows jtagd doesn’t see connected board:

$ jtagconfig
No JTAG hardware available

Further investigation showed that jtagd is being started as me, while system is blocking access to the blaster for security reason. Temporary solution was to kill JTAG daemon and start it as root:

$ sudo killall -9 jtagd
$ sudo jtagd --user-start --config /home/dev/.jtagd.conf

Finally, I’ve got some progress programming my test board:

$ jtagconfig
1) USB-Blaster [1-1.2]
031020DD 10M08DA(.|ES)/10M08D(C|F)/..

Bingo! Now Quartus Programmer starts and you can program FPGA as if you would use it in windows environment. Job is done except for the fact that jtagd is still running as root and I’ll have to kill and restart it as superuser every time I restart my laptop. I can live with jtagd being started manually if it wasn’t running as root, so while FPGA is programmed and being tested in background, it is perfect time to setup permissions so jtagd can talk to USB Blaster while started as me once and forever.

To setup permissions in the right way we need to know what library or driver is being used by jtagd daemon to communicate with FPGA. For that, you can look at files accessed by jtagd process:

$ ps aux|grep jtag
dev       9809  0.0  0.0  25824  2968 ?        S    Jul09   0:00 jtagd --user-start --config /home/dev/.jtagd.conf
dev      24538  0.0  0.0  15460   980 pts/4    S+   01:45   0:00 grep --color=auto jtag jtag pid is 9809 let's take a quick glance at opened files: $ lsof -n -p 9809
COMMAND  PID USER   FD      TYPE             DEVICE SIZE/OFF     NODE NAME
jtagd   9809  dev  cwd       DIR                8,5     4096        2 /
jtagd   9809  dev  rtd       DIR                8,5     4096        2 /
jtagd   9809  dev  txt       REG                8,2   324403   227751 /mnt/A4525C2A525C0388/altera_lite/15.1/quartus/linux64/jtagd
jtagd   9809  dev  mem       REG                8,5  1856752  1442617 /lib/x86_64-linux-gnu/libc-2.24.so
jtagd   9809  dev  mem       REG                8,2   520428   226218 /mnt/A4525C2A525C0388/altera_lite/15.1/quartus/linux64/libgcc_s.so.1
jtagd   9809  dev  mem       REG                8,2   306411   228255 /mnt/A4525C2A525C0388/altera_lite/15.1/quartus/linux64/libgomp.so.1
jtagd   9809  dev  mem       REG                8,5  1088952  1442625 /lib/x86_64-linux-gnu/libm-2.24.so
jtagd   9809  dev  mem       REG                8,2  6439682   226861 /mnt/A4525C2A525C0388/altera_lite/15.1/quartus/linux64/libstdc++.so.6
jtagd   9809  dev  mem       REG                8,5    14608  1442623 /lib/x86_64-linux-gnu/libdl-2.24.so
jtagd   9809  dev  mem       REG                8,5   142400  1442650 /lib/x86_64-linux-gnu/libpthread-2.24.so
jtagd   9809  dev  mem       REG                8,5    31712  1442653 /lib/x86_64-linux-gnu/librt-2.24.so
jtagd   9809  dev  mem       REG                8,5    93128  1442631 /lib/x86_64-linux-gnu/libnsl-2.24.so
jtagd   9809  dev  mem       REG                8,2    41914   228110 /mnt/A4525C2A525C0388/altera_lite/15.1/quartus/linux64/libccl_ver.so
jtagd   9809  dev  mem       REG                8,5   162608  1442609 /lib/x86_64-linux-gnu/ld-2.24.so
jtagd   9809  dev  mem       REG                8,5   131344  1442708 /lib/x86_64-linux-gnu/libudev.so.1.6.5
jtagd   9809  dev    0r      CHR                1,3      0t0        7 /dev/null
jtagd   9809  dev    1w      CHR                1,3      0t0        7 /dev/null
jtagd   9809  dev    2w      CHR                1,3      0t0        7 /dev/null
jtagd   9809  dev    3u     unix 0x0000000000000000      0t0 30798035 type=DGRAM
jtagd   9809  dev    4u     IPv4           30798036      0t0      TCP 127.0.0.1:1309 (LISTEN)
jtagd   9809  dev    5u  netlink                         0t0 30798858 KOBJECT_UEVENT

Highlighted line shows that jtagd is using old good system libudev. Now we need to create rules for libudev so any user can access USB Blaster. According to Altera website idProduct for USB Blaster can be one of the following 6001, 6002, 6003, 6010, 6810 so I’ll add them all to libudev rules in case I’ll have to work with different type of USB blaster down the pipeline.

$ sudo touch /etc/udev/rules.d/usbblaster.rules
$ echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"09fb\", ATTR{idProduct}==\"6001\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/usbblaster.rules -a
$ echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"09fb\", ATTR{idProduct}==\"6002\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/usbblaster.rules -a
$ echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"09fb\", ATTR{idProduct}==\"6003\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/usbblaster.rules -a
$ echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"09fb\", ATTR{idProduct}==\"6010\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/usbblaster.rules -a
$ echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"09fb\", ATTR{idProduct}==\"6810\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/usbblaster.rules -a

For the changes to take effect reboot your PC or run following command if you have it:

$ sudo udevadm control --reload

If jtagconfig doesn’t show your FPGA/board name you might have to copy board description file to jtag config and restart jtagd:

$ sudo mkdir /etc/jtagd
$ sudo cp /opt/altera/15.1/quartus/linux64/pgm_parts.txt /etc/jtagd/jtagd.pgm_parts
$ killall jtagd

Done is done! Now you can start Quartus Programmer at any time and upload your updated firmware to connected board like you always do with just a few mouse clicks.

usb blaster ubuntu

Basically, the same steps will work on any linux installation since all the steps and commands are common for most *nix distributives.

As a bonus, here’s the bash script that will do all the necessary steps for you: usbblaster.sh on GitHub:

$ wget https://raw.githubusercontent.com/atomminer/QuartusTweaks/master/usbblaster.sh && chmod +x usbblaster.sh && ./usbblaster.sh

Please leave your OS name and version along with Quartus version you’re using in comments if this script didn’t work for you, so I can update it.

If you find any of provided information helpful or just want to support our project, please donate:

BTC       1BBZMp3qouKY2MHx3vbosmPinTLMeU9C9u
DOGE    DMLrv8ZT2NfPUZUtPmGMJq9DvuQsH82QLN
LTC        LQ1QLdRjj1uf2MDiiMA3xLuEoLHBSeyvFU