TinyOS on GINA
This page describes how to port TinyOS for the Gina platform.
Overview
Two steps are involved when using TinyOS on motes: compiling nesC code into binaries then flashing those binaries onto the hardware. In adding support for a new platform, those two steps have to be kept in mind.
Gina comes with the MSP430 processor and the AT86RF231 radio. Though the MSP is already supported in TinyOS and both the RF230 and RF212 have ports, it was not a simple task to add support for Gina. The reason is that the version of the MSP on Gina is 2618 while Telos and other motes had the MSP430f1611. Therefore, we needed to add a port for family 2xxx MSP to tinyos (a specific msp430-gcc and MSP430x2xxx TinyOS drivers). Luckily, this had been done before by a startup called Zolertia. They make a mote very similar to the Telosb but with a family 2 MSP. However, the tools they had built for their z1 mote needed a special C compiler: gcc3.4. This is why we decided that the easiest way to start off would be to get a stable OS that came with this version of gcc (step1). Steps 2, 3 and 4 complete adding support for compiling gina specific code onto TinyOS.
Steps 5 to 9 deal with making possible programming Gina motes with the compiled TinyOS code. In fact, compiling on TinyOS generates binaries specific to the processor of choice. One of those files comes in the intel-hex format and can therefore be flashed directly onto the MSP, using the MSP-FET430UIF tool. But this wasn't straightforward. The reason is that TI, who made the JTAG proprietary protocol, did not make it open enough so that developers could make an open-source solution. Before we get into the details of the installation process, one should know that the way to program on Linux through JTAG is to start a GDB proxy server that listens on a specific port and keep that server running in the background, and then flashing the binaries to the processor through that server. Starting the GDB proxy server required files that had to be brought from a working version of IAR on Windows (Steps 5 to 9).
Installation Steps
NOTE: before you start bear in mind that the tinyos version you are downloading is more recent than the one found here. Make changes in the commands accordingly.
- Get Ubuntu 8.04 (because it comes with gcc3.4)
Open Synaptic Package Manager then
Settings->Repositories->Third-Party Software
: add the following linedeb http://tinyos.stanford.edu/tinyos/dists/ubuntu hardy main
From a terminal window type:
sudo apt-get update sudo apt-get install tinyos-2.1.0
Get the
zolertia z1 support package
from https://sourceforge.net/projects/zolertia/files. You should download a file of the form:tinyos-z1-xx-xx_i386.deb
cd to the directory where you downloaded it and type:
sudo dpkg -i tinyos-z1-xx-xx_i386.deb sudo chown -R <my_username>:<my_username> /opt/tinyos-2.1.0/
- Extract
gina20.zip
to/opt/tinyos/tos/platforms/
and copygina20.target
to/opt/tinyos/support/
Pump up a terminal in your home directory and edit file
.gdbinit
; add the following lines:set remoteaddresssize 16 set remotetimeout 999999 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
Edit file
/etc/udev/rules.d/26-ti.rules
; add the following lines:SUBSYSTEM=="usb", ACTION=="add", ATTR{product}=="MSP-FET430UIF JTAG Tool", \ ATTR{bNumConfigurations}=="2", ATTR{bConfigurationValue}="2", \ GROUP="dialout" SUBSYSTEMS=="usb-serial", DRIVERS=="ti_usb_3410_5052_1", \ SYMLINK+="ttyUSBfet430"
This is to set the
bConfigurationValue
of the TI usb device to "2" everytime it is connected. After finishing all those steps, connect the MSP-FET430UIF to your computer and typedmesg
in your terminal. You should see something like:[ 2243.126136] usb 2-1: TI USB 3410 1 port adapter converter now attached to ttyUSB0
If this fails (e.g. something with "error -5" contact chraim@berkeley.edu)
Open Synaptic again and get
wine
. From a terminal, typewinecfg
Under
drives
, click on "add" then "ok". In a terminal, type:mkdir -p ~/.wine/dosdevices ln -s /dev/ttyUSBfet430 ~/.wine/dosdevices/com1
Now comes the tricky part. From a terminal, type:
mkdir -p ~/.wine/drive_c/msp430 cd ~/.wine/drive_c/msp430
- 'Now to this new directory
~/.wine/drive_c/msp430/
, we want to copymsp430-gdbproxy.exe
,HIL.dll
andMSP430.dll
.
Those NEED to be compliant with your FET430-UIF firmware version.
Install IAR on Windows, connect the FET tool and update its firmware (it may not ask for a firmware update). Make sure your FET tool works. Search the IAR directory (something like C:\Program Files\IAR
) for HIL.dll
and MSP430.dll
(beware that, in Linux, the names of those files are case sensitive, so they should be renamed as it appears here).
I forgot how I got msp430-gdbproxy.exe but I think that I installed mspgcc-20081230.exe from the mspgcc website. It's the windows tool as well.
Connect the FET tool, open a terminal and type:
wine c:/msp430/msp430-gdbproxy.exe -p 2000 msp430 COM1
This starts the GDB proxy. Keep this running in the background and open a new terminal:
cd /opt/tinyos/apps/Blink make gina20 cd /build/gina20 msp430-gdb main.ihex monitor reset erase load main.ihex cont
Et Voila!