Wednesday, December 7, 2011

Using example blick application in TinyOS

TInyOS comes with some example applications to try out before we write a single NesC code. You can find them in the directory /opt/tinyos-2.1.1/apps. In this post I write down how to try the example blink application provided by TinyOS on a MicaZ mote.

If you still haven't installed TinyOS in your Ubuntu system do it. My previous post may help on this. This is the steps I follow to try the blink application.

1) Plug the MIB510 program board to power supply and switch it on. Plug a MicaZ mote to the program board via its 51pin connector.
MIB510 program board
MicaZ mote

2) Open the file located at /opt/tinyos-2.1.1/support/make/Makedefaults and add the following two lines to it,


3) Now in the terminal give the following two commands to burn the example blink application to MicaZ mote.

cd /opt/tinyos-2.1.1/apps/Blink
sudo make micaz install

After the MicaZ motes flash memory is written with the app, you will see that three LEDs on the MIB510 program board are blinking. That is the output of the blink program which come to the program board since they are connected. If you remove the MicaZ mote from the program board, put batteries on it and switch it on, you will see the program output as blinking LEDs on the mote.

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.