Alberto Embedded & Open experience

Notes on my experience on Open Source Embedded Systems

Archive for March 2010

OpenOCD with Amontec JtagKey2 support

leave a comment »

Recently I bought an Amontec JtagKey-2 debug probe for my embedded projects. This Jtag probe have great features over a relative little buying cost: over other low cost Jtag probes, this one supports the RTCK signal and nominal speeds are really interesting.

What this post will describe is how to setup a useful JTAG debug environment:

libftd2xx

The JtagKey2 is based on FTDI FT2232 usb interface. Drivers for this chip can be found here:
http://www.ftdichip.com/Drivers/D2XX.htm

Choose your arch (for me Linux x86_64) and  download the archive in  $PRJROOT/openocd.
Then:

$ cd $PRJROOT/openocd
$ tar -xvf libftd2xx0.4.16_x86_64.tar.gz

OpenOCD

OpenOCD can be downloaded from its public git repository:

$ cd $PRJROOT
$ git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd openocd

Then, move to the opnocd directory and configure with:

$ cd openocd
$ ./bootstrap
$ # If you need, choose the right prefix with --prefix=DIR
$ ./configure --enable-maintainer-mode --enable-ft2232_ftd2xx \
  --with-ftd2xx-linux-tardir=libftd2xx0.4.16_x86_64
$ # n: Numbers of cores in your machine
$ make -j n

At this point the OpenOCD build process fire a linker error, this because  libtool mess up the library order when linking main.c so, let we do the right command:

$ cd src/

$ gcc -std=gnu99 -g -O2 -I/media/dati/android/openocd/libftd2xx0.4.16_x86_64 \
  -Wall -Wstrict-prototypes -Wformat-security -Wextra -Wno-unused-parameter \
  -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror \
  -o openocd main.o ./.libs/libopenocd.a \
  /media/dati/android/openocd/libftd2xx0.4.16_x86_64/static_lib/libftd2xx.a.0.4.16 \
  -ldl -lpthread
$ cd ..
$ make -j 6

And at the end, install:

$ sudo make install

Using OpenOCD

OpenOCD is completely configurable: the server must be started with a number of “-f ” options that points to the necessaries configuration files.
Normally must be given two configuration files: The interface config and a board config.
So OpenOCD can be started with:

$ sudo openocd -f interface/jtagkey2.cfg -f board/your_board.cfg

We have to use sudo because of permissions needs on using an usb device, otherwise an udev rule must be set.

Written by Alberto!

16/03/2010 at 12:11 pm

Posted in linux-arm

Tagged with ,