Configuring OpenOCD with an Olimex ARM-USB-TINY-H in Ubuntu 12.04 64 bit

I have an Olimex ARM-USB-TINY-H JTAG programmer which I recently installed in Ubuntu 12.04 64 bit (running inside Virtualbox).  I am using the programmer with OpenOCD.  I had some old instructions I wrote up, which I updated to work with 12.04.  I had some issues (due to some stupid mistakes on my part) and I came across this post while doing research.  My instructions are generally the same, but they differ somewhat in the details.  I decided to post what I have in case it helps anyone out.

References

Configure the Programmer

The programmer uses the FTDI chipset, so we need to install the FTDI drivers – we will use the libFTDI driver:

sudo apt-get install libftdi-dev libftdi1

Now Ubuntu should recognize the programmer when it is plugged in. But, by default it requires root privileges to use. Therefore, we need to set up a udev rule to change the permissions.  This rule assigns the device to the plugdev group – which was introduced in Linux for hot-pluggable devices – and then gives the group read and write access.  Make sure your user is in the plugdev group; my user was in it by default.

  1. Create a file /etc/udev/rules.d/olimex-arm-usb-tiny-h.rules
  2. Put this single line in the file:
    SUBSYSTEM=="usb", ACTION=="add", ATTR{idProduct}=="002a", ATTR{idVendor}=="15ba", MODE="664", GROUP="plugdev"

Install OpenOCD

  1. Change into the directory where you will download and build OpenOCD. I use my home folder:
    cd ~
  2. You can download the distribution from the OpenOCD website, but I prefer to get the source code from its git repository.  If you go down this route, you will need to have some extra packages:
    sudo apt-get install git libtool automake texinfo
  3. Get the source code
    git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
    cd openocd
  4. Check the tags to see what versions are available (you can also reference the OpenOCD website):
    git tag -l

    The version distributed with my programmer was 0.3.0 , but that is way out of date at this point.  At the time of writing, the lastest version is 0.6.0, so that’s what I use:

    git checkout v0.6.0
  5. Do the build – this uses the libFTDI drivers we installed earlier:
    ./bootstrap
    ./configure --enable-maintainer-mode --enable-ft2232_libftdi
    make
    sudo make install

Test OpenOCD

Make sure the programmer is plugged in to the computer and into a board/microcontroller, and then run openocd (use the appropriate target for your microcontroller).  If there is a problem connecting to your programmer, you should quickly get an error message about not being able to open the ftdi device:

openocd -f interface/olimex-arm-usb-tiny-h.cfg -f target/stm32f1x.cfg

Troubleshooting tips

  • If openocd cannot find your FTDI device, run openocd as root (e.g. using sudo).  If that works, then you have a permission issue.
  • Run this command to view attached USB devices:
    lsusb

    You should see something similar to this line:

    Bus 001 Device 002: ID 15ba:002a Olimex Ltd. ARM-USB-TINY-H JTAG interface
  • Devices can be found under /dev/bus/usb/001/004 (in this example 001 is the bus and 004 is the device).  If the udev rule is working, this device file should have permissions as described above.  If the rule is not working, the device file will belong to the root group.
  • A /dev/ttyUSB device is not created by default, and openocd does not need it if it is using libFTDI (the libFTDI driver does not rely on the kernel drivers).
  • Run this command to get detailed attributes for a device – useful for modifying or troubleshooting a udev rule (substitue your bus and device number):
    udevadm info -a -p  $(udevadm info -q path -n /dev/bus/usb/001/004).
  • Run this command to test your udev rule against the device and see why it does not work (substitue your bus and device number):
    udevadm test /dev/bus/usb/001/004
  • The OpenOCD interface and target cfg scripts are located under this folder by default: /usr/local/share/openocd/scripts
Advertisements