OpenOCD for IMote2

From TinyOS Wiki
Jump to: navigation, search


OpenOCD JTAG programming for IMote2

Install FTDI libftd2xx driver

  • run the following as root or using sudo
gunzip libftd2xx0.4.13.tar.gz
tar -xvf libftd2xx0.4.13.tar
cd libftd2xx0.4.13
cp ftd2xx.h /usr/local/include
cp WinTypes.h /usr/local/include
chmod a+r /usr/local/include/ftd2xx.h /usr/local/include/WinTypes.h
cp /usr/local/lib
cd /usr/local/lib
ln -s
cd /usr/lib
ln -s /usr/local/lib/

The closed source drivers from FTDI rely on having /proc/bus/usb available. This is not enabled in Ubuntu by default. We enable it by editing /etc/init.d/ and uncommenting the following lines:

# Magic to make /proc/bus/usb work
mkdir -p /dev/bus/usb/.usbfs
domount usbfs "" /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

We now need to set up the permissions correctly for the Amontec JTAGkey or the Olimex JTAG programmer, depending on their PID / VID. Create a file called /etc/udev/rules.d/45-ft2232.rules with the following text:

  • For the Amontec JTAGkey
BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="kcontrol_rules_end"

SYSFS{idProduct}=="cff8", SYSFS{idVendor}=="0403", MODE="664", GROUP="adm"

  • For the Olimex programmer
BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="kcontrol_rules_end"

SYSFS{idProduct}=="0004", SYSFS{idVendor}=="15ba", MODE="664", GROUP="adm"  


You will have to reboot your machine for the changes to take effect.

Build OpenOCD

  • check out OpenOCD svn repository (svn:516)
svn checkout -r 516 openocd-svn
  • build OpenOCD
 cd openocd-svn
 ./configure --enable-ft2232_ftd2xx
  • install OpenOCD
 sudo make install
 sudo chmod 4755 /usr/local/bin/openocd
 sudo mkdir -p /usr/local/etc
 sudo cp $INTELMOTE2_CONTRIB_DIR/tools/platforms/intelmote2/openocd/arm-usb-tiny.cfg /usr/local/etc
 sudo chmod 755 /usr/local/etc/arm-usb-tiny.cfg

This will install openocd to /usr/local/bin. Be sure this is on your PATH.

Program iMote2 with OpenOCD

  • Connect iMote2 to the debug board.
  • Connect JTAG interface with USB to debug board and then connect to PC. (Best to connect directly to PC - going through a hub does not always work.)
  • Connect USB cable to debug board and then to PC. (As above, best to connect directly rather than through a hub.) You will therefore have two USB cables running from the PC: one to the JTAG interface and the other directly to the debug board.
  • Press the reset button on the iMote2.
  • compile binary:
cd /opt/tinyos-2.x/apps/Blink
make intelmote2 install.100 openocd

Note that this will try to run "" with the executable as an argument. This program is assumed to be in $TOSROOT/tools/platforms/intelmote2/openocd/; Alternately, you can manually install the binary on the mote by running:

$TOSROOT/tools/platforms/intelmote2/openocd/ build/intelmote2/main.exe

Manual programming method.

The above uses our custom "" program that is a wrapper for running openocd and programming the mote. You can also run openocd by hand:

 openocd -f /usr/local/etc/arm-usb-tiny.cfg

and then connect to it with:

 telnet localhost 3333

Various commands you can use:

flash info 0