Search:  
Gentoo Wiki

TinyOS

Contents

Overview

This page describes how to set up your Gentoo Linux Box for using TinyOS. The document describes setting up an environment for using Telos motes - additions to this document for other mote platforms are welcome.

This document is a work in progress at the moment.

TinyOS installation

This section of the document goes parallel with the official TinyOS 2 installation guide, following it's steps one by one.

Step 1: Install Java 1.5 JDK

Simply:

emerge ibm-jdk-bin

or:

emerge sun-jdk

Step 2: Install Cygwin

This step is not needed on Linux.

Step 3: Install native compilers

Grab the TinyOS 2 portage overlay created by Aurélien Francillon, as root:

cd /usr/local
mkdir portage
svn checkout https://naurel.org/svn/tinyos-2-overlay

Also make sure to add the portage overlay directory to /etc/make.conf:

PORTDIR_OVERLAY="/usr/local/portage /usr/local/tinyos-2-overlay"

For msp430 you may want to try the crossdev version in the "tinyos overlay" and install the toolchain with

emerge crossdev 
FEATURES="-sandbox nostrip" crossdev -t msp430

Compiler install for Atmel AVR-based Motes

emerge crossdev 
FEATURES="nostrip" crossdev -t avr

The "nostrip" feature is needed because stripping ruins the libraries built by crossdev making them unusable, see http://bugs.gentoo.org/show_bug.cgi?id=207284

Alternative approach: use dedicated msp430 ebuilds

For Motes using the TI MSP430 platform, grab the portage overlay created by Matthias Transier, and untar it say to /usr/local/portage. Make sure to add this as an overlay directory to /etc/make.conf:

PORTDIR_OVERLAY="/usr/local/portage"

after this is done, emerge the following packages:

emerge msp430-binutils "=dev-embedded/msp430-gcc-3.2.3" msp430-libc "=dev-embedded/msp430-jtag-20040519"

Packages of other versions didn't seem to work, nor does msp430-gdb

Step 4 & 5: Install TinyOS

Grab the TinyOS 2 portage overlay created by Aurélien Francillon, as root:

cd /usr/local
svn checkout https://naurel.org/svn/tinyos-2-overlay

Also make sure to add the portage overlay directory to /etc/make.conf:

PORTDIR_OVERLAY="/usr/local/portage /usr/local/tinyos-2-overlay"

Ideally, it would be sufficient to emerge the tinyos ebuild, but at the moment this has to be done in multiple steps:

emerge eselect-tinyos tos
eselect tinyos set 2.0.1
env-update
source /etc/profile
emerge tinyos-tools
emerge tinyos

Set the Java CLASSPATH

Even though eselect would need to set the CLASSPATH, for some reason it does not do so. Therefore it is important to set the classpath environment variable. To do this, issue the following command, or add it to your ~/.profile or ~/.bash_rc file:

export CLASSPATH=.:/usr/src/tinyos-2.x/support/sdk/java/tinyos.jar

Trying it out

Add the user to the uucp group

To access the USB-serial port that the mote connects with to the system, add your user to the uucp group, then log out / log in for this change to take effect.

Check that the Mote is connected properly

Plug in the Mote to your machine, and see if it is listed with the motelist application. You should get something like:

$ motelist 
Reference  Device           Description
---------- ---------------- ---------------------------------------------
M4MWCK52   /dev/ttyUSB0     Moteiv Telos (Rev A 2004-04-27)

Download the sample application

To try out if it works, let's compile the (in)famous Blink application. For this, one has to get the TinyOS 2 archive, extract it, and try to compile the Blink application from there:

wget http://www.tinyos.net/dist-2.0.0/tinyos/linux/tinyos-2.0.1-5.noarch.rpm
rpm2targz tinyos-2.0.1-5.noarch.rpm
tar xfz tinyos-2.0.1-5.noarch.tar.gz
cd opt/tinyos-2.x/apps/Blink


You may prefer to copy the apps directory in /usr/src/tinyos-2.x to your working directory

cp -r /usr/src/tinyos-2.x/apps  ~/yourworkdir/
cd ~/yourworkdir/apps/Blink

Build the sample application

For Telos-based Motes, like the MoteIV TMote Sky, issue the following from the Blink application's directory, after the Mote has been connected to your machine. We'll assume the Mote is connected through the /dev/ttyUSB0 USB-serial device:

make telos install.1 bsl,/dev/ttyUSB0;

This should compile and install the Blink application.

For more information on getting started with TinyOS, see the TinyOS tutorial Lesson 1

Other examples

For other examples, follow through the TinyOS tutorial.


Help

Running crossdev fails

The libc, gcc, and binutils versions should be specified when running crossdev.

emerge crossdev 
FEATURES="nostrip" crossdev -S --libc 1.4.8 --binutils 2.16.1-r3 --gcc 3.4.6-r2 -t avr


When trying to run `make micaz` or `make mica2`, an "unknown opcode" error is produced

When trying to compile a nesc program for an avr chip, sometimes an error like this is produced.

$ make micaz
mkdir -p build/micaz
   compiling BlinkAppC to a micaz binary
ncc -o build/micaz/main.exe -Os -finline-limit=100000 -Wall -Wshadow -Wnesc-all -target=micaz -fnesc-cfile=build/micaz/app.c -board=micasb -DIDENT_PROGRAM_NAME=\"BlinkAppC\" -DIDENT_USER_ID=\"user\" -DIDENT_HOSTNAME=\"gentoo\" -DIDENT_USER_HASH=0xfb3074c7L -DIDENT_UNIX_TIME=0x4803ea6fL -DIDENT_UID_HASH=0x2e90e669L -fnesc-dump=wiring -fnesc-dump='interfaces(!abstract())' -fnesc-dump='referenced(interfacedefs, components)' -fnesc-dumpfile=build/micaz/wiring-check.xml BlinkAppC.nc -lm 
/tmp/cc7CxVQx.s: Assembler messages:
/tmp/cc7CxVQx.s:10: Error: unknown opcode `atm128powe'
/tmp/cc7CxVQx.s:12: Error: unrecognized symbol type ""
/tmp/cc7CxVQx.s:12: Error: unknown opcode `atm128powe'
/tmp/cc7CxVQx.s:13: Error: expected comma after name `McuSleepC' in .size directive
/tmp/cc7CxVQx.s:13: Error: unknown opcode `atm128powe'
/tmp/cc7CxVQx.s:14: Error: unknown opcode `mcusleepc'
...

This is due to nesc trying to use "$" in symbol names. Recent versions of gcc and binutils do not have this functionality. In order to get rid of this error, older versions of gcc and binutils must be used.

emerge crossdev 
FEATURES="nostrip" crossdev -S --libc 1.4.8 --binutils 2.16.1-r3 --gcc 3.4.6-r2 -t avr


`make micaz` or `make mica2` fails saying "/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory"

$ make micaz
mkdir -p build/micaz
   compiling BlinkAppC to a micaz binary
ncc -o build/micaz/main.exe -Os -finline-limit=100000 -Wall -Wshadow -Wnesc-all -target=micaz -fnesc-cfile=build/micaz/app.c -board=micasb -DIDENT_PROGRAM_NAME=\"BlinkAppC\" -DIDENT_USER_ID=\"illabout\" -DIDENT_HOSTNAME=\"gentoo-virtualb\" -DIDENT_USER_HASH=0xfb3074c7L -DIDENT_UNIX_TIME=0x48055402L -DIDENT_UID_HASH=0x27aee2e5L -fnesc-dump=wiring -fnesc-dump='interfaces(!abstract())' -fnesc-dump='referenced(interfacedefs, components)' -fnesc-dumpfile=build/micaz/wiring-check.xml BlinkAppC.nc -lm 
/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory
make: *** [exe0] Error 1
$

Due to Bug 147155, the correct directories do not get searched when calling ld. This can be fixed by changing $CFLAGS.

$ CFLAGS="-L/usr/i686-pc-linux-gnu/avr/lib" make micaz


Trying to use TOSSIM and Running `make micaz sim` fails with compiler warnings like "`PyObject' was not declared in this scope"

Sometimes the Python version is not set correctly in /usr/src/tinyos-2.x/support/make/sim.extra.

The sim.extra file should be edited and the line

PYTHON_VERSION=2.5

should be replaced with your python version. For example, if you are using python-2.4, the line should be changed to

PYTHON_VERSION=2.4

Doing so will remove the compiler error.

Links

Retrieved from "http://www.gentoo-wiki.info/TinyOS"

Last modified: Fri, 05 Sep 2008 10:42:00 +0000 Hits: 4,797