Pre-requisites: Before installing tinyOS itself one can start with the pre-requisites. Namely installing packages named flex, bison, python and graphviz.
$ sudo apt-get install flex
$ sudo apt-get install bison
$ sudo apt-get install graphviz
$ sudo apt-get install build-essential python-dev swig python-pygame
This is to make sure you do not get some errors related to python.
“/opt/tinyos-2.1.1/tos/lib/tossim/tossim_wrap.cxx:2501:4: error: #error "This python version requires swig to be run with the '-classic' option"”
Source: http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2010-April/045814.html
The next step is to edit the sources list (links to the packages).
Open the sources list.
$ sudo gedit /etc/apt/sources.list
Add these following lines to the end of the list.
#tinyOS
End of code, save and close the “gedit” application.
TinyOS Installation:
Enter the following command in the console to update Ubuntu with previously edited sources list.
$ sudo apt-get update
$ sudo apt-get install tinyos-2.1.x
(x is the version 2 for our example)
Next get the subversion to checkout from the tinyos repository.
$ sudo apt-get install subversion
Then update using repository using the following command
$ svn checkout http://tinyos-main.googlecode.com/svn/trunk/ tinyos-main-read-only
TinyOS is installed in the directory /opt/, go to the installed directory
$ cd /opt/tinyos-2.1.2
Create a shell script with name tinyos.sh
$ sudo gedit tinyos.sh
Copy paste the following contents to tinyos.sh :
#! /usr/bin/env bash
# Here we setup the environment
# variables needed by the tinyos
# make system
echo "Setting up for TinyOS 2.1.2 Repository Version"
export TOSROOT=
export TOSDIR=
export MAKERULES=
TOSROOT="/opt/tinyos-2.1.2"
TOSDIR="$TOSROOT/tos"
CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java:.:$TOSROOT/support/sdk/java/tinyos.jar
MAKERULES="$TOSROOT/support/make/Makerules"
export TOSROOT
export TOSDIR
export CLASSPATH
export MAKERULES
End of code, save and exit.
Update the ~/.bashrc file with Class path and Path environment variables to make running tinyos possible from anywhere.
$ sudo gedit ~/.bashrc
Add the following code to it.
#TinyOS Feb-11-2015
#Sourcing the tinyos environment variable setup script
source /opt/tinyos-2.1.2/tinyos.sh export TOSROOT="/opt/tinyos-2.1.2"
export TOSDIR=$TOSROOT/tos
export CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java
export MAKERULES=$TOSROOT/support/make/Makerules
export PYTHONPATH=$PYTHONPATH:$TOSROOT/support/sdk/python
export PATH=/opt/msp430/bin:$PATH
export APP="$TOSROOT/apps"
Save and exit.
Java versions: Requires older versions :1.4 or 1.5
Multiple versions can be installed on Unbuntu and users can switch between versions using the command:
$ sudo update-alternatives --config java
For installing older versions and using check the following link:
http://askubuntu.com/questions/469259/downgrade-java-1-7-to-java-1-5
MAKE part:
After this it is very IMPORTANT to change the permissions of the folders created so that you can execute commands without the requirement of sudo command, without which you will get the following error.
$ sudo make micaz sim
make: *** No rule to make target `micaz'. Stop.
And for plain $ make micaz sim
mkdir -p simbuild/micaz
mkdir: cannot create directory `simbuild/micaz': Permission denied
make: *** [builddir] Error
Thus you need to change the ownership of the entire folder using the command.
$ sudo chown -R username:group directory
Example: if your command line looks like:
username$ubuntu:~$
Then use:
$sudo chown -R username:username /opt/tinyos-2.1.2/
$sudo chown -R username:username /opt/tinyos-2.1.2
After this you should be able to run “make micaz sim” command that is used to simulate the applications on tossim freely.
To check go to the folder of Blink application
$ cd /opt/tinyos-2.1.2/apps/Blink
And run the command “make micas sim”
$make micaz sim
You should approximately get the following output:
@ubuntu:/opt/tinyos-2.1.2/apps/Blink$ make micaz sim
mkdir -p simbuild/micaz
placing object files in simbuild/micaz
writing XML schema to app.xml
compiling BlinkAppC to object file sim.o
ncc -c -shared -fPIC -o simbuild/micaz/sim.o -g -O0 -tossim -fnesc-nido-tosnodes=1000 -fnesc-simulate
....... (More code here)
*** Successfully built micaz TOSSIM library.
For further usage of Tossim pls consider this link:
http://www.tinyos.net/dist-2.0.0/doc/html/tutorial/lesson11.html
This article is a combination of articles from:
http://norbertobarrocablog.wordpress.com/2012/12/19/how-to-install-tinyos-2-1-2-on-ubuntu-12-04/
http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2010-April/045814.html
http://priyansmurarka.wordpress.com/2012/06/09/tiny-os-2-1-1-installation-on-ubuntu-12-04/