Wednesday, December 7, 2011

Installing TinyOS in Ubuntu 10.10

Even though almost all the works I was doing in sensor networks are implemented using Contiki OS, recently I had to install TinyOS and play with it as a course work. Therefore for the first time I used TinyOS and it seems OK. Even though NesC is a little bit painful than pure C used in Contiki, I think I can adapt to it.

I thought to write down the steps I followed to install TinyOS in my machine before my memory get overwritten by something new. There are different variations of TinyOS available and its installation is little bit complicated. This is the way I did as I was instructed. Here I have set up the required tool chains for AVR micro-controller based platforms. There may be different packages required to compile for different other platforms.

1) There are some repositories we have to put in our sources.list file to install TinyOS. Therefore add the two lines shown below to the sources.list file (/etc/apt/sources.list) of your Ubuntu system.

2) If you don't have synaptic package manager in your system, now it's better to install it before going further,

sudo apt-get update
sudo apt-get install synaptic 

3) Now in the terminal issue the following command to install TinyOS, (this step may take some time)

sudo apt-get install tinyos-2.1.1

4) The next step is to install avr-libc package. But there's problem. When you follow the previous step, some of the tools comes with avr-libc gets installed an therefore some package inconsistency problems may occur. Therefore its better to remove those unnecessary additional packages came with TunyOS installation.

sudo apt-get remove avr-binutils-tinyos avr-gcc-tinyos

5) Now lets install avr-libc package,

sudo apt-get install avr-libc

6) Now open .bashrc file of your home directory and add the following line.
To open the file,

 sudo gedit .bashrc

Add the following line to the end of that file, save and close.

source /opt/tinyos-2.1.1/

7) Now python-dev package is required. So, we install it by issuing the command,

sudo apt-get install python-dev

8) Python version of the system is written in a configuration file of TinyOS. Therefore we have to edit it to make it have the current python version. To find it enter the following in the terminal,

python --version

There we can see the version of python. Open the configuration file by issuing the following command,

sudo gedit /opt/tinyos-2.1.1/support/make/sim.extra

There's a line in that file which starts as PYTHON_VERSION. Change it to have the correct python version in your system.

Now we have installed TinyOS in our system. I will write a separate post about burning an example TinyOS application to a mote.


  1. This truly is a great article. After several failed attempts from other tinyos installation guides, i finally found this page which did the trick for me. However, i had to perform a few additional tasks to make it work:

    1)- change the above-mentioned PYTHON-VERSION as follows:

    PYTHON_VERSION ?= $(shell python --version 2>&1 | sed 's/Python 2\.\([0-9]\)\.\([0-9]\)+\{0,1\}/2.\1/')

    2)- Add the following line to the end of the file \opt\tinyos-2.1.1\

    export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.

    3)- Execute the following command (required for SerialForwarder):

    sudo tos-install-jni


  2. It's nice to hear that my article was useful to you. :)
    And thank you very much for your additional information regarding this!!!!!

  3. Thanks a ton Asanka.... Even I was struggling to install tinyOS before I found your article ... You made the installation look so simple... Thanks again...

  4. Just one or two more things which I felt are equally important... How to compile and check if tinyOS is installed...

    Once the last step of changing the the PYTHON VERSION is done, one should know how to compile an application. It is better to restart the system once for all the script files to run once.

    Once booted, go to /opt/tinyos-2.1.1/ folder and issue the command: sudo chmod -R 777 . so that you set all the permissions for the subfolders also.

    Once the permissions are set, then go to /opt/tinyos-2.1.1/apps/Blink/ folder and type make iris.

    The output of the command looks like this indicating the compilation of the BlinkC application:

    mkdir -p build/iris
    compiling BlinkAppC to a iris binary
    ncc -o build/iris/main.exe -Os -fnesc-separator=__ -Wall -Wshadow -Wnesc-all -target=iris -fnesc-cfile=build/iris/app.c -board=micasb -DDEFINED_TOS_AM_GROUP=0x22 --param max-inline-insns-single=100000 -DIDENT_APPNAME=\"BlinkAppC\" -DIDENT_USERNAME=\"ims-lab\" -DIDENT_HOSTNAME=\"imslab-ThinkPad\" -DIDENT_USERHASH=0x37c6d44eL -DIDENT_TIMESTAMP=0x503e06b6L -DIDENT_UIDHASH=0xf9760d4eL -fnesc-dump=wiring -fnesc-dump='interfaces(!abstract())' -fnesc-dump='referenced(interfacedefs, components)' -fnesc-dumpfile=build/iris/wiring-check.xml -lm
    compiled BlinkAppC to build/iris/main.exe
    2270 bytes in ROM
    51 bytes in RAM
    avr-objcopy --output-target=srec build/iris/main.exe build/iris/main.srec
    avr-objcopy --output-target=ihex build/iris/main.exe build/iris/main.ihex
    writing TOS image

    And you are game...

  5. Thanks Prashant, your additional details will be really useful for anyone wishing to work in TinyOS. Great!