
TinyOS on Linux
Catello Di Martino
Here an extract
from several tutorials found on the net.
This installation
procedure has been tested on a Fedora Core 5 system, and should work
appropriately for this distribution of linux and for all RedHat based
distributions.
1. Setup an installation environment for installing tinyos and all of
its tools
o Open a shell and cd to your home directory
$>cd ~
o Create
an installation directory where all downloaded installation files will
be stored
$> mkdir tinyos-install-files
Any time
this tutorial tells you to download a file please put it into this folder.
2. Download
and install Java JDK version 5.0
This rpm
must be directly downloaded from sun's website because of licencing
issues. The rest of the installation files will be dowloaded from the
local server and installed separately.
o Go to this page here.
o Scroll down to the part of the page where it says "Download JDK
5.0 Update 8" and click on this link
o On the new page that opens up, scroll down to the part of where it
says "Accept License Agreement" and click on the radio button
next to it
o Wait for the page to refresh
o Scroll down to the part of the page where it says "Linux RPM
in self-extracting file" and click on this link to download the
file
o Open a terminal window and browse to where you saved the jdk-1_5_0_05-linux-i586-rpm.bin
file
o Run the following commands(answering yes to any questions that get
asked)
$> su -
$> chmod 755 jdk-1_5_0_08-linux-i586-rpm.bin
$> ./jdk-1_5_0_08-linux-i586-rpm.bin
$> exit
3. Download and
install all other files required by the tinyos installation
o Download the following files to ~/tinyos-install-files
java-1.5.0-sun-compat-1.5.0.05-1jpp.i586.rpm
rxtx-2.1-20050120.i386.rpm
avr-binutils-2.13.2.1-1.i386.rpm
avr-gcc-3.4.3-1.i386.rpm
avr-libc-1.2.3-1.i386.rpm
avarice-2.3.20041206cvs-1.i386.rpm
avr-insight-6.3-1.i386.rpm
msp430tools-base-0.1-20050607.i386.rpm
msp430tools-python-tools-1.0-1.noarch.rpm
msp430tools-binutils-2.16-20050607.i386.rpm
msp430tools-gcc-3.2.3-20050607.i386.rpm
msp430tools-libc-20050308cvs-20050608.i386.rpm
msp430tools-jtag-lib-20031101cvs-20050610.i386.rpm
msp430tools-gdb-6.0-20050609.i386.rpm
nesc-1.2-1.i386.rpm
tinyos-1.1.15Dec2005cvs-1.noarch.rpm
tinyos-tools-1.2.0-2.i386.rpm
o To install these rpms simply run the following commands
$>cd ~/tinyos-install-files
$>su
$>rpm -hiv *.rpm
$>exit
4. To finalize this installation, a few additional steps need to be
performed.
o Create a tinyos group for usres to have access to the tinyos-1.x folder
$> su -
$> /usr/sbin/groupadd tinyos
$> chmod -R g+w /opt/tinyos-1.x
$> chgrp -R tinyos /opt/tinyos-1.x
$> exit
o Add yourself to the lock, uucp, lp, and tinyos groups for enabling
access to the Serial and USB ports
Download group-script.sh to ~/tinyos-install-files
$> cd ~/tinyos-install-files
$> su -
$> ./group-script.sh -a $USER_NAME lock
$>./group-script.sh -a $USER_NAME uucp
$> ./group-script.sh -a $USER_NAME lp
$> ./group-script.sh -a $USER_NAME tinyos
$> exit
Replacing $USER_NAME by your username as appropriate
o Download Makelocal, and washu.sh to ~/tinyos-install-files
$> cd ~/tinyos-install-files
$> su -
$>cp Makelocal /opt/tinyos-1.x/tools/make
$> cp washu.sh /etc/profile.d
$> exit
Explain what javapath file does
Explain what Makelocal file does
Explain what washu.sh file does
o Setup java's JNI library:
$> cd /opt/tinyos/tools
$> su -
$> make install
$> exit
5. Verify that the installation was successful
o Open a new shell and check the CLASSPATH environment variable
$ echo $CLASSPATH
.;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools\java;C:\PROGRA~1\UCB\cygwin\opt\ti
nyos-1.x\tools\java\jars\cup.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools\java\jars\Jama-1.0.1.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools\java\jars\javax.servlet.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools\java\jars\jazz.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-.x\tools\java\jars\jdom.jar;C:\PROGRA~1\UCB\cygw
in\opt\tinyos-1.x\tools\java\jars\JLex.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x
\tools\java\jars\junit.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools\java\jars
\oalnf.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools\java\jars\org.mortbay.jet
ty.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools\java\jars\pgjdbc2.jar;C:\PROG
RA~1\UCB\cygwin\opt\tinyos-1.x\tools\java\jars\plot.jar;C:\PROGRA~1\UCB\cygwin\o
pt\tinyos-1.x\tools\java\jars\pxgraphapplet.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyo
s-1.x\tools\java\jars\xercesImpl.jar;C:\PROGRA~1\UCB\cygwin\opt\tinyos-1.x\tools
\java\jars\xmlParserAPIs.jar
Test whether SerialForwarder works:
$> runsf_com1
You should see the following GUI appear:
o Test whether you can compile a TinyOS application:
$ >cd apps
$> cd BlinkTask
$> make mica2
compiling BlinkTask to a mica2 binary
ncc -o build/mica2/main.exe -Os -DCC1K_DEF_FREQ=434107920 -finline-limit=100000
-Wall -Wshadow -DDEF_TOS_AM_GROUP=0x07 -Wnesc-all -target=mica2 -fnesc-cfile=bui
ld/mica2/app.c -board=micasb -I%T/lib/Deluge -DIDENT_PROGRAM_NAME=\"BlinkTask\"
-DIDENT_USER_ID=\"localuser\" -DIDENT_HOSTNAME=\"jupiter\"
-DIDENT_USER_HASH=0x6
64b16dbL -DIDENT_UNIX_TIME=0x43de78adL -DIDENT_UID_HASH=0xff1068e4L
BlinkTask.nc
-lm
compiled BlinkTask to build/mica2/main.exe
1658 bytes in ROM
50 bytes in RAM
avr-objcopy --output-target=srec build/mica2/main.exe build/mica2/main.srec
avr-objcopy --output-target=ihex build/mica2/main.exe build/mica2/main.ihex
writing TOS image
6. All Done!
The following notes describe differences from the main installation
instructions on how to install TinyOS on Debian.
The #s in the 1st column refer to the steps in your installation instructions
and
the *s are the things I had to do differently and/or do extra to complete
the step
and/or that didn't work for some reason or another.
http://www.stoecklin.net/technology/tinyos/page_data/howto-setup-tinyos.pdf
helped
me with setting up the tool chain too since it was written for a Debian
system.
I didn't do anything it said until step 3.6 titled "Configuration
and setup".
3.
* install the rpms by running the alien command as root:
alien -iv *.rpm
.
* I could't download the javapath file because its link is broken
4.
* The /opt/tinyos-1.x/tools/java/jni/Makefile depends on a script called
locate-jre
to find out the jni and java include locations. Executing that script
on Debian
causes the following error because the script is using the rpm command:
locate-jre --jni
rpm: To install rpm packages on Debian systems, use alien. See README.Debian.
error: cannot open Packages index using db3 - No such file or directory
(2)
A workaround is to hardcode the paths in Makefile
JNI="/usr/lib/j2sdk1.5-sun/include"
JAVAC_DIR="/usr/lib/j2sdk1.5-sun/bin"
* There is no lock group.
* The group-script.sh completely executed and didn't report any errors
other than the lock group
missing, but I couldn't write to the tinyos-1.x tree as
my user that I passed into that script. When I invoked the groups command
from a terminal
window in which I was logged in as that user, those groups were not
listed, but when I invoked
groups <user_name> they all were listed. In order to write to
the tinyos-1.x tree I
set its group to my user's default group.
* When I invoked /etc/profile.d/washu.sh I saw a few errors. I haven't
troubleshooted
this problem yet.
* In my ~/.bashrc I appended in the following which howto-setup-tinyos.pdf
said to do:
export TOSROOT="/opt/tinyos-1.x"
export TOSDIR="$TOSROOT/tos"
export TOSAPPS="$TOSROOT/apps"
export TOSTOOLS="$TOSROOT/tools"
export CLASSPATH="$CLASSPATH:`$TOSROOT/tools/java/javapath`:$TOSROOT/tools/java/net:/usr/lib/j2sdk1.5-sun/jre/lib/ext/"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/:/usr/lib/j2sdk1.5-sun/jre/bin/:/usr/lib/j2sdk1.5-sun/include/"
PATH="$PATH:$TOSROOT/tools/java/net/tinyos/sim"
5.
* In order to build the files in /opt/tinyos-1.x/tools/java so that
SerialForwarder would run
without generating exceptions I did:
cp /opt/rxtx/jar/RXTXcomm.jar /usr/lib/j2sdk1.5-sun/jre/lib/ext
cp /opt/rxtx/lib/librxtxSerial.so /usr/lib/j2sdk1.5-sun/jre/lib/i386
* I took the last verification test a step further and tried installing
the Blink program.
When I had Makelocal only in /opt/tinyos-1.x/tools/make and I tried
uploading the Blink app onto a
mica2 mote which was plugged into a MIB510, the make program tried using
the parallel port
instead of the SerialUSB port that I had the cable attached to. To try
to figure out why it wasn't using my
make/Makelocal I grep'ed the apps/Makerules file and it showed me the
reason:
-include $(shell ncc -print-tosdir)/../apps/Makelocal
Once I put my Makelocal in apps it succesfully uploaded the program
to the mote.
p.s. The USBSerialPort the cable was connected to was designated as
/dev/ttyUSB0 and my user had to be in the
dialout group in order to access the port.
|