CONTIKI : How to write hello-world program in MICAZ mote

Contiki is a open source operating system for the IoT (Internet of Things). Contiki connects tiny low power, low cost micro-controllers to the Internet. While there are many similar OS such as TinyOS, what makes Contiki different is the completeness and flexibility it offers to the programmers.

Gets Start…

Installing Contiki

1. Download Instant Contiki

http://sourceforge.net/projects/contiki/files/Instant%20Contiki/

Try to download the latest version of Instant Contiki.

2. Install VMPlayer

https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0

3. Start Instant Contiki. The password for instant contiki is  user.

Hello-world program

There are alot of examples provided in the Instant contiki itself. Here I am going to upload hello-world program into MIcaz mote connected to my pc.

Steps:

1. Open a terminal, go to the code directory

#cd contiki/examples/hello-world

2. Compile Contiki and the application

Now compile the Hello World application for our hardware platform. For MIcaz

#make TARGET=micaz hello-world
#make TARGET=micaz savetarget

3. Now it is ready to upload in our MIcaz platform

#make hello-world.upload

Error 1

For the first time I am trying to upload hello-world, I found the following error

user@instant-contiki:~/contiki/examples/hello-world$ make hello-world.upload
using saved target 'micaz'
avr-objcopy -O srec hello-world.micaz hello-world.srec
uisp -dprog=mib510 -dserial=/dev/ttyS0 -dpart=ATmega128 --wr_fuse_h=0xd1 --wr_fuse_e=ff --erase --upload if=hello-world.srec --verify
Direct Parallel Access not defined.
make: *** [hello-world.upload] Error 2
rm hello-world.srec

 Solution for this is to install uisp. Try to install latest version of uisp

Steps :

Download the lastet version of uisp from here

http://kasun.ch.googlepages.com/uisp.tar.gz

Compile and install using terminal.

    # tar -xvzf uisp.tar.gz
    # cd uisp
    # ./bootstrap
    # ./configure
    # make
    # sudo make install

This definitely solve the problem of “Direct Parallel Access not defined.”

Error 2

user@instant-contiki:~/contiki/examples/hello-world$ make hello-world.upload
using saved target 'micaz'
avr-objcopy -O srec hello-world.micaz hello-world.srec
uisp -dprog=mib510 -dserial=/dev/ttyS0 -dpart=ATmega128 --wr_fuse_h=0xd1 --wr_fuse_e=ff --erase --upload if=hello-world.srec --verify
Error: Permission denied
 -> /dev/ttyS0
make: *** [hello-world.upload] Error 1
rm hello-world.srec

Solution

Give permission to USB port. Because the micaz mote is connected to our pc directly.

# sudo  chmod  777  /dev/ttyUSB*

And use this command to upload hello-world in to Micaz mote

# make hello-world.upload  PORT=/dev/ttyUSB0

Leave a comment