TinyOS is an event-driven operating system designed for sensor network nodes that have very limited resources (e.g., 8K bytes of program memory, 512 bytes of RAM). TinyOS, is used, for example, on the Berkeley MICA motes, which are small wireless sensor nodes. nesC is an extension to the C programming language designed to embody the structuring concepts and execution model of TinyOS.
nc2moml is used to convert nesC files (.nc) into MoML
(.moml) files. This will create the Ptolemy II libraries of
components that are used to assemble models. TinyOS provides a
rich library of nesC components. If you install TinyOS 1.x in
$PTII/vendors/ptinyos/tinyos-1.x
, then the Ptolemy
II configure script will find it and automatically make the TinyOS
libraries available.
Note: As of 10/05, Windows users will not be able to run TinyOS models inside Ptolemy. The reason is that reloading the TinyOS shared objects into the running Ptolemy interface fails because the TinyOS shared objects use pthreads and under Windows, Java is using Windows native threads. We are working on a solution. In the interim, Windows users can convert .nc files to .moml files and create models, but running the model fails.
However, Windows and users on other platforms can generate code for the
pc
or other targets. See the help instructions
in $PTII/ptolemy/configs/viptos/help.htm
.
These installation instructions assume that you already have Ptolemy II installed, and that if you are running on Windows, you already have Cygwin installed. These instructions also assume that you do not already have the nesC compiler nor TinyOS installed. If you wish to use pre-existing installations, please set up the environment variables described in the steps below to point to proper directories.
If you already have AVR tools, TinyOS and nesC installed, try:cd $PTII mkdir -p vendors/ptinyos cd $PTII/vendors/ptinyos ln -s location_of_your_tiny-1.x_tree tinyos-1.x ln -s location_of_your_nesc_tree nescBe sure to update to the latest nesC cvs version, then proceed to Set up the necessary environment variables below. You may skip installing TinyOS and nesc and proceed to unzipping the opts files and runningnc2moml
.
The nesC compiler can be downloaded and compiled from source, which requires an impressive suite of tools. These instructions ask you to first verify that you have the necessary programs installed, then to install the AVR tools, followed by TinyOS, then nesC.
For help with how to install these in Cygwin, see the Ptolemy II Cygwin Instructions. Note that most installations will not have gperf on them, at least, so you will likely need to install at least that.
Note: If the files below do not work for you, you can try
using the latest files (although these have not been tested
with Viptos yet):
http://www.tinyos.net/dist-1.2.0/tools
.
Choose and follow the appropriate directions for your operating system:
http://sourceforge.net/project/showfiles.php?group_id=68108
WinAVR-20040404-bin-install.exe
WinAVR-20050214-install.exe
, as of 10/05,
it will not work. When converting .nc files to .moml files,
you will see messages about avr-gcc not being able to find
cc1. Instead, install
WinAVR-20040404-bin-install.exe
.
C:\WinAVR
is preferred.
FIXME: Directories with spaces in the pathname might not work?
c:/cygwin/usr/local/lib/ncc/
to
c:/usr/local/lib/ncc/
:
mkdir -p c:/usr/local/lib cd c:/usr/local/lib cp -r /usr/local/lib/ncc .The reason is that Cygwin mounts directories under c:/cygwin and the WinAVR binaries don't know how to handle that.
Installing the rpms under Cygwin is not recommended, it causes include file problems later.
http://www.tinyos.net/dist-1.2.0/tools/
rpm --ignoreos -ivh *.rpmin the directory where you saved the files.
If you get a message about checksum errors, complain
to the TinyOS authors and then reinstall Cygwin with
Unix
line endings.
Note to tinyos developers: Unix line endings are not the right choice for naive Windows users.
If you get
bash-3.00$ rpm --ignoreos -ivh *.rpm error: Failed dependencies: /bin/sh is needed by make-3.80tinyos-1 /bin/sh is needed by mspgcc-win32tinyos-20041204-2 bash-3.00$Then try
rpm --ignoreos --nodeps -ivh *.rpm
The rpms are also available here.
rpm -ivh *.rpmin the directory where you saved the files.
mkdir -p $PTII/vendors/ptinyosNote that
$PTII
should not have spaces in it.
cd $PTII/vendors/ptinyos cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/tinyos login Hit Enter when prompted for a password cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/tinyos co tinyos-1.x
Note to tinyos developers: why is this download so large? Perhaps there should be a core cvs module and then a contrib module?
This will create a directory tinyos-1.x
. For more
information, see http://sourceforge.net/cvs/?group_id=28656
.
export TOSROOT=$PTII/vendors/ptinyos/tinyos-1.x export TOSDIR=$TOSROOT/tos export PTINYOS_MOMLROOT=$PTII/vendors/ptinyos/moml
setenv TOSROOT $PTII/vendors/ptinyos/tinyos-1.x setenv TOSDIR $TOSROOT/tos setenv PTINYOS_MOMLROOT $PTII/vendors/ptinyos/moml
Go to Start Menu -> Settings -> Control Panels -> System -> Advanced -> Environment Variables.
Set TOSROOT
to %PTII%/vendors/ptinyos/tinyos-1.x
Set TOSDIR
to %PTII%/vendors/ptinyos/tinyos-1.x/tos
Set PTINYOS_MOMLROOT
to %PTII%/vendors/ptinyos/moml
http://sourceforge.net/cvs/?group_id=56288
cd $PTII/vendors/ptinyos cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nescc login Hit Enter when prompted for a password cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nescc co nesc
cd $PTII/vendors/ptinyos/nesc ./Bootstrap
./configureBy default, this configuration will cause nesC to be installed in
/usr/local
. We assume that
/usr/local/bin
is in your path. If you wish to
install in a different directory, run ./configure
--prefix=<MYDIR>
instead and add the
bin
directory to your path.
FIXME: Necessary? If you are using Cygwin, and configure
has trouble finding TOSROOT
or
TOSDIR
, try expanding your $PTII
environment variable to /cygdrive/c/ptII
or
something similar. Also try expanding the
TOSROOT
and TOSDIR
environment
variables if you still have problems.
make make install
FIXME: necessary? If you are using Cygwin and make cannot find avr-gcc, then avr-gcc is probably not in your path. Locate avr-gcc and add the directory to your path. If you cannot find avr-gcc, then the AVR rpm's were not installed correctly, and you will need to try to reinstall them.
cd $TOSROOT/tools/src/ncc ./Bootstrap ./configureBy default, this configuration will cause the tools to be installed in
/usr/local
. We assume that
/usr/local/bin
is in your path. If you wish to
install in a different directory, run ./configure
--prefix=<MYDIR>
instead and add the
bin
directory to your path.
make make installmake failed for me:
Making all in libcompat make[3]: Entering directory `/cygdrive/c/cxh/ptII/vendors/ptinyos/nesc/src/libcompat' if gcc -DHAVE_CONFIG_H -I. -I. -I.. -DNMEMDEBUG -DNDEBUG -O9 -g -Wall -MT regions.o -MD -MP -MF ".deps/regions.Tpo" -c -o regions.o regions.c; \ then mv -f ".deps/regions.Tpo" ".deps/regions.Po"; else rm -f ".deps/regions.Tpo"; exit 1; fi In file included from /usr/local/include/sys/types.h:331, from /usr/local/include/sys/unistd.h:9, from /usr/local/include/unistd.h:4, from stats.c:3, from regions.c:40: /usr/include/cygwin/types.h:152: error: conflicting types for 'key_t' /usr/local/include/sys/types.h:137: error: previous declaration of 'key_t' was here /usr/include/cygwin/types.h:179: error: parse error before "u_int16_t" /usr/include/cygwin/types.h:187: error: parse error before "u_int64_t" /usr/include/cygwin/types.h:202: error: conflicting types for 'mode_t' /usr/local/include/sys/types.h:142: error: previous declaration of 'mode_t' was here In file included from /usr/local/include/fcntl.h:1, from stats.c:4, from regions.c:40: /usr/local/include/sys/fcntl.h:139: error: redefinition of `struct flock' make[3]: *** [regions.o] Error 1The solution was to uninstall one of the rpms.
cd Location of avr rpms rpm -e arm-thumb-elf-gcc-3.2-1 cd $PTII/vendors/ptinyos/nesc make make install cd Location of avr rpms rpm -force --ignoreos --nodeps -ivh *.rpm
Note that you need to have pdflatex
and bibtex
installed, or else edit nesc/Makefile
and comment remove
doc
from the SUBDIRS
line.
cd $PTII/vendors/ptinyos/tinyos-1.x make make install
tinyos-1.x/tools/src/uisp/src/Serial.C
failed to compile
Serial.C: In member function `void TSerial::OpenPort()': Serial.C:243: warning: right-hand operand of comma has no effect Serial.C:244: warning: right-hand operand of comma has no effect make[4]: *** [Serial.o] Error 1The solution is to edit
tinyos-1.x/tools/src/uisp/src/Makefile
and remove the -Werror
and rerun make from the top.
cd $PTII/ptolemy/domains/ptinyos/util ./unzip-opts.sh
If the executable permissions are not set correctly, run:
chmod a+x unzip-opts.shthen try the step above again.
cd $PTII/ptolemy/domains/ptinyos/util/nc2moml ./nc2momlIf the executable permissions are not set correctly, run:
chmod a+x nc2moml*then try the step above again. The
nc2moml
command will take 10-30 minutes to complete.
Note: The nc2moml tool requires that you build the tools in $PTII/bin
. Do the following and rerun the script above if they are missing:
cd $PTII/bin make
$PTII/vendors/ptinyos/moml
$PTII/bin/vergil -viptos