Getting Started with Contiki

after going through lots of help pages, I find this to be the easiest and what I needed 🙂
these snippets come from and part of it from a lot of other sources

I am using Contiki 2.6. Contiki 2.7 has some files missed; so instead of wasting my time on it, I downgraded to 2.6 (again). Of course you can use 2.7 and put together what was left out 🙂
I reinstall my OS several times for several reasons (my external hdd that I kept the OS broke down, I changed to 4Gb pendrive then onto 8Gb which weren’t enough, so I now am using 32Gb pendrive – pendrive is easier to bring than external hdd) anyway since I kept on reinstalling everything all over again, I lost my files (and I can’t really remember what changes did I do in 2.7)

1. Install msp430 tool chain. Type this command in terminal
sudo apt-get install binutils-msp430 gcc-msp430 msp430-libc

2. Install the AVR tool chain. Type this command in terminal
sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude

3. Now you need JRE and JDK
sudo apt-get install openjdk-7-jdk openjdk-7-jre

4. Or, instead of using terminal, you can use the Ubuntu Software Center and install all above from there

5. To run cooja simulator you will need Ant
sudo apt-get install ant

okay, going into Contiki itself, a few things to do (based on the errors I got and whatnot)
/dev/ttyS0: Permission denied

Do check if it can detect the TelosB/TMote Sky
adila@ubuntu:~$ dmesg
.
.
[ 2317.492986] usb 2-1.1: FTDI USB Serial Device converter now attached to ttyUSB1

1. check permission
adila@Adila:~$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Oct 8 12:41 /dev/ttyUSB0

2. add yourself to the group
adila@Adila:~$ sudo gpasswd --add adila dialout

3. Log out and log in again for changes to take effect

4. I’ve added myself, and reboot.
adila@Adila:~$ id -n -G
adila adm dialout cdrom sudo dip plugdev lpadmin sambashare

5. Other things to give permission to:
adila@Adila:~/contiki-2.6/tools/sky$ chmod a+x motelist-linux
adila@Adila:~/contiki-2.6/tools/sky$ ls -l motelist-linux
-rwxrwxr-x 1 adila adila 7588 Jul 17 2012 motelist-linux

_________________________________________

adila@ubuntu:~/Desktop/contiki-2.6/tools/sky$ ls -l msp430-bsl-linux
-rw-rw-r-- 1 adila adila 68624 Jul 17 2012 msp430-bsl-linux
adila@ubuntu:~/Desktop/contiki-2.6/tools/sky$ chmod a+x msp430-bsl-linux
adila@ubuntu:~/Desktop/contiki-2.6/tools/sky$ ls -l msp430-bsl-linux
-rwxrwxr-x 1 adila adila 68624 Jul 17 2012 msp430-bsl-linux

________________________________________

adila@ubuntu:~/Desktop/contiki-2.6/tools/sky$ ls -l serialdump-linux
-rw-rw-r-- 1 adila adila 14922 Jul 17 2012 serialdump-linux
adila@ubuntu:~/Desktop/contiki-2.6/tools/sky$ chmod a+x serialdump-linux
adila@ubuntu:~/Desktop/contiki-2.6/tools/sky$ ls -l serialdump-linux
-rwxrwxr-x 1 adila adila 14922 Jul 17 2012 serialdump-linux

__________________________________________________________

6. I have this Command not found problem when I’m trying to upload the code into TelosB from my laptop (but not on the computer in my office)
bash: /home/adila/contiki/tools/sky/serialdump-linux: No such file or directory

If you have a 64bit processor, don’t have ia32-libs installed, ‘serialdump-linux’ was compiled for 32bit, and so you’ll need ia32-libs (and perhaps other libraries) to run it
adila@ubuntu:~$ sudo apt-get install ia32-libs

EDIT
Package ia32-libs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
lib32z1 lib32ncurses5 lib32bz2-1.0

E: Package 'ia32-libs' has no installation candidate
adila@ubuntu:~$ sudo apt-get install lib32bz2-1.0

__________________________________________________________

7. For older Contiki version, if this error occur:
/msp430/lib/mmpy-16/libc.a(rand.o):(.debug_info+0xd3): relocation truncated to fit: R_MSP430_16_BYTE against `no symbol'
collect2: ld returned 1 exit status

solution:
go to:
contiki/cpu/msp40/Makefile.msp430

near line 132 search for
CFLAGSNO = -Wall -mmcu=$(CC_MCU) -g $(CFLAGSWERROR)

and delete the option “-g”.
The line should look like this:
CFLAGSNO = -Wall -mmcu=$(CC_MCU) $(CFLAGSWERROR)

________________________________________________________
to check if everything works perfectly, connect the sensor
and at the terminal,

adila@ubuntu:~$ cd contiki-2.7/
adila@ubuntu:~/contiki-2.7$ cd examples/
adila@ubuntu:~/contiki-2.7/examples$ cd hello-world/
adila@ubuntu:~/contiki-2.7/examples/hello-world$ make TARGET=sky hello-world.upload

there shouldn’t be any error (remember to restart the computer first!)

msp430-objcopy hello-world.sky -O ihex hello-world.ihex
make IHEXFILE=hello-world.ihex sky-reset sky-upload
make[1]: Entering directory `/home/adila/contiki-2.7/examples/hello-world'
make -k -j 20 sky-reset-sequence
make[2]: Entering directory `/home/adila/contiki-2.7/examples/hello-world'
../../tools/sky/msp430-bsl-linux --telosb -c /dev/ttyUSB1 -r
MSP430 Bootstrap Loader Version: 1.39-telos-7
Use -h for help
Reset device ...
Done
make[2]: Leaving directory `/home/adila/contiki-2.7/examples/hello-world'
make -j 20 sky-upload-sequence
make[2]: Entering directory `/home/adila/contiki-2.7/examples/hello-world'
+++++ Erasing /dev/ttyUSB1
MSP430 Bootstrap Loader Version: 1.39-telos-7
Use -h for help
Mass Erase...
Transmit default password ...
+++++ Programming /dev/ttyUSB1
MSP430 Bootstrap Loader Version: 1.39-telos-7
Invoking BSL...
Transmit default password ...
Current bootstrap loader version: 1.61 (Device ID: f16c)
Changing baudrate to 38400 ...
Program ...
20606 bytes programmed.
+++++ Resetting /dev/ttyUSB1
MSP430 Bootstrap Loader Version: 1.39-telos-7
Use -h for help
Reset device ...
Done
make[2]: Leaving directory `/home/adila/contiki-2.7/examples/hello-world'
make[1]: Leaving directory `/home/adila/contiki-2.7/examples/hello-world'
rm hello-world.ihex

then type;
adila@ubuntu:~/contiki-2.7/examples/hello-world$ make TARGET=sky login

press the RESET button on the sensor you’ll get:
Rime started with address 1.0
MAC 01:00:00:00:00:00:00:00 Contiki 2.7 started. Node id is set to 1.
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26
Starting 'Hello world process'
Hello, world

Advertisements