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

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

  1. Felipe says:

    I am trying to flash an STM32E0407ZGT6 chip on an STM32-E407 using a ARM-USB-TINY-H programmer. I was able to install openocd using sudo apt-get install on my ubuntu 11.10 machine. Unfortunately, when I try to flash the chip using telnet I get the following error:

    auto erase enabled
    Info : device id = 0x10016413
    Warn : Cannot identify target as a STM32 family, try the other STM32 drivers.
    Error: auto_probe failed
    in procedure ‘flash’
    Do you have any idea of what I could be doing wrong? This is the command I used for openocd:
    openocd -f olimex-arm-usb-tiny-h.cfg -f stm32f4x.cfg
    I have tried a bunch of the different config files for different STM 32 devices and none seem to be working. Below are all the details of my openocd session:
    openocd -f olimex-arm-usb-tiny-h.cfg -f stm32f4x.cfg
    Open On-Chip Debugger 0.5.0 (2011-08-26-10:27)
    Licensed under GNU GPL v2
    For bug reports, read
    http://openocd.berlios.de/doc/doxygen/bugs.html
    Info : only one transport option; autoselect ‘jtag’
    2000 kHz
    adapter_nsrst_delay: 100
    jtag_ntrst_delay: 100
    Info : max TCK change to: 30000 kHz
    Info : clock speed 2000 kHz
    Info : JTAG tap: stm32f4xxx.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
    Info : JTAG tap: stm32f4xxx.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
    Info : stm32f4xxx.cpu: hardware has 6 breakpoints, 4 watchpoints
    Info : accepting ‘telnet’ connection from 4444
    Info : device id = 0x10016413
    Warn : Cannot identify target as a STM32 family, try the other STM32 drivers.
    Error: auto_probe failed
    in procedure ‘flash’
    Thank you,

    Felipe

    • Andre Beckus says:

      I looked in the OpenOCD source code – the device ID check for your chip happens in the file “src/flash/nor/stm32f2x.c”. It is checking the three least-significant digits of the device ID, which are 0x413 in your case. Going back as far as OpenOCD 0.6.0, the code will handle 0x413. However, in OpenOCD 0.5.0 this ID was not included yet, thus resulting in the “Cannot identify target” error. Try upgrading to the latest version of OpenOCD, and it should resolve your issue.

  2. Bharath says:

    Hi Andre

    Your blog was really helpful . After a lot (and I mean a lott) of other methods, your post was very helpful in configuring openocd on my Ubuntu 12.04 system.

    But when I try to run the default blink program, on an Olimex ARM-USB-TINY-H , my system just stops at Programming imote2 with binary: build/intelmote2/main.bin.out
    Starting OpenOCD…

    I checked the build folder and the main.exe file appears as expected. But it does not proceed beyond the “Starting Openocd” point.

    Do you have any suggestions. I googled around and the only suggestion I could find is to disconnect the mini usb and try again, which doesnt fix my issue

    Thanks a lot

    • Andre Beckus says:

      Thank you, I am glad that you found the post helpful.

      Unfortunately, I am not too familiar with the internals of OpenOCD, nor do I have any experience with the Intel Mote 2 board or chip. But, here are some questions/ideas:
      1) What version of OpenOCD are you using? You should try using the latest version (currently 0.6.1) if you are not already doing so.
      2) According to the documentation, there is a “-d” option that you can use to enable debug messages (see http://openocd.sourceforge.net/doc/html/Running.html ). Try this and see if it helps identify the cause.
      3) In order to help you further, please post the following information: OpenOCD version number, exact command line you are using, and the log output you get when running with debug messages enabled.

      You should consider posting a message on the OpenOCD forum (at https://forum.sparkfun.com/viewforum.php?f=18 ), as this has a wider and more knowledgeable audience. If you do this, please post another comment with a link to the forum thread.

      Good luck!

  3. Yang says:

    I am trying to flash Imote2 using a Olimex-arm-usb-tiny-h programmer. I was ablt to install openocd using sudo apt-get install on my Ubuntu 14.04 machine. However, when I try to reset (or flash) the chip using telnet i get the following error:

    JTAG tap: imote2.cpu tap/device found: 0x79265013 (mfg: 0x009, part: 0x9265, ver: 0x7)
    Bad value ’00’ captured during DR or IR scan:
    check_value: 0x02
    check_mask: 0x07
    JTAG error while writing DCSR
    Bad value ’00’ captured during DR or IR scan:
    check_value: 0x02
    check_mask: 0x07
    JTAG error while writing DCSR
    Bad value ’00’ captured during DR or IR scan:
    check_value: 0x02
    check_mask: 0x07
    JTAG error while writing DCSR
    Bad value ’00’ captured during DR or IR scan:
    check_value: 0x02
    check_mask: 0x07
    JTAG error while writing DCSR
    Bad value ’00’ captured during DR or IR scan:
    check_value: 0x02
    check_mask: 0x06
    JTAG error while reading TX
    error while polling TX register, reset CPU
    target state: halted
    target halted in ARM state due to target-not-halted, current mode: User
    cpsr: 0x00000000 pc: 0x00000000
    MMU: disabled, D-Cache: disabled, I-Cache: disabled

    Do you have any ideas about this?

    Thanks.

    Yang

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: