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:

How to install the nc2momllib distribution and build it

  1. 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:

    (The directions above were modified from the original TinyOS installation directions).
  2. Make a directory into which to store the source code, for example:
        mkdir -p $PTII/vendors/ptinyos
            
  3. 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 directory tinyos-1.x. For more information, see http://sourceforge.net/cvs/?group_id=28656.
  4. 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.
      Set TOSROOT to %PTII%/vendors/ptinyos/tinyos-1.x
      Set TOSDIR to %PTII%/vendors/ptinyos/tinyos-1.x/tos

      While you are setting environment variables in Windows, you may want to set NC2MOMLLIB_NESC.

  5. 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
            
  6. 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 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.
  7. 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
    
  8. 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.

  9. 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.
      Set NC2MOMLLIB_NESC to %PTII%/vendors/ptinyos

  10. 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.
  11. See if it worked:
  12. You should see some valid MoML code in: $TOSDIR/lib/Counters/Counter.xml
  13. It should be listed by: $TOSDIR/lib/Counters/index.xml
  14. You should see a top-level index file: $TOSROOT/TOSIndex.xml

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.

  1. 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.

  2. 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:

    (The directions above were modified from the original TinyOS installation directions).
  3. Make a directory into which to store the source code, for example:
        mkdir -p $PTII/vendors/ptinyos
            
  4. 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 directory tinyos-1.x. For more information, see http://sourceforge.net/cvs/?group_id=28656.
  5. 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.
      Set TOSROOT to %PTII%/vendors/ptinyos/tinyos-1.x
      Set TOSDIR to %PTII%/vendors/ptinyos/tinyos-1.x/tos

      While you are setting environment variables in Windows, you may want to set NC2MOMLLIB_NESC.

  6. 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
            
  7. Boostrap nesC
    cd $PTII/vendors/ptinyos/nesc
    ./Bootstrap
            
  8. Run configure for nesc
    ./configure --prefix=$PTII/vendors/ptinyos
            
    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.
  9. 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.

  10. 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.
      Set NC2MOMLLIB_NESC to %PTII%/vendors/ptinyos

  11. 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.
  12. See if it worked:
  13. You should see some valid MoML code in: $TOSDIR/lib/Counters/Counter.xml
  14. It should be listed by: $TOSDIR/lib/Counters/index.xml
  15. You should see a top-level index file: $TOSROOT/TOSIndex.xml