TinyOS

From EECS

Jump to: navigation, search

There seem to be several versions of TinyOS. The 1.1 version is the stable (and old) one, while 2.0 is reaching release state. It seems that different tools (or at least different versions of the same tools) are needed to compile different TinyOS versions.

Hardware list: https://trac.eecs.iu-bremen.de/projects/netlab/wiki/motes_list

Contents

Linux kernel support

To be able to program the motes, sub-serial converter support is needed in the Linux kernel. This can be enabled under

Device Drivers  ---> USB support  ---> USB Serial Converter support  ---> 

The

USB FTDI Single Port Serial Driver

supports the particular hardware of the telosb (0403:6001) motes and the mib520 board (0403:6010) used for programming the micaz motes.

Motes or the programming board should then show up as

/dev/ttyUSB0

or similar.

TinyOS 1.1

install debian packages from http://thomer.com/tinyos/ o avr-binutils_2.13.2.1-2_i386.deb o avr-gcc_3.3tinyos-2_i386.deb o avr-libc_20030512cvs-2_i386.deb o nesc_1.1.2a-2_i386.deb o tinyos-tools_1.1.0-2_i386.deb

The tinyos toolchain setup can be checked with

toscheck

install java from /usr/local/deb/ on meat (probably not needed)

fetch TinyOS as rpm

wget 'http://www.tinyos.net/dist-1.1.0/tinyos/linux/tinyos-1.1.15Dec2005cvs-1.noarch.rpm'

convert to a debian package

fakeroot alien tinyos-1.1.15Dec2005cvs-1.noarch.rpm

install the new package

sudo dpkg -i tinyos_1.1.15Dec2005cvs-2_all.deb

Now TinyOS sources should be installed in /opt/tinyos-1.x/. To make things easier, just chown -R the whole source tree to your user.

sudo chown -R harvan:harvan /opt/tinyos-1.x

This is wrong, sources should go into use's ~/src, but getting a package is so easy... Besides that, checking out sources form the cvs server did not work. Next, compile the Blink application for the simulator

cd /opt/tinyos-1.x/apps/Blink
make pc

If all went well, start the Blink application in the simulator (should be TOSIM)

build/pc/main.exe  1

There will be a lot of output, which probably means success ;)

Seom documentation about the simulator can be found at http://www.tinyos.net/tinyos-1.x/doc/nido.pdf.

The simulator target would be something like

make <mote type> sim

TinyOS 2.0

TinyOS 2.0 has been set up on meat (running Debian GNU/Linux).

The following howtos were useful

Java 1.5 has been installed using the Debian sun-java5-jdk package.

The cross-compilers for avr and msp430 platforms and tinyos/nesc-related tools have been installed from the rpms on the tinyos page (after converting them to debs with alien). TinyOS sources from the rpm package are in

/opt/tinyos-2.x/

The cvs version is in

/opt/cvs/tinyos-2.x/

It has been checked out using the following commands

cvs -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login
cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co tinyos-2.x

The rpm and deb packages and a basic script for setting environment variables are on meat in

/home/harvan/tinyos/

In order to compile TinyOS/nesC code, following environment variables have to be set

# set up  environment variables for TinyOS 2.0
# usage (in bash): source env.sh

# adjust TOSROOT to the directory where you have TinyOS sources
export TOSROOT="$HOME/tinyos/tinyos-2.x"
#export TOSROOT="$HOME/tinyos/tinyos-2.x.cvs"
#export TOSROOT="/opt/tinyos-2.x"

export TOSDIR="$TOSROOT/tos"
export CLASSPATH="$CLASSPATH:$TOSROOT/support/sdk/java/tinyos.jar:."
export MAKERULES="$TOSROOT/support/make/Makerules"
#export PYTHONPATH=:$TOSROOT/support/sdk/python/

# for MSP430 platform/tools only
export PATH="/opt/msp430/bin:$PATH"

A copy of the script is on meat in /home/harvan/tinyos/env.sh. A fancier script is in one of the howtos.

The setup has been tested and work for both micaz and telosb motes. TinyOS code can be compiled and uploaded via USB to the motes.

Setup for individual users on meat

Students who want to start playing with TinyOS on meat can set up a copy of the TinyOs source tree in the following way:

cd
mkdir tinyos
cd tinyos
cp /home/harvan/tinyos/env.sh .
cp -r /opt/tinyos-2.x .

Note that you may prefer to use the cvs version rather than the packaged (older) one. Instructions for checking it out from cvs are provided above.

Before you can use the toolchain, you have to source the script with environment variables (you may want to add this to your shell init file, i.e. ~/.bashrc)

source ~/tinyos/env.sh

Compiling and installing sample applications

Compile the Blink application for telosb

cd ~/tinyos/tinyos-2.x.cvs/apps/Blink
make telosb

Compile and upload to the mote with

make telosb install bsl,/dev/ttyUSB0

For micaz, you would compile and install with

make micaz install mib510,/dev/ttyUSB0

To also use the MTS300 sensorboard with the micaz do

SENSORBOARD=mts300 make micaz install mib510,/dev/ttyUSB0

You may want to look into the TinyOS 2.0 tutorial http://www.tinyos.net/tinyos-2.x/doc/html/tutorial/index.html .

Other Operating Systems

Ubuntu

TinyOS 2.0 Debian repository for Ubuntu "Edgy". From http://tinyos.net/scoop/story/2007/3/1/142950/4912:

You must still follow the installation instructions for configuring your environment variables. Just point your system to

deb http://tinyos.stanford.edu/tinyos/dists/ubuntu edgy main

And you can

sudo apt-get install tinyos-avr 

and

sudo apt-get install tinyos-msp430

Uninstall the brltty package as it makes the /dev/ttyUSB0 device node go away

sudo aptitude purge brltty

MacOS X

A howto for MacOS X can be found at http://www.inf.ethz.ch/personal/muellren/tinyosonmac.html.

FreeBSD

Some information is available at http://www.eecs.harvard.edu/~mainland/tinyos/.

The avr and msp related cross-compilation tools are available in FreeBSD ports. nesc and TinyOS tools would probably have to be installed directly from sources. This has not been tested.

However, an attempt was made to upload pre-built images onto TelosB and MicaZ motes from a FreeBSD machine. The images were built on a Debian machine and transfered to the FreeBSD machine. The tools for uploading have been built from sources. Note that before connecting the motes via usb the ftdi kernel module had to be loaded

kldload uftdi.ko
  • TelosB

The following patch for the FreeBSD kernel is needed: http://www.sics.se/~bg/telos/freebsd.patch

cd tinyos-2.x.cvs/tools/platforms/msp430/pybsl
sudo python tos-bsl --telosb -c /dev/ttyU0 -r -e -I -p  /tmp/main.ihex.out-1

This has worked fine. however, without the ucomm patch, tos-bsl could not talk to the TelosB mote.

  • MicaZ
cd tinyos-2.x.cvs/tools/platforms/mica/uisp
./bootstrap
./configure
make
sudo ./src/uisp -dprog=mib510 -dserial=/dev/ttyU0 --wr_fuse_h=0xd9 -dpart=ATmega128 --wr_fuse_e=ff  --erase --upload if=/tmp/main.srec.out-11

This has worked fine.

Sensors

This section shows code to access sensors using TinyOS 2.x only.

Some formulas for conversion from ADC counts to more sensible units can be found in tinyos-1.x/contrib/xbow/tools/src/xlisten/xconvert.c and tinyos-1.x/contrib/xbow/tools/src/xlisten/boards/mts300.c'

In general, the sensors provide a Read interface, which can be used to obtain the sensor values.

TelosB

TelosB has following sensors

  • Visible Light Sensor (Hamamatsu S1087)

Drivers are in tos/platforms/telosa/chips/s1087, component HamamatsuS1087ParC

Usage with the Oscilloscope application:

configuration OscilloscopeAppC { }
implementation
{
   ...
   components new HamamatsuS1087ParC() as Sensor
   ...
   OscilloscopeC.Read -> Sensor;
   ...
}
  • Visible to IR Light Sensor (Hamamatsu S1087-01)

Drivers are in tos/platforms/telosa/chips/s10871, component HamamatsuS10871TsrC

  • Humidity Sensor (Sensirion SHT11)

Drivers are in tos/platforms/telosa/chips/sht11, component

Following formula can be used to convert from ADC counts to temperature (Sensirion sample code http://www.sensirion.com/pdf/product_information/Sample_Code_humidity_sensor_SHTxx.pdf, page 3)

hum_lin [%] = -0.0000028*data*data + 0.0405*data-4

Temperature compensated humidity:

hum [%] = (temp-25)*(0.01+0.00008*data)+lin_hum

The sensor seems to also have a heater which can be turned on/off.

  • Temperature Sensor (Sensirion SHT11)

Drivers are in tos/platforms/telosa/chips/sht11, component SensirionSht11C

Following formula can be used to convert from ADC counts to temperature (from comments in TinyOs sources)

tmp [deg C] = -38.4 + 0.0098 * data

Sensirion sample code http://www.sensirion.com/pdf/product_information/Sample_Code_humidity_sensor_SHTxx.pdf, page 3 gives

tmp [deg C] = -40 + 0.01 * data
  • Voltage Sensor (CPU built-in)

Drivers are in tos/chips/msp430/sensors, component Msp430InternalTemperatureC.nc

  • Voltage Sensor (CPU built-in)

Drivers are in tos/chips/msp430/sensors, component Msp430InternalTemperatureC.nc

Following formula can be used to convert from ADC counts to temperature:

voltage [V] = data/4096*3
  • Temperature Sensor (CPU built-in)

Drivers are in tos/chips/msp430/sensors, component Msp430InternalTemperatureC.nc

Following formula can be used to convert from ADC counts to temperature:

tmp [deg C] = ((data/4096*1.5) - 0.986)/0.00355

MicaZ

There are no sensors on the MicaZ directly, you need an additional sensorboard.

MST300 (Mica sensorboard)

The MST300 sensorboard can be attached to the MicaZ nodes. Drivers are in tos/sensorboards/mts300. A sample application is in apps/tests/mica2/mts300. It needs a few modifications to run on our mtoes/sensorboards. Note that the drivers are not in the rpm-packaged sources, so cvs version is needed. Furthermore, the example is using a slightly different interface than the one described below.

The connector on the mica platform is a major source of trouble. To check that the board is indeed properly connected to the mote, it is a good idea to regularly turn on and off the sounder. Just turning it on is not sufficient, as it keeps beeping even after being turned off in software if the sensorboard is not properly attached. Furthermore, there might be a good connection between the board and the mote, but once you relase pressure on the board/mote the connection might break.

For compiling, the SENSORBOARD variable has to be set

SENSORBOARD=mts300 make micaz

The sensorboard provides following sensors/devices

  • Temperature Sensor (???)

Drivers are in tos/sensorboards/mts300, component TempC

Using this sensor/component seems to hang the mote sometimes, or at least prevent it from blinking the leds and sending packets over the radio. Furthremore, no usefull temperature readings have been obtained from the sensor yet. Either there are no readings or the readings are constant, ingoring the changing environment temperature.

  • Light Sensor (???)

Drivers are in tos/sensorboards/mts300, component PhotoC

  • Acoustic Sensor (microphone) (???)

Drivers are in tos/sensorboards/mts300, component MicC

  • Buzzer (speaker) (???)

Drivers are in tos/sensorboards/mts300, component SounderC The sounder can be controlled using the start and stop functions.

cofiguration BlinkAppC {}
implementation {
...
components SounderC
...
BlinkC.Sounder -> SounderC
...
module BlinkC
{
  ...
  uses interface StdControl as Sounder;
  ...
}
implementation
{
   ...
   call Sounder.stop();
   ...
   call Sounder.stop();
   ...

Except for temperature sensor, all components on the board seem to be supported and work well. Using the temperature/light sensor might interfere with using the radio interface due to hardware design.

The board also seems to be well supported in TinyOS 1.x (see tinyos-1.x/apps/MicaSBVerify/MicaSBTest2).

Personal tools