Monday, September 3, 2012

Installing Contiki 2.6 and Cooja Simulator in Ubuntu 12.04


Are you working with WSN or IoT? Probably you have heard about Contiki. Since a while I'm interested in using Contiki like operative system for a wireless sensor network. In this post I'm going to explain you how to install it in Ubuntu. Please read more about in the contiki page project http://www.contiki-os.org. In that page you can download "Instant Contiki", which is an virtual image disk where is ubuntu installed and all the contiki related things (cooja,contiki os, eclipse IDE for programming) configured, ready to use. But if you'd rather install it by your own, follow the next steps

1) Download contiki source from here.

2) Unzip the contiki-2.6.zip file

3) Try if Contiki works running an example from directory "examples". To compile the hello-world example,


cd contiki-2.6/examples/hello-world 
make TARGET=native
./hello-world.native

You should see the following output

Contiki 2.6 started
Rime started with address 2.1
MAC nullmac RDC nullrdc NETWORK Rime
Hello, world


After testing that hello world example you can clean the temporary files created during the compilation,

make clean


4) Procede installing java, because the cooja is a java based simulator,

sudo apt-get install openjdk-6-jdk

5) To compile cooja, install ant which is a compile tool,

sudo apt-get install ant


6) To compile and start cooja I gave the commands,cd tools/cooja

ant run

To remove all the temporary files created during the compilation, use ant clean 

7) If you're a begginer with Contiki OS I strongly recommend you to read the Getting started section step 3 for running Contiki on Cooja simulator.

Enjoy it!! :)





19 comments:

  1. Everytime I run the ant run command it gives the following error-

    ERROR:JAVA_HOME is not defined correctly.
    We cannot execute /usr/java/jdk1.7.0_09/bin/java/bin/java

    ReplyDelete
    Replies
    1. I had that problem as well
      I tried sudo apt-get install openjdk-7-jdk
      and that did the trick since I'm using 7 not 6

      Delete
  2. 1) Make sure you have java installed. Type the following in a terminal:
    java -version
    Can you see the output?

    2) It seems you need to set up the environmental variable JAVA_HOME. You have to put the path which indicates where the jdk was installed. More info about how to set up JAVA_HOME in the next link

    http://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html

    ReplyDelete
  3. 1) I already checked the java version.It shows--> 1.7.0_09

    2) I followed the link you mentioned but it is still showing the same error.

    ERROR:JAVA_HOME is not defined correctly.
    We cannot execute /usr/java/jdk1.7.0_09/bin/java/bin/java

    ReplyDelete
  4. How did you define JAVA_HOME? Which java did you installed (oracle, openjdk,etc)? Did you check you the permissions? Please give me more detail to help you.

    ReplyDelete
  5. JAVA_HOME is defined in the following way in the bashrc file-
    export JAVA_HOME=/usr/java/jdk1.7.0_09/bin/java/bin/java
    export PATH=$/usr/java/jdk1.7.0_09/bin/java/bin/java/bin:$PATH

    I downloaded java jdk from the oracle website..

    ReplyDelete
  6. Try JAVA_HOME=/usr/lib/jvm/jdk1.7.0_09 and PATH=$PATH:$JAVA_HOME/bin. Let me know if works

    ReplyDelete
  7. I know this is probably not the place to post it but I've installed contiki and I'm using cooja to simulate a WSN but i don't understand how its coding works, I'm trying to simulate a master-slave architecture, where the master mote only receives data from the slave motes and the slave motes only send to the master, but I don't know how to implement it in code form, please can you help me, because I can't find anything that would help me on Google.

    ReplyDelete
  8. how to connect a xbee series 2 module to contiki os via cooja

    ReplyDelete
  9. Hi , i use a ubuntu 12.04 and i install cooja i have this error in compling : JAVA_HOME environment variable not set , cooja mote can not compile , i taped apt-get install binutils-msp430 gcc-msp430 msp430-lib msp430mcu mspdebug ant openjdk-7-jdk . can you help me plz . best regards

    ReplyDelete
    Replies
    1. plz how did you resoute the problem
      i have the same problem

      Delete
  10. About JAVA_HOME environment variable please read more info in the following pages:

    http://docs.oracle.com/cd/E19509-01/820-3208/6neopagg5/

    http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/

    ReplyDelete
  11. If you need to set JAVA_HOME it can be set by carrying out the following to your ~/.bashrc

    nano ~/.bashrc

    then add the following and save the changes

    export JAVA_HOME="/usr/lib/jvm/jdk-7-oracle-armhf"
    export PATH=$PATH:$JAVA_HOME/bin

    when you next login try typing:

    export

    you will see a list of values, one of which should be

    declare -x JAVA_HOME="/usr/lib/jvm/jdk-7-oracle-armhf"

    ReplyDelete
  12. instead 2.6 can i use instant contiki 2.7 in ubuntu 12.04??
    plz help me to install.. :(

    ReplyDelete
  13. when i m trying to run hello-world example it is giving me 'bash: cd: contiki/examples/hello-world: No such file or directory' such error.. plzz help me to run that example :'(

    ReplyDelete
  14. when I am trying to run hello-world example it is giving an error 'bash: cd: contiki/examples/hello-world: No such file or directory' ..plz help to fix that error... :'(

    ReplyDelete
  15. when i unzip the folder i didn't find /contiki/tools/cooja/ & /contiki/examples/hello-world/ these directories...

    ReplyDelete
  16. Hi!
    I have a problem, when I do:
    make target=NATIVE

    I get this error :
    ../../cpu/avr/./watchdog.c:71:9: error: attempt to use poisoned "MCUSR" #define MCUSR MCUCSR ^ ../../cpu/avr/./watchdog.c: In function ‘watchdog_init’: ../../cpu/avr/./watchdog.c:85:2: error: attempt to use poisoned "MCUSR" MCUSR&=~(1<<WDRF); ^ ../../cpu/avr/./watchdog.c:85:2: error: ‘MCUSR’ undeclared (first use in this function) ../../cpu/avr/./watchdog.c:85:2: note: each undeclared identifier is reported only once for each function it appears in make: *** [obj_micaz/watchdog.o] Error 1

    can anyone help me please ??

    ReplyDelete
  17. Hi!
    I try to install contiki-cooja. when I do: " make TARGET=native ", I get this error: " make: Nothing to be done for `all' ".
    can you help me please?

    ReplyDelete