Friday, May 11, 2012

Install TinyOS under Ubuntu 12.04 or later

Installing TinyOS under Ubuntu 12.04 or 12.10 or 13.04 or 13.10


I am specifying 3 different methods for installing tinyos. There are different ways one can install. I prefer last method for advanced users and first two methods for simple use. Also, not to forget that There is a problem reported with MSP430-gcc version < 4.6.3. So, all users should make sure that they use MSP430-gcc version 4.6.3 for TelosB devices. If you want to download 4.6.3, please follow http://tinyprod.net/repos/debian/README-46.html .

When you try different methods, please make sure to remove previous installations (including toolchain).

Method 1:
1. Add software source, deb http://tinyos.stanford.edu/tinyos/dists/ubuntu lucid main to /etc/apt/sources.list

2. Type, sudo apt-get update to get new changes. Install tinyos-2.1.1 by typing sudo apt-get install tinyos-2.1.1.

3. Change the environment variables. Open the .bashrc file (sudo gedit ~/.bashrc), and add the following lines to the bashrc file:
       
       export TOSROOT=/opt/tinyos-2.1.1
       export TOSDIR=$TOSROOT/tos
       export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.$CLASSPATH
       export MAKERULES=$TOSROOT/support/make/Makerules
       export PATH=/opt/msp430/bin:$PATH
       source /opt/tinyos-2.1.1/tinyos.sh

Use command: source ~/.bashrc to update changes. 

3. Get the access authority to the tinyos folder (sudo chown usr_name:usr_name -R /opt/tinyos-2.1.1/). Also follow this 2 steps:
  • Change the ownership on your /opt/tinyos-2.x files: chown -R <your uid> /opt/tinyos-2.x
  • Change the permissions on any serial (/dev/ttyS<N>), usb (/dev/tts/usb<N>, /dev/ttyUSB<N>), or parallel (/dev/parport) devices you are going to use: chmod 666 /dev/<devicename>

4. Install tinyos jave tools. First install JNI by running "tos-install-jni". Go to "$TOSROOT/support/sdk/java/". If the directory has a Makefile in it, type make and make install.

//optional step:
5. Generate the documents of TinyOS java tools. Go to  "$TOSROOT/support/sdk/java/" , copy the the directory to another place (e.g., /home/usr_name), open the Makefile, change "JAVADOCDIR" to the intended location. Type "make javadoc" to generate the documents.

Close all editors, restart the machine. And you are done.


Method 2:

  1. Remove tinyos using : sudo apt-get remove tinyos-2.1.2
  2. Add software source, 

deb http://tinyos.stanford.edu/tinyos/dists/ubuntu lucid main
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu maverick main
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu natty main

       to /etc/apt/sources.list
      Type as instructed in bullet.
      • Type, sudo apt-get update to get new changes. Install tinyos-2.1.2 by typing sudo apt-get install tinyos-2.1.2.
      • Type: cd /opt 
      • Get tinyos repository using: sudo git clone https://github.com/tinyos/tinyos-main.git 
      • sudo cp -R /opt/tinyos-main /opt/tinyos-2.x
      • Change the ownership on your /opt/tinyos-2.x files: chown -R <your uid> /opt/tinyos-2.x
      • Change the permissions on any serial (/dev/ttyS<N>), usb (/dev/tts/usb<N>, /dev/ttyUSB<N>), or parallel (/dev/parport) devices you are going to use: chmod 666 /dev/<devicename>
           4. Copy tinyos.sh file from /opt/tinyos-2.1.2/ using: sudo cp /opt/tinyos-2.1.2/tinyos.sh /opt/tinyos-2.x/tinyos.sh (if don't have tinyos.sh file under tinyos-2.1.2, get it from tinyos-2.1.1)

             5. Change permission: sudo chmod +x /opt/tinyos-2.x/tinyos.sh

             6. Open tinyos.sh file under /opt/tinyos-2.x/ and add below lines, save and exit:

      #! /usr/bin/env bash
      # Here we setup the environment
      # variables needed by the tinyos
      # make system
      echo "Setting up for TinyOS 2.x Repository Version"
      export TOSROOT=
      export TOSDIR=
      export MAKERULES=
      TOSROOT="/opt/tinyos-2.x"
      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


              7. Type sudo gedit ~/.bashrc and add below line:
                source /opt/tinyos-2.x/tinyos.sh

        8. Install tinyos jave tools. First install JNI by running "tos-install-jni". Go to "$TOSROOT/support/sdk/java/". If the directory has a Makefile in it, type make and make install.

      Close all editors, restart the machine. And you are done.

      Method 3:

      My preferred way (difficult for some people though).
      1. Get tinyos repository using: sudo git clone https://github.com/tinyos/tinyos-main.git 
        1. cd ~ ;
        2. mkdir local/src
        3. sudo git clone https://github.com/tinyos/tinyos-main.git
      2. Get required tools using TinyOS wiki step 3. You can try converting rpm to deb using simple search on Google.  
      3. Make sure you install MSP430-gcc version 4.6.3 from http://tinyprod.net/repos/debian/README-46.html. Before installing version 4.6.3, make sure to remove previous versions from your machine, otherwise you will end up having errors in your machine.  
      4. Once everything is done, install automake using sudo apt-get install automake;
      5. Use following commands: 
        1. sudo apt-get install automake
        2.  cd tinyos-2.x/tools
        3.  ./Bootstrap
        4.  ./configure --prefix=$HOME/local
        5.  make all
        6.  make install
      6. Set environment variables under bashrc:
      7. #! /usr/bin/env bash
        # Here we setup the environment
        # variables needed by the tinyos
        # make system
        echo "Setting up for TinyOS 2.x Repository Version"
        export TOSROOT=
        export TOSDIR=
        export MAKERULES=
        TOSROOT="/opt/tinyos-2.x"
        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

        You are done. Close all editors and Enjoy. 
      Method 4:

      My preferred way (Very easy to follow).

      Follow Eric Decker's link for installation. After following his steps from 1 to 4 (and of-course "Note" mentioned)


      • cd /opt/
      • Get git repos using: sudo git clone https://github.com/tinyos/tinyos-main.git 
      • sudo cp -R /opt/tinyos-main /opt/tinyos-2.x
      • Change the ownership on your /opt/tinyos-2.x files: chown -R <your uid> /opt/tinyos-2.x
      • Create tinyos.sh file under /opt/tinyos-2.x/ and add these lines:

      #! /usr/bin/env bash
      # Here we setup the environment
      # variables needed by the tinyos
      # make system
      echo "Setting up for TinyOS 2.x Repository Version"
      export TOSROOT=
      export TOSDIR=
      export MAKERULES=
      TOSROOT="/opt/tinyos-2.x"
      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

      • Type sudo gedit ~/.bashrc and add below line: source /opt/tinyos-2.x/tinyos.sh
      • Install tinyos jave tools. First install JNI by running "tos-install-jni". Go to "$TOSROOT/support/sdk/java/". If the directory has a Makefile in it, type make and make install.

      Enjoy. 


      Please post your comments and suggestions if you find this helpful. 

      10 comments:

      BeaconK said...

      Great post. Thank you.
      After the steps, I had to install g++:
      sudo apt-get install g++

      Install python-dev
      sudo apt-get install python-dev

      and change python version to my current version (7.3) in:
      /opt/tinyos-2.1.1/support/make/sim.extra

      BeaconK said...

      I had problems running on telosb. The fix for "cannot find `Portx'" is given at:
      http://xuepengxu.blogspot.se/2012/05/tinyos-211-installation-on-ubuntu-1204.html

      Unknown said...

      Thanks a lot, that was really helpful tutorial, I just tried Blink though.

      Bo Wang said...

      Great post Dr Jenis~

      umair said...

      thanks for the great tutorial.
      for installing tinyos 2.1.2 using the following lines in sources.list isn't working

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

      I have tried these lines
      deb http://tinyos.stanford.edu/tinyos/dists/ubuntu lucid main

      and its work.

      Unknown said...

      Thank you so much ! Had been struggling with this since long :)

      lifeiscolorful said...

      hi
      m using method 2 for tinyos installation but when i run step 4 it shows error:

      cp: cannot stat `/opt/tinyos-2.1.1/tinyos.sh': No such file or directory

      what i need to do?
      thanks
      akansha

      lifeiscolorful said...

      previous problem solved but in the last step when i run make with directory /opt/tinyos-2.x/support/sdk/java...

      it shows errors
      3 errors
      make[3]: *** [DataModel.class] Error 1
      make[3]: Leaving directory `/opt/tinyos-2.x/support/sdk/java/net/tinyos/mviz'
      make[2]: *** [subdirs] Error 2
      make[2]: Leaving directory `/opt/tinyos-2.x/support/sdk/java/net/tinyos'
      make[1]: *** [subdirs] Error 2
      make[1]: Leaving directory `/opt/tinyos-2.x/support/sdk/java/net'
      make: *** [subdirs] Error 2


      plz help urgent

      Jenis said...
      This comment has been removed by the author.
      Unknown said...

      Thanks for your information, but i got some problem here.
      while i'm trying to update my package (sudo apt-get update), it gives me this error comment :

      W: Failed to fetch http://tinyos.stanford.edi/tinyos/dists/ubuntu/dists/lucid/Release.gpg Something wicked happened resolving 'tinyos.stanford.edi:http' (-11 - System error)

      W: Failed to fetch http://tinyos.stanford.edi/tinyos/dists/ubuntu/dists/lucid/main/binary-i386/Packages Something wicked happened resolving 'tinyos.stanford.edi:http' (-11 - System error)

      W: Failed to fetch http://tinyos.stanford.edi/tinyos/dists/ubuntu/dists/lucid/main/i18n/Translation-en_US Something wicked happened resolving 'tinyos.stanford.edi:http' (-11 - System error)

      W: Failed to fetch http://tinyos.stanford.edi/tinyos/dists/ubuntu/dists/lucid/main/i18n/Translation-en Something wicked happened resolving 'tinyos.stanford.edi:http' (-11 - System error)

      i don't know what to do after this occur, please help
      thanks