Wednesday, March 31, 2010

Easy installation instruction for TinyOS 1.x

I'm not an expert in TinyOS so search in google for indepth questions regarding tinyOS & hardware involved. I'm covering only the installation process here.
Installing TinyOS was cumbersome & frustrating experience for me. It took me more than one month to get it working stage. I tried to install it in 4-5 OSs many times including Xubuntos, Ubuntu, RedHat, Windows XP etc. No proper document covering all aspect of installation is available for it. I have gone through 'n' number of documents for installing it in different OS but of no help. I was running out of time allotted for my project which further added to my frustration. All those times I was trying to install it in tinyOS 2.x. So next I gave  tinyOS 1.x a try. Some steps were missing in all documents concerning tinyOS which I realised while going through TinyOS help pages archive. At last I installed tinyos-1.x in Windows XP inside VMware & Windows 7 as my host OS. Of course any VMware supporting OS can be the host OS like linux distributions. As there was no proper documents available for it, I decided to write a blog to save others from such a frustrating experience.



I recommend using VMware & install Windows XP inside it because of safety measures. And don't forget to take snapshots in VMware, after installing XP & in different stages of your progress of installing tinyOS. So that, in case you messed up while installing tinyOS, you can revert back the changes to the previous snapshot.

Follow these instructions pertaining to installing tinyos 1.x in Windows XP
1> Go here & follow the steps for installing tinyos 1.x in Windows XP -> http://webs.cs.berkeley.edu/tos/tinyos-1.x/doc/install.html
Some precautions you must follow while going through the steps.
a> Java 1.4 JDK is too outdated. I have scratched my head for many hours while finding this version. Java 1.5 jdk will not work, I have checked it & I don't think any other version will work other than 1.4. So the direct link where you should go is http://java.sun.com/products/archive/ & then look for [J2SDK/J2RE - 1.4], scroll down for 1.4.2 (initial). After that follow the instructions for choosing OS (windows) & installer (SDK). The file name is j2sdk-1_4_2-windows-i586.exe & its about 42.75MB. 
b> Javax.comm is also hard to find in sun site. So I gave google a try & I found the link here ->http://llk.media.mit.edu/projects/picdev/software/javaxcomm.zip . Download it & after that follow the instructions as they are in the site.

2> When you are finished with all instruction on installing tinyOS 1.x in Windows XP, now you have to set the environment variables which is the most important step to bring it in working stage.
 They are TOSROOT, TOSDIR, CLASSPATH, PATH & MAKERULES.
You can check the value of any variable by command "echo $TOSROOT" similarly for others(without quotes).
Commands for setting various variables -->
>export TOSROOT="/opt/tinyos-1.x/"
>export TOSDIR="$TOSROOT/tos"
>export CLASSPATH=`cygpath -w $TOSROOT/tools/java`
>export CLASSPATH="$CLASSPATH;."
>export PATH="/cygdrive/c/j2sdk1.4.2/bin:/usr/local/bin:$PATH"

One thing, I have noticed that some variables value gets omitted after restarting the terminal. So, I appended  the file [C:\Program Files\cygwin\etc\profile] at the end, instead of executing the command like above.

# make sure we start in home
cd "$HOME"
export PATH="/opt/tinyos-1.x/tools/java/net/tinyos/sim/:$PATH"
export DBG=usr1
export MAKERULES=`cygpath -w $TOSROOT/tools/make/Makerules` 

As you have installed java 1.4 jdk, a folder named j2sdk1.4.2 must be created in C: drive. One thing that I didn't found in any installation instruction was setting PATH environment variable in a proper way. I made it work by performing trial & error method & going through help archives. All paths in my PATH variable are ( paths separated by ':' ) 
Code:
/opt/tinyos-1.x/tools/java/net/tinyos/sim/:/cygdrive/c/j2sdk1.4.2/bin:/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program\ Files/ATT/Graphviz/bin:/cygdrive/c/Program\ Files/ATT/Graphviz/bin/tools

/opt/tinyos-1.x/tools/java/net/tinyos/sim/ --> for tinyviz, so that I can execute "tinyviz" command from any directory
/cygdrive/c/j2sdk1.4.2/bin --> for java integration
/usr/local/bin:/usr/bin:/bin --> to make sure I didn't miss any bin directory (all important executables) :-)
Rest of the paths are included by default or include it otherwise if it's not there.

Mind you,  your   CLASSPATH variable must contain these paths.
>Echo $CLASSPATH must return
Code:
.;C:\Program/ Files\cygwin\opt\tinyos-1.x\tools\java;C:\Program/ Files\cygwin\opt\tinyos-1.x\tools\java\jars\oalnf.jar;C:\Program/ Files\cygwin\opt\tinyos-1.x\tools\java\jars\pxgraphapplet.jar
If any path is missing, add it using the commands, I wrote above.
Note that PATH values are separated by ':' , whereas CLASSPATH values are separated by ';'. This is because, we are using cygwin type path in PATH & windows type path in CLASSPATH.
>export CLASSPATH=`cygpath -w $TOSROOT/tools/java` In this command "cygpath -w" is used to convert cygwin type of path into windows style.

Ok now, execute the command "toscheck". if you have done above steps carefully, It should complete without any error. If there is any error, read the error & try to make out what went wrong. Error will be detected if you have installed jdk 1.5.
After you gained a no error status, go here  /opt/tinyos-1.x/tools/java/net/tinyos/sim/ (cd /opt/tinyos-1.x/tools/java/net/tinyos/sim/) & execute "make" command. If there is no error then you have successfully compiled & configured tinyviz & successfully installed tinyOS.

Now goto /opt/tinyos-1.x/apps/ (>cd /opt/tinyos-1.x/apps/).
There are many folders comprising different programs in there. They are inbuilt in TinyOS to give you an understanding of tinyOS. Now, we have to test our installation. Go to TestTinyViz folder(>cd /opt/tinyos-1.x/apps/TestTinyViz) & execute the command "make pc" for compilation (only dealing with TOSSIM simulator here). After successful compilation, execute command "./build/pc/main.exe -gui 3"
build/pc/main.exe --> location of executable created.
-gui --> for graphical interpretation using tinyviz.
3 --> any no. (no.  of nodes in simulation).
After that open another terminal & execute the command "tinyviz" to see the simulation in tinyviz. You will see nodes communicating with each other in Tinyviz GUI. In my case , at  the first time launch of tinyviz, it closed automatically without showing anything. But after sometimes of repeated execution of same commads, it started working, I don't know what the problem was. I searched it in google & many people seemed to had same problem at the beginning. May be you need to restart, I don't know.

It might be possible that something might have slipped off my mind because I have installed it 4 months before writing this blog. But its very unlikely because I did it many times.  
I think, you can install tinyos-2.x in similar fashion, let me know, if it works. 


Read this pdf file for detailed explanation of TOSSIM commands. Here's another pdf for tinyOS-programming concepts. Plenty of material is available online on the subject, so search in google & subscribe to tinyOS-help mailing list for asking genuine problems to the community.   

This is the snapshot of tinyviz after successful installation.

I have worked in simulation of WSN using TOSSIM implementing Key Exchange Algorithm between nodes. Here are the snapshots.

 


I will be working in real motes & hardware soon.
I would be grateful if the people who have successfully configured tinyOS in other OSs like  Xunbutos, Ubuntu & others, could mail me, providing the complete instructions of installation.  
 Eagerly waiting for your suggestions or feedback or correction!

15 comments:

  1. Hi Kumar, following your suggestion, I am not so familiar with TinyOS, actually I am just trying to install because I have a final Activity in Network subject, and it is to implement a routing protocol using TinyOs. I got installed, at least a I think, But when a I try to open Tinyviz to simulate a simple protocol, I can't, I don't know why, So, It's possible you share a copy of your VM that have created with TinyOS and Tinyviz implemented. I am not intend to be an expert in this issue, I just want to make this simulation and finish this task dude. I really appreciate if you could help me.

    ReplyDelete
  2. me too faced problem while starting tinyviz that I already stated in the post. Just keep trying the instructions as I mentioned. Don't forget to compile the tinyviz by executing make command in its folder as I have already stated.

    ReplyDelete
  3. hi,
    do u know how to install tiny os 1.x in ubunto,or somebody who is working on this project.pls give his refrence so that i can contact him.
    surjeet115@yahoo.co.in

    ReplyDelete
  4. sorry, I don't know anyone personally who had installed tinyos 1.x in ubuntu.

    ReplyDelete
  5. hi
    how to compile a simple blink program without mote, help me I'm new to this

    ReplyDelete
  6. Execute 3 commands
    1 for changing dir to blink folder
    cd /opt/tinyos-1.x/apps/Blink

    2 to compile
    make pc

    3 to execute
    ./build/pc/main.exe -gui 3


    please read above post!

    ReplyDelete
  7. Do you know if I can install both tinyos-1.x and tinyos-2.x on cygwin. Are there any instructions available online?

    ReplyDelete
  8. May be as they are installed at different paths. But I'm not sure as both may have different environment variables which will create conflicts.

    ReplyDelete
  9. Hey Dude please improve your sense of Design and colors that should be used to enhance the readability...

    ReplyDelete
  10. I don't see any problem with the readability unless someone is color blind..
    Can you be more specific.. dude?

    ReplyDelete
  11. hello
    please what version of vmware you used in this installation?
    thanks

    ReplyDelete
  12. Use the latest version, it doesn't matters much because tinyos is installed inside XP. The steps given above is only for tinyos simulator, not for hardware sensor motes configuration.

    ReplyDelete
  13. Hi,

    Is your VMware image available for download?
    I'm trying to get tinyviz working on Ubuntu but It didn't work. Everything is working fine and running but TinVzi can't list or detect any events.

    Thanks,

    mrehan

    ReplyDelete
  14. Hello,
    Each time one i execute make pc
    I get a lot of messages from this kind: child state waiting for longjmp
    then an error appears: make: *** [build/pc/main.exe] Error 1

    SO please can any one help me. I need that too much.
    Thanks

    ReplyDelete
  15. Hy! make pc command does not run in tinyos on virtual machine?

    ReplyDelete