Personal tools
You are here: Home Research Projects DynamicTinyOS JTAG TelosB Linux
Document Actions

JTAG TelosB Linux

by Olaf Landsiedel last modified 2008-08-17 20:37

Debugging Tmote sky with MSP FET430UIF

This page describes my experience of setting up TI's JTAG device (MSP-FET430UIF) to debug motiev's tmote platform (telosb) which is equipped with an MSP430x1611. This mcu supports JTAG debugging which is a really helpful feature and following is how to go about it.

The Machine I tried this on was:
HPtx1000z (AMD Turion X2) with Ubuntu 8.04, Kernel 2.6.26.2

Step 1:

Install MSPGCC tool chain:

$ cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P tinyos-1.x/tools/src/mspgcc
$ cd tinyos-1.x/tools/src/mspgcc
$ INSTALL_DIR=/opt/msp430 ./build-mspgcc install

Step 2:

Install GNU debugger with mspgcc patches. (use gcc-3.4 for compilation, yes gcc-3.4 not gcc-4.x)

$ wget http://mirror.switch.ch/ftp/mirror/gnu/gdb/gdb-6.0.tar.bz2
$ tar xfj gdb-6.0.tar.bz2

$ cvs -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc login
$ cvs -z3 -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc co gdb/gdb-current

$ cp -r gdb/gdb-current/* gdb-6.0/
$ cd gdb-6.0
$ CC=/usr/bin/gcc-3.4  ./configure --prefix=/opt/msp430 --target=msp430
if you dont already have gcc-3.4 install it as follows
$ sudo apt-get install gcc-3.4

$ make
$ sudo make install

Step 3:

Install msp430-gdbproxy
$ cvs -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc login
$ cvs -z3 -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc co jtag
$ cd jtag/hardware_access
$ make
if compilation is successful copy it into the ".so" pool
$ cp libHIL.so /usr/lib
$ sudo ldconfig
Now get msp430-gdbproxy and msp430.so (both are closed sourced)
$ wget http://www.soft-switch.org/downloads/mspgcc/msp430-gdbproxy
$ wget http://www.soft-switch.org/downloads/mspgcc/libMSP430.so

$ chmod +x msp430-gdbproxy
$ sudo cp msp430-gdbproxy /opt/msp430/bin
$ sudo cp libMSP430.so /usr/lib

Step 4:

Set up gdb initscript, so that we dont have to repeat basic commands every time. make a ".gdbinit" file in home folderwith following contents
set remoteaddresssize 16
set remotetimeout 999999
set download-write-size 512
target remote localhost:2000
set remote memory-write-packet-size 512
set remote memory-write-packet-size fixed
set remote memory-read-packet-size 512
set remote memory-read-packet-size fixed

Step 5:

Now test it. Compile the following program for msp430x1611
///////////////////
#include <io.h>
void wait();              /* prototype for wait()      */

int main()
{ 
   /* main function, called by startup-code */
   P5DIR = 0xFF;          /* port 5 = output           */
   P5OUT = 0x70;          /* set bits 4-6 in port 5    */

   for(;;) { 
      /* infinite loop */
      P5OUT ^= 0x10;      /* invert port 5 bit 4       */
      wait();             /* call delay function       */
   }
}

void wait()
{ 
   /* simple delay function */
   volatile int i;        /* declare i as volatile int */
   for(i = 0; i < 32000; i++)
      ;                   /* repeat 32000 times (nop)  */
}
///////////////////
$ msp430-gcc -Os -mmcu=msp430x1611 -ggdb -o blink.elf blink.c

Step 6:

so far we have not attached JTAG with PC. Load the kernel module as:
$ sudo modprobe ti_usb_3410_5052 product_3410=0xf430 vendor_3410=0x0451
now
 
$ dmesg
OR
$ lsusb
will confirm you that "ti_usb_3410_5052" module has been loaded. Attach JTAG with tmote, and then attach JTAG with PC. now
$ dmesg
should tell you that a USB port (/dev/ttyUSB*) has been assigned to ti_usb_3410_5052 If yes all is fine move to next step. If instead it shows some error message ending at -5 then input following command
$ sudo /bin/bash -c 'echo 2  > /sys/bus/usb/devices/<your device address>/bConfigurationValue' 
Ideally you should not get any error here. Now if everything went well,
$ dmesg 
will tell you that a USB port has been assigned, if yes move to Step 7, else to Step 6a.

Step 6a :

For kernel version 2.6.24 and eralier; there seems to be a problem with ti_usb_3410_5052.ko driver included in kernel modules. That can be resolved (as explained here in detail). In short, you need to download your kernel source, apply following patch to ti_usb_3410_5052.c and recompile this module. And copy it into your /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ folder. steps will be:
$ mkdir kernel
$ cd kernel
$ apt-get source linux-source
$ tar xjvf linux-source-2.6.24.tar.bz2
$ cd linux-source-2.6.24
$ cp /boot/config-2.6.24-19-generic .config
$ make oldconfig
$ vi drivers/usb/serial/ti_usb_3410_5052.c
$ # Now apply the patch mentioned below
$ make
The patch to be applied is as follows. (Taken from here):
@@ -264,8 +264,8 @@ static struct usb_serial_driver ti_1port_device = {
 	.description		= "TI USB 3410 1 port adapter",
 	.usb_driver		= &ti_usb_driver,
 	.id_table		= ti_id_table_3410,
-	.num_interrupt_in	= 1,
-	.num_bulk_in		= 1,
+	.num_interrupt_in	= NUM_DONT_CARE,
+	.num_bulk_in		= NUM_DONT_CARE,
 	.num_bulk_out		= 1,
 	.num_ports		= 1,
 	.attach			= ti_startup,
-
Now after applying the patch and recompilation, do following
$ sudo rmmod ti_usb_3410_5052
$ sudo cp drivers/usb/serial/ti_usb_3410_5052.ko /lib/modules/2.6.24-19-generic/kernel/drivers/usb/serial/
$ sudo depmod -a
Now replug your Jtag device run
$ dmesg
to check for address of your device, and then run this
$ sudo /bin/bash -c 'echo 2  > /sys/bus/usb/devices/<your device address>/bConfigurationValue'
If it still gives some error move onto step 6b, else move to step 7.

Step 6b :

Download and install a vanilla kernel as explained here. I used 2.6.26.2. After reinstalling kernel go back to Step 6

Step 7:

Assuming you have succesfully installed JTAG device and it has been tied to some /dev/ttyUSB*, now self test can be performed with (assuming JTAG device is tied to /dev/ttyUSB0)
$ msp430-gdbproxy  msp430 --selftest-usb-fet /dev/ttyUSB0
Ideally you should get :
notice:	msp430: TI USB FET self-test requested
debug:	MSP430_Initialize()
open: 	No such file or directory
error:  msp430: Could not initialize device interface (1)
debug: MSP430_Initialize()
debug: MSP430_Configure()
debug: MSP430_VCC(3000)
debug: MSP430_Identify()
info:  msp430: Target device is a 'MSP430F1611' (type 42)
debug: MSP430_Configure()
notice: msp430-gdbproxy: waiting on TCP port 2000
if instead you get an error about firmware version, disconnect jtag device, connect it again, input following command
$ sudo /bin/bash -c 'echo 2 > /sys/bus/usb/devices/<your device address>/bConfigurationValue' 
and then
$ msp430-gdbproxy  msp430 --update-usb-fet /dev/ttyUSB0
This will update the firmware of JTAG device.

Step 8:

If everything went well up till here, now we can start with msp430-gdb At this point Jtag device should be connected to tmote and then to PC. Tmote should be powered on either by batteries or by USB. Now enter
$ msp430-gdb blink.elf
you should get something similar to
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu
--target=msp430"...0x00004000 in ?? ()
now enter following commands
(gdb) monitor erase all
(gdb) load
(gdb) cont
at this point red led on mote should start blinking. If it does ... Congratulations. To set up eclipse you might want to take a look at [3], [4] and [5]. Somehow [3] and [4], both have conveniently missed the part of Zylin-embedded CDT, a plugin in Eclipse which can be installed from within Eclpise using update site: http://www.zylin.com/zylincdt

for this walkthrough I have heavily stolen from

[1] http://www.inf.ethz.ch/personal/muellren/jtagmsp430.html
[2] http://ge.ubuntuforums.com/showthread.php?t=796231
[3] http://www.scribd.com/doc/219845/msp430-mspgcc-eclipse-ubuntu-tutorial
[4] http://msp430.techcontent.net/wiki/index.php/IDEs/Eclipse
[5] http://homepage.hispeed.ch/py430/mspgcc/

Please send any suggestions, comments, critique to Waqaas Munawar
« November 2009 »
Su Mo Tu We Th Fr Sa
1234567
891011121314
1516 1718192021
22232425262728
2930
How does the Internet work?
Wie funktioniert das Internet?
Wie funktioniert das Internet? - Explaining the Internet to Kids
P2P'08 at RWTH
The 8th International Conference on Peer-to-Peer Computing (P2P'08)
www.p2p08.org
 

Powered by Plone