TinyOS + iris mote on FreeBSD HOWTO

This is how to make our iris mote with MTS400 sensor board work with FreeBSD. Although it’s difficult to make the full feature of TinyOS toolkit (especially Java based tools on the host side) because of several limitations of the toolkit, it’s still possible to develop everything on the motes and host PC(s) with FreeBSD.
Before getting started, the user must be join dialer group to “dialer” group to control /dev/cua*.
[ Step 1: ports setup ]
Since iris motes have Atmel’s AVR processors, we need avr cross compiler to make them work. I’ve installed following softwares from FreeBSD ports collection.
– devel/avr-gcc
– devel/avr-libc (without documentation)
– devel/avr-gdb
– devel/avarice
– devel/avrdude (needs “cp /usr/local/etc/avrdude.conf /etc/avrdude/” after installation)
[ Step 2: NesCC installation ]
To compile programs run on motes, we need NesC compiler (that calls avr-gcc for iris motes). However, NesC has a small incompatibility with the latest avr-gcc comes with FreeBSD ports. Simply edit src/unparse.c and comment out line 812 and 813. Without this patch, avr-gcc will experience an “internal compiler error”, then terminates abruptly.
nesc-1.3.2/src/unparse.c
811: /* gcc wants the attributes here */
812: // prt_type_elements(CAST(type_element, d->attributes),
813: // flag_gccize ? 0 : psd_no_target_attributes);
Then just:
% ./configure –prefix=${HOME}/work/xbow/tools
% gmake
% gmake install
this will install nescc in ~/work/xbow/tools.
[ Step 3: Build TinyOS environment ]
Since I couldn’t build latest trunk (revision at r5194) for iris motes and TinyOS-2.1.1.3 doesn’t have mts400 driver, I’ve checked out trunk at revision r5166 and it builds.
% cd ~/work/xbow/
% svn checkout http://tinyos-main.googlecode.com/svn/trunk tinyos-5166 -r 5166
% ln -s tinyos-5166 tinyos
% set path = ( /usr/local/diablo-jdk1.6.0/bin ~/work/xbow/tools/bin $path )
% setenv TOSROOT ~/work/xbow/tinyos/
% setenv TOSDIR ~/work/xbow/tinyos/tos
% setenv CLASSPATH ~/work/xbow/tinyos/support/sdk/java/tinyos.jar:.
% setenv MAKERULES ~/work/xbow/tinyos/support/make/Makerules
Next, we need some patches to build TinyOS on FreeBSD before building the tools:
% cd tinyos/tools
% vi configure (change #!/bin/sh on the first line to #!/usr/local/bin/bash. That’s because FreeBSD’s Bourne shell can’t run the script…)
% vi misc/tos-locate-jre (replace “readlink -q” by “readlink”. The command doesn’t require -q option.)
% ./configure –prefix=${HOME}/work/xbow/tools
% gmake && gmake install
This will install uisp and many other programs in ~/work/xbow/tools/bin. Unfortunately I still can’t run Java based tools, I can use C based SDKs.
[ Step 4: Program the Mote NOW! ]
The first one is the “Blink” application. Assume that the programmer appears on /dev/cuaU0 (and the mote interface on /dev/cuaU1).
% cd ~/work/xbow/tinyos/apps/Blink
% gmake iris
% gmake iris reinstall mib520,/dev/cuaU0
The LEDs will blink!
Next thing is test with radio… The client ID must be specified at gmake reinstall.
Compile for client:
% cd ~/work/xbow/tinyos/apps/tutorials/BlinkToRadio
% gmake iris
Install for client 0x1234:
% gmake iris reinstall,0x1234 mib520,/dev/cuaU0
Install for client 0xabcd:
% gmake iris reinstall,0xabcd mib520,/dev/cuaU0
Set up the basestation:
% cd ~/work/xbow/tinyos/apps/tutorials/Basestation
% gmake iris
% gmake iris reinstall mib520,/dev/cuaU0
Compile C based serial forwarder:
% cd ~/work/xbow/tinyos/support/sdk/c/sf
% sh bootstrap && ./configure && gmake
% ./seriallisten /dev/cuaaU1 57600
The packets are displayed by serial forwarer:
00 ff ff ab cd 04 00 06 ab cd 00 01
00 ff ff ab cd 04 00 06 ab cd 00 02
00 ff ff ab cd 04 00 06 ab cd 00 03
00 ff ff ab cd 04 00 06 ab cd 00 04
00 ff ff ab cd 04 00 06 ab cd 00 05
00 ff ff 12 34 04 00 06 12 34 00 01
00 ff ff ab cd 04 00 06 ab cd 00 06
00 ff ff 12 34 04 00 06 12 34 00 02
00 ff ff ab cd 04 00 06 ab cd 00 07
00 ff ff 12 34 04 00 06 12 34 00 03
00 ff ff ab cd 04 00 06 ab cd 00 08
OK, cool.

コメントを残す