Thursday, March 8, 2012

Install Tiny OS in Ubuntu 11.10 from Ubuntu repository

These configurations are done for tiny os to work with Telosb mote.

1. Need to install java first. Follow the following steps.
    (a) Login as Root.
      sudo -i
    (b) Install "python-software-properties" package.
      apt-get install python-software-properties
    (c) Add proper Repo for Java package.
      add-apt-repository ppa:ferramroberto/java
    (d) Now install java packages.
      apt-get install sun-java6-jdk sun-java6-plugin

2. Add tiny os repo to your sourcelist.
      gedit /etc/apt/sources.list

3. Add following to your sourcelist.
      deb http://tinyos.stanford.edu/tinyos/dists/ubuntu hardy main
      deb http://hinrg.cs.jhu.edu/tinyos oneiric main

4. Give update.
      apt-get update

5. Install tiny os from the added repo.
      apt-get install tinyos-2.1.0

6. Edit your bashrc file for setting up tiny os environment after booting.
      (a) gedit ~/.bashrc

      (b) Add following line to bottom of the .bashrc file.
             source /opt/tinyos-2.1.0/tinyos.sh
             export CLASSPATH=$TOSROOT/support/sdk/java/tinyos.jar:.

7. Save bashrc file.
      source ~/.bashrc

8. Run this command to avoid error with java.
      tos-install-jni

9. Install g++ to avoid some error.
      apt-get install g++

10. Now you can run your first tiny os Blink program.
        (a) cd /opt/tinyos-2.1.0/apps/Blink
        (b) make telosb

11. Enjoy


Possible Errors

Note: These are all the errors i faced while running Tiny OS in Ubuntu 11.10.

1. While running "java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSB0:telosb" you may get the following error.

The toscomm JNI library was not found. check that your tiny-os package is installed and try rerunning tos-install-jni

Can solve this by the following method.

  (a) Open the bashrc file.
          vim ~/.bashrc
  (b) Add path for the jre binaries.
       Add this line at the bottom most part of bashrc file with out double quotes.
         "export PATH=/usr/lib/jvm/java-6-sun/jre/bin:$PATH"
  (c) Run this command.
         "tos-install-jni"
  (d) Enjoy.

2. Error due to java, while running the java command for serial communication.

      Eg:
             java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:telosb

      Exception in thread "main" java.lang.NoClassDefFoundError: net/tinyos/tools/Listen
Caused by: java.lang.ClassNotFoundException: net.tinyos.tools.Listen
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: net.tinyos.tools.Listen.  Program will exit.

  (a) Download "java" tar file from the Tiny OS CVS repository: http://tinyos.cvs.sourceforge.net/viewvc/tinyos/tinyos-2.x/support/sdk/java/
  (b) Untar and keep it in /opt/tinyos-2.1.0/support/sdk instead of existing java folder there.
  (c) Go inside the java folder in terminal and give "make" command.
  (d) Enjoy.

8 comments:

  1. i have problems when compiling RadioSenseToLeds application , 100 errors
    make: *** [RadioSenseMsg.class] Error 1

    ReplyDelete
    Replies
    1. Hello,
      I had installed Tinyos-2.1.1 in ubuntu 11.10
      but when i try to run : make telosb
      an error will be displayed :

      please help me

      PS : when i type : make micaz or make mica2 , the compilation is done normally !!

      Delete
    2. Hi Amouna,
      Can you mention what is the error you are getting.

      Delete
    3. Hi Allaahamed,

      Please mention the error you are getting.

      Delete
    4. hi I got the same problem with the amouna 100errors in radiosenseMsg.
      the partly errors are the following

      root@ubuntu:/opt/tinyos-2.1.1/apps/RadioSenseToLeds# make mica2
      mkdir -p build/mica2
      javac RadioSenseMsg.java
      RadioSenseMsg.java:88: unclosed string literal
      s += " [nx_struct radio_sense_msg 4 7
      ^
      RadioSenseMsg.java:89: illegal start of expression
      =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
      ^
      RadioSenseMsg.java:89: hexadecimal numbers must contain at least one hexadecimal digit
      =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
      ^
      RadioSenseMsg.java:89: unclosed string literal
      =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
      ^
      RadioSenseMsg.java:89: ';' expected
      =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
      ^
      RadioSenseMsg.java:90: illegal start of expression
      ())+"]\n";
      ^
      RadioSenseMsg.java:90: ';' expected
      ())+"]\n";
      ^
      RadioSenseMsg.java:90: not a statement
      ())+"]\n";
      ^
      ^
      100 errors
      make: *** [RadioSenseMsg.class] Error 1
      root@ubuntu:/opt/tinyos-2.1.1/apps/RadioSenseToLeds#

      Delete
  2. hi I got the same problem with the amouna 100errors in radiosenseMsg.
    the errors are hte following

    root@ubuntu:/opt/tinyos-2.1.1/apps/RadioSenseToLeds# make mica2
    mkdir -p build/mica2
    javac RadioSenseMsg.java
    RadioSenseMsg.java:88: unclosed string literal
    s += " [nx_struct radio_sense_msg 4 7
    ^
    RadioSenseMsg.java:89: illegal start of expression
    =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
    ^
    RadioSenseMsg.java:89: hexadecimal numbers must contain at least one hexadecimal digit
    =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
    ^
    RadioSenseMsg.java:89: unclosed string literal
    =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
    ^
    RadioSenseMsg.java:89: ';' expected
    =0x"+Long.toHexString(get_nx_struct radio_sense_msg 4 7
    ^
    RadioSenseMsg.java:90: illegal start of expression
    ())+"]\n";
    ^
    RadioSenseMsg.java:90: ';' expected
    ())+"]\n";
    ^
    RadioSenseMsg.java:90: not a statement
    ())+"]\n";
    ^
    ^
    100 errors
    make: *** [RadioSenseMsg.class] Error 1
    root@ubuntu:/opt/tinyos-2.1.1/apps/RadioSenseToLeds#

    ReplyDelete
  3. I think the java path is not set properly or may be a "make" command inside /opt/tinyos-2.x/support/sdk/java folder may help. That is because your jar files may not be compiled properly.

    ReplyDelete
  4. yeah, the problem I believe is caused by the tinyos install after reinstall the whole tinyos, the problem is solved

    ReplyDelete