Difference between revisions of "OpenOCD for IMote2"

From TinyOS Wiki
Jump to: navigation, search
(Install FTDI libftd2xx driver)
m (Program iMote2 with OpenOCD)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== OpenOCD JTAG programming for IMote2==
 
== OpenOCD JTAG programming for IMote2==
  
* The following instruction works with [http://www.olimex.com/dev/arm-usb-tiny.html USB JTAG cable from Olimex] under Linux. The cable is available from http://microcontrollershop.com/
+
* The following instruction works with the [http://www.amontec.com/jtagkey.shtml Amontec JTAGkey] and with [http://www.olimex.com/dev/arm-usb-tiny.html USB JTAG cable from Olimex] under Linux. The Amontec JTAGkey is available from http://www.amontec.com/. The Olimex cable is available from http://microcontrollershop.com/
 
* The instructions are based on Ubuntu 7.10
 
* The instructions are based on Ubuntu 7.10
 
* [http://openocd.berlios.de/web/ OpenOCD website]
 
* [http://openocd.berlios.de/web/ OpenOCD website]
* ARM-USB-TINY only works with [http://www.ftdichip.com/Drivers/D2XX.htm libftd2xx from FTDI]
+
* Amontec JTAGkey and ARM-USB-TINY only works with [http://www.ftdichip.com/Drivers/D2XX.htm libftd2xx from FTDI]
* Instruction on using openOCD with JTAG wiggler cable [[OpenOCD_for_IMote2_Wiggler | OpenOCD for Imote2 using Wiggler]]
+
* Instruction on using openOCD with JTAG wiggler parallel port cable [[OpenOCD_for_IMote2_Wiggler | OpenOCD for Imote2 using Wiggler]]
  
 
===Install FTDI libftd2xx driver===
 
===Install FTDI libftd2xx driver===
Line 15: Line 15:
 
  cp ftd2xx.h /usr/local/include
 
  cp ftd2xx.h /usr/local/include
 
  cp WinTypes.h /usr/local/include
 
  cp WinTypes.h /usr/local/include
 +
chmod a+r /usr/local/include/ftd2xx.h /usr/local/include/WinTypes.h
 
  cp libftd2xx.so.0.4.13 /usr/local/lib
 
  cp libftd2xx.so.0.4.13 /usr/local/lib
 
  cd /usr/local/lib
 
  cd /usr/local/lib
Line 32: Line 33:
 
  mount --rbind /dev/bus/usb /proc/bus/usb
 
  mount --rbind /dev/bus/usb /proc/bus/usb
  
We now need to set up the permissions correctly for the Olimex JTAG programmer.  Create a file called <tt>/etc/udev/rules.d/45-ft2232.rules</tt> with the following text:  
+
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 <tt>/etc/udev/rules.d/45-ft2232.rules</tt> 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"
 +
 +
LABEL="kcontrol_rules_end"
 +
 
 +
* For the Olimex programmer
  
 
  BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="kcontrol_rules_end"
 
  BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="kcontrol_rules_end"
 
   
 
   
  SYSFS{idProduct}=="0004", SYSFS{idVendor}=="15ba", MODE="664", GROUP="adm"
+
  SYSFS{idProduct}=="0004", SYSFS{idVendor}=="15ba", MODE="664", GROUP="adm"
 
   
 
   
 
  LABEL="kcontrol_rules_end"
 
  LABEL="kcontrol_rules_end"
Line 63: Line 74:
 
=== Program iMote2 with OpenOCD ===
 
=== Program iMote2 with OpenOCD ===
  
* Connect iMote2 to the debug board.
+
* 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 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.  
 
* 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.  

Latest revision as of 21:59, 9 November 2009

OpenOCD JTAG programming for IMote2

Install FTDI libftd2xx driver

  • run the following as root or using sudo
wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.13.tar.gz
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 libftd2xx.so.0.4.13 /usr/local/lib
cd /usr/local/lib
ln -s libftd2xx.so.0.4.13 libftd2xx.so
cd /usr/lib
ln -s /usr/local/lib/libftd2xx.so.0.4.13 libftd2xx.so
ldconfig

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/mountdevsubfs.sh 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"

LABEL="kcontrol_rules_end"
  • 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"  

LABEL="kcontrol_rules_end"

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 http://svn.berlios.de/svnroot/repos/openocd/trunk openocd-svn
  • build OpenOCD
 cd openocd-svn
 ./bootstrap
 ./configure --enable-ft2232_ftd2xx
 make
  • 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 "imote2-ocd-program.py" 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/imote2-ocd-program.py build/intelmote2/main.exe

Manual programming method.

The above uses our custom "imote2-ocd-program.py" 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:

halt
poll
resume
flash info 0