Difference between revisions of "OpenOCD for IMote2"
(→Accessing serial data) |
(→Program iMote2 with OpenOCD) |
||
Line 67: | Line 67: | ||
* You can now manually install the binary on the mote by running: | * You can now manually install the binary on the mote by running: | ||
− | $INTELMOTE2_CONTRIB_DIR/tools/platforms/intelmote2/openocd/imote2-ocd-program.py build/intelmote2/main. | + | $INTELMOTE2_CONTRIB_DIR/tools/platforms/intelmote2/openocd/imote2-ocd-program.py build/intelmote2/main.exe |
− | |||
==== Manual programming method. ==== | ==== Manual programming method. ==== | ||
Line 82: | Line 81: | ||
resume | resume | ||
flash info 0 | flash info 0 | ||
− | |||
− | |||
=== Using GDB === | === Using GDB === |
Revision as of 19:38, 28 May 2008
Contents
OpenOCD JTAG programming for IMote2
- The following instruction works with USB JTAG cable from Olimex under Linux. The cable is available from http://microcontrollershop.com/
- The instructions are based on Ubuntu 7.10
- OpenOCD website
- ARM-USB-TINY only works with libftd2xx from FTDI
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 cp ftd2xx.h /usr/local/include cp WinTypes.h /usr/local/include 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 Olimex JTAG programmer. Create a file called /etc/udev/rules.d/45-ft2232.rules with the following text:
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 checkout http://svn.berlios.de/svnroot/repos/openocd
- build OpenOCD
cd openocd/trunk ./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.
- You can now manually install the binary on the mote by running:
$INTELMOTE2_CONTRIB_DIR/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
Using GDB
It is possible to use GDB to debug the iMote2 while it is running.
- Compile your binary using the "debug" flag:
make intelmote2 debug install.100
- After the mote is installed with the new binary, start up openocd:
openocd -f /usr/local/etc/arm-usb-tiny.cfg
- Run xscale-elf-gdb (which should have been installed with the xscale toolchain):
xscale-elf-gdb build/intelmote2/main.exe
- Tell gdb to use localhost:4444 as the debugging target. (This is the port that openocd listens on for gdb commands.)
(gdb) target remote localhost:4444
- Then continue:
(gdb) cont
- You can then hit Ctrl-C to halt the mote, and inspect what is going on. For example,
(gdb) info reg (gdb) where
and so forth.