nc2momllib
This tool is no longer used. Please use Viptos instead.
This tool is an extension of the nesC compiler. nesC is "an extension to the C programming language designed to embody the structuring concepts and execution model of TinyOS. 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, described at http://webs.cs.berkeley.edu/tos/, is used, for example, on the Berkeley MICA "motes," which are small wireless sensor nodes.
nc2momllib is used to convert nesC files (.nc) into MoML files
(.xml). 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 in $PTII/vendors/ptinyos (FIXME:
/tinyos-1.x
?), then the Ptolemy II configure script will
find it and automatically make the TinyOS libraries available.
Below are the detailed instructions for:
- Installing the nc2momllib source distribution and building it.
- Installing nc2momllib from CVS and compiling from scratch.
How to install the nc2momllib distribution and build it
- You must install the following AVR tools:
- avarice
- avr-binutils
- avr-gcc
- avr-insight
- avr-libc
Choose and follow the appropriate directions for your operating system:
- If you are running Windows XP or Windows 2000, you can either:
- Download WinAVR
- Go to
http://winavr.sourceforge.net/
- Click on "Package"
- Download the latest release
The link should be at the top of the page and have a name like "WinAVR 20040404" - Install Winavr in any directory Directories with spaces in the pathname might not work?
- Go to
- If your Cygwin is installed so your 'Default
Text File Type' is Unix, download the following rpms
to an empty directory:
Note: If your Cygwin installation has 'Default Text File Type' of Unix instead of DOS, then you will likely have Cygwin CR/NL problems with CVS.- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avarice-2.0.20030825cvs-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-binutils-2.13.2.1-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-gcc-3.3tinyos-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-insight-pre6.0cvs.tinyos-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-libc-20030512cvs-1w.cygwin.i386.rpm
rpm --ignoreos -ivh *.rpm
in the directory where you saved the files.The rpms are also available here.
- Download the TinyOS Installshield Wizard. Run the wizard, and choose "Custom" install. Install only the AVR tools. This will install all of the rpms below for you. Do not choose the "cygwin" install option (it will overwrite and corrupt your current cygwin installation) or the "TinyOS" install option (you will install this later from CVS as a separate step). You may choose to install the other remaining options if you do not already have them installed on your system. The wizard will install all of the selected rpms for you. JavaCOMM is not needed if you are not planning on using the TinyOS java tools (these are not needed for Viptos).
- Download WinAVR
- If you are running Linux (Redhat 9), download the rpms from
here. More convenient links are included here:
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avarice-2.0.20030825cvs-1.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-binutils-2.13.2.1-1.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-gcc-3.3tinyos-1.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-insight-pre6.0cvs.tinyos-1.3.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-libc-20030512cvs-1.i386.rpm
rpm -ivh *.rpm
in the directory where you saved the files.
- Make a directory into which to store the source code, for
example:
mkdir -p $PTII/vendors/ptinyos
- We have put into the TinyOS makefiles a rule that you can
run to create all the TinyOS libraries in one step. To use this,
as of this writing, you need to get TinyOS from the CVS
repository rather than getting the packaged install version. To
do this, type:
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
This will create a directorytinyos-1.x
. For more information, seehttp://sourceforge.net/cvs/?group_id=28656
. - Set the TOSROOT environment variable to the location of the TinyOS source tree; also set the TOSDIR environment variable.
- Under bash, type:
export TOSROOT=$PTII/vendors/ptinyos/tinyos-1.x export TOSDIR=$TOSROOT/tos
- Under csh or tcsh:
setenv TOSROOT $PTII/vendors/ptinyos/tinyos-1.x setenv TOSDIR $TOSROOT/tos
- Under Windows with Cygwin, you can permanently set
environment variables from the System control panel. (For
details, see Set the value of
the PTII environment variable).
Go to Start Menu -> Settings -> Control Panels -> System -> Advanced -> Environment Variables.
SetTOSROOT
to%PTII%/vendors/ptinyos/tinyos-1.x
SetTOSDIR
to%PTII%/vendors/ptinyos/tinyos-1.x/tos
While you are setting environment variables in Windows, you may want to set NC2MOMLLIB_NESC.
- Under bash, type:
- Download the nc2momllib distribution and save it in $PTII/vendors/ptinyos. Install it:
cd $PTII/vendors/ptinyos gunzip nc2momllib-1.1.1-1.tar.gz tar xvf nc2momllib-1.1.1-1.tar
- Run configure for nc2momllib:
cd $PTII/vendors/ptinyos/nc2momllib-1.1.1-1 ./configure --prefix=$PTII/vendors/ptinyos
If you are using Cygwin, and configure has trouble findingTOSROOT
orTOSDIR
, try expanding your$PTII
environment variable to/cygdrive/c/ptII
or something similar. Also try expanding theTOSROOT
andTOSDIR
environment variables if you still have problems. - If you are using the CVS version:
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 ./configure --prefix=$PTII/vendors/ptinyos make make install
- Install nc2momllib:
make make install
This will create directories in$PTII/vendors/ptinyos
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.
- Set another environment variable (NC2MOMLLIB_NESC) that
points to the nc2momllib installation.
- Under bash, type:
export NC2MOMLLIB_NESC=$PTII/vendors/ptinyos
- Under csh or tcsh
setenv NC2MOMLLIB_NESC $PTII/vendors/ptinyos
- Under Windows with Cygwin, you can permanently set the environment variables from the System control panel:
Go to Start Menu -> Settings -> Control Panels -> System -> Advanced -> Environment Variables.
SetNC2MOMLLIB_NESC
to%PTII%/vendors/ptinyos
- Under bash, type:
- Run the makefile
cd $TOSROOT/contrib/momllib make momllib mica
You can ignore most warnings, since these are errors for .nc files in the TinyOS tree that do not compile properly. - See if it worked:
How to install nc2momllib from CVS and build it
You can also download the nc2momllib source code and build it. It is based on the nesC compiler, which requires an impressive suite of tools.
- Under Linux or Cygwin, you must have the following programs
installed on your system:
- autoconf 2.50 or later
- bison
- emacs
- emacs-el
- gperf
- perl
- rpm
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.
- You must install the following AVR tools:
- avarice
- avr-binutils
- avr-gcc
- avr-insight
- avr-libc
Choose and follow the appropriate directions for your operating system:
- If you are running Windows XP or Windows 2000, you can either:
- Download WinAVR
- Go to
http://winavr.sourceforge.net/
- Click on "Package"
- Download the latest release
The link should be at the top of the page and have a name like "WinAVR 20040404" - Install Winavr in any directory Directories with spaces in the pathname might not work?
- Go to
- If your Cygwin is installed so your 'Default
Text File Type' is Unix, download the following rpms
to an empty directory:
Note: If your Cygwin installation has 'Default Text File Type' of Unix instead of DOS, then you will likely have Cygwin CR/NL problems with CVS.- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avarice-2.0.20030825cvs-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-binutils-2.13.2.1-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-gcc-3.3tinyos-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-insight-pre6.0cvs.tinyos-1w.cygwin.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/windows/avr-libc-20030512cvs-1w.cygwin.i386.rpm
rpm --ignoreos -ivh *.rpm
in the directory where you saved the files.The rpms are also available here.
- Download the TinyOS Installshield Wizard. Run the wizard, and choose "Custom" install. Install only the AVR tools. This will install all of the rpms below for you. Do not choose the "cygwin" install option (it will overwrite and corrupt your current cygwin installation) or the "TinyOS" install option (you will install this later from CVS as a separate step). You may choose to install the other remaining options if you do not already have them installed on your system. The wizard will install all of the selected rpms for you. JavaCOMM is not needed if you are not planning on using the TinyOS java tools (these are not needed for Viptos).
- Download WinAVR
- If you are running Linux (Redhat 9), download the rpms from
here. More convenient links are included here:
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avarice-2.0.20030825cvs-1.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-binutils-2.13.2.1-1.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-gcc-3.3tinyos-1.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-insight-pre6.0cvs.tinyos-1.3.i386.rpm
- http://today.cs.berkeley.edu/tos/dist-1.1.0/tools/linux/avr-libc-20030512cvs-1.i386.rpm
rpm -ivh *.rpm
in the directory where you saved the files.
- Make a directory into which to store the source code, for
example:
mkdir -p $PTII/vendors/ptinyos
- We have put into the TinyOS makefiles a rule that you can
run to create all the TinyOS libraries in one step. To use this,
as of this writing, you need to get TinyOS from the CVS
repository rather than getting the packaged install version. To
do this, type:
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
This will create a directorytinyos-1.x
. For more information, seehttp://sourceforge.net/cvs/?group_id=28656
. - Set the TOSROOT environment variable to the location of the TinyOS source tree; also set the TOSDIR environment variable.
- Under bash, type:
export TOSROOT=$PTII/vendors/ptinyos/tinyos-1.x export TOSDIR=$TOSROOT/tos
- Under csh or tcsh:
setenv TOSROOT $PTII/vendors/ptinyos/tinyos-1.x setenv TOSDIR $TOSROOT/tos
- Under Windows with Cygwin, you can permanently set
environment variables from the System control panel. (For
details, see Set the value of
the PTII environment variable).
Go to Start Menu -> Settings -> Control Panels -> System -> Advanced -> Environment Variables.
SetTOSROOT
to%PTII%/vendors/ptinyos/tinyos-1.x
SetTOSDIR
to%PTII%/vendors/ptinyos/tinyos-1.x/tos
While you are setting environment variables in Windows, you may want to set NC2MOMLLIB_NESC.
- Under bash, type:
- Get the nesC CVS Tree, see
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 -r nc2momllib nesc
- Boostrap nesC
cd $PTII/vendors/ptinyos/nesc ./Bootstrap
- Run configure for nesc
./configure --prefix=$PTII/vendors/ptinyos
If you are using Cygwin, and configure has trouble findingTOSROOT
orTOSDIR
, try expanding your$PTII
environment variable to/cygdrive/c/ptII
or something similar. Also try expanding theTOSROOT
andTOSDIR
environment variables if you still have problems. - Install nesc
make make install
This will create directories in$PTII/vendors/ptinyos
.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.
- Set another environment variable (NC2MOMLLIB_NESC) that
points to the nesc installation.
- Under bash, type:
export NC2MOMLLIB_NESC=$PTII/vendors/ptinyos
- Under csh or tcsh, type:
setenv NC2MOMLLIB_NESC $PTII/vendors/ptinyos
- Under Windows with Cygwin, you can permanently set the environment variables from the System control panel:
Go to Start Menu -> Settings -> Control Panels -> System -> Advanced -> Environment Variables.
SetNC2MOMLLIB_NESC
to%PTII%/vendors/ptinyos
- Under bash, type:
- Run the makefile
cd $TOSROOT/contrib/momllib make momllib mica
You can ignore most warnings, since these are errors for .nc files in the TinyOS tree that do not compile properly. - See if it worked: