ほぼ http://www.contiki-os.org/start.html のまま実行。

InstantContikiをダウンロード

http://sourceforge.net/projects/contiki/files/Instant%20Contiki/ からInstant Contiki 2.7をダウンロード

VMWare Playerをダウンロード

https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/7_0 からバージョン7をダウンロード

msp430-gccをインストール

$ sudo apt-get install msp430-gcc

でインストール

telosbに書き込み

$ sudo make TARGET=sky hello-world.upload Motes=/dev/ttyUSB0

で書き込める。

coojaの起動

$ cd ~/contiki/tools/cooja
$ ant run

Makefileの書き方

all:

CONTIKI = /home/user/contiki
include $(CONTIKI)/Makefile.include

最小限のMakefile↑。 ディレクトリの中身は

$ ls
Makefile  test01.c

makeすると

$ make TARGET=sky test01
$ ls
contiki-sky.a    Makefile  symbols.c  test01.c
contiki-sky.map  obj_sky   symbols.h  test01.sky

いろいろ作られる。 特にsymbols.cとsymbols.hが勝手に作られるのが面白い。

test01.cは

#include "contiki.h"
#include <stdio.h>

PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);

PROCESS_THREAD(hello_world_process, ev, data)
{
  PROCESS_BEGIN();
  printf("Hello, world\n");

  PROCESS_END();
}

Coojaで実行するとHello, worldは見ることができる。 通信系のライブラリであるrimeもどうやら起動している模様...

TelosBをPCに接続してVMWareの操作パネルからLinuxに接続。

「ls /dev/ttyUSB*」でどのデバイスファイルでUSBが認識されているか確認。

$ ls /dev/ttyUSB*
/dev/ttyUSB0
$

この場合には/dev/ttyUSB00としてtelosBが見えている。そこで

$ sudo make TARGET=sky test01.upload Motes=/dev/ttyUSB0

でプログラムをtelosBに書き込み。 test01はprintfするだけのプログラムなのでこのままでは何も出力されない。 telosBにログインする必要がある。

$ sudo make login TARGET=sky Motes=/dev/ttyUSB0
/home/user/contiki/tools/sky/serialdump-linux -b115200 /dev/ttyUSB0
connecting to /dev/ttyUSB0 (115200) [OK]

これで接続は完了。telosBのリセットボタンを押すと。

Rime started with address 189.57
MAC bd:39:00:00:00:00:00:00 Contiki 2.6 started. Node id is not set.
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 65491
Starting 'Hello world process'
Hello, world

が出力されて無事にプログラムの実行完了。


  添付編集
Last-modified: 2015-03-04 (水) 17:04:31 (3312d)