Ptolemy II PtinyOS Domain Installation Notes

Below are the complete instructions for installing the tools necessary for running the Viptos demos.

If you are using Windows, see the short form of these instructions: Ptolemy II PtinyOS Domain Installation Notes for Cygwin

These installation instructions assume that you already have Viptos (or a release of Ptolemy II that includes the PtinyOS domain) installed. Viptos is a configuration of Ptolemy II, which means that it contains a specialized subset of the domains in the full version of Ptolemy II. If you already have the full version of Ptolemy II installed (i.e., your ptII installation includes the $PTII/ptolemy/domains/ptinyos directory), then you do not need to install a Viptos release, unless you are upgrading your version of Ptolemy II or Viptos. In any case, if you want to use Viptos or Ptolemy II with Viptos capabilities, you need to follow the instructions below to install the necessary tools.

Linux How-To

Below are the steps that worked in April, 2015 with RHEL 6.5 and Java 1.8
  1. Download the devel via svn and build. See http://chess.eecs.berkeley.edu/ptexternal:
    svn co https://source.eecs.berkeley.edu/svn/chess/ptII/trunk ptII
    cd ptII
    export PTII=`pwd`
    ./configure
    make 
      
  2. Set up ptinyos1.x:
    cd $PTII
    mkdir -p vendors/ptinyos
    cd $PTII/vendors/ptinyos
    wget http://ptolemy.berkeley.edu/viptos/viptos1.0/tinyos-1.x-2007-01-17.tar.gz
    tar -zxf tinyos-1.x-2007-01-17.tar.gz
      
  3. Download nesc 1.2.8 from http://sourceforge.net/projects/nescc/files/nescc/v1.2.8/. We use nesc-1.2.8 to avoid /usr/include/pthread.h:502: requested alignment is not a constant, see http://bugs.gentoo.org/145870.
    cd $PTII/vendors/ptinyos
    wget "http://downloads.sourceforge.net/project/nescc/nescc/v1.2.8/nesc-1.2.8a.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnescc%2Ffiles%2Fnescc%2Fv1.2.8%2F&ts=1298084236&use_mirror=superb-sea2"
    tar -zxf nesc-1.2.8a.tar.gz 
    cd nesc-1.2.8a
    ./configure
    make
    sudo make install 
      
  4. Set up the environment variables (details)
  5. export TOSROOT=$PTII/vendors/ptinyos/tinyos-1.x
    export TOSDIR=$TOSROOT/tos
    export PTINYOS_MOMLROOT=$PTII/vendors/ptinyos/moml
      
  6. Reconfigure:
    cd $PTII
    ./configure
      
  7. Configure and install the TinyOS 1.x nesC tools.
    cd $TOSROOT/tools/src/ncc
    ./Bootstrap
    ./configure
    make
    sudo make install
      
  8. See if you have installed TinyOS 1.x and nesC correctly (details)
    cd $TOSROOT/apps/Blink
    make pc
    ./build/pc/main.exe 1
      
    If you get messages like gcc: error: unrecognized command line option ‘-_fnesc-gcc=gcc’, then edit /usr/local/bin/nescc and use an older version of gcc:
    # Have fun with the arguments
    # $gcc = "gcc";
    # Use gcc-4.4.7 and avoid gcc: error: unrecognized command line option ‘-_fnesc-gcc=gcc’
    $gcc = "/usr/bin/gcc";
      
    gcc-4.4.7 worked, gcc-4.9.2 did not, and required the above change.
  9. Unzip the pre-generated libraries and applications
    cd $PTII/vendors/ptinyos
    cat $PTII/ptolemy/domains/ptinyos/util/nc2moml/nc2moml-tinyos-1.1.15Dec2005cvs-1.tar.gz | gunzip | tar -xvf -
    cd $PTII/vendors/ptinyos
    cat $PTII/ptolemy/domains/ptinyos/util/ncapp2moml/ncapp2moml-tinyos-1.1.15Dec2005cvs-1.tar.gz | gunzip | tar -xvf -
      
  10. Run the demo, check standard output for errors. The LEDs in the icon should blink
    $PTII/bin/viptos $PTII/ptolemy/domains/ptinyos/demo/SenseToLeds/SenseToLeds-InWireless.xml 
      

Windows Notes

Important information about running under Windows

To invoke Viptos, we use $PTII/jni/launcher/launcher.exe. This tool solves problems with Cygwin and JNI.

Windows users should verify that JNI works before proceeding

cd /usr/bin
cp make.exe gmake.exe

cd $PTII
./configure
make

cd $PTII/jni/test
make
            
You should see:
Failed: 0  Total Tests: 4  ((Passed: 4, Newly Passed: 0)  Known Failed: 0) C:/cxh/ptII/jni/test
            

If you are using Cygwin, and the above tests fail for you, then it is very unlikely that running a TinyOS model within Viptos (or Ptolemy II) will work.

If the any of the tests above fail for you, Windows users and other users can still generate code by changing the PtinyOSDirector target from ptII to pc or some other TinyOS target like mica or mica install. See $PTII/ptolemy/configs/viptos/help.htm for details. Only running a simulation within ptII involves JNI.

Cygwin users should make sure that /usr/local/bin is in your path before /usr/bin
Under Cygwin, the easiest way to add /usr/local/bin to your path is to edit $HOME/.bashrc and add

PATH=/usr/local/bin:${PATH}
            
Another way is via the System control panel (For details, see Set the value of the PTII environment variable).

If you use the Ptolemy II 6.0 cygwinDevel, you may also need to upgrade to

  • autoconf-2.53 or later, (2.59 preferred)
  • automake-1.5 or later (1.9.6 preferred)
  • bison
  • emacs
  • emacs-el
  • gperf
  • make-3.80 or later (3.80 preferred)
  • rpm

For each of the packages, download the .tar.gz or bzip2 file from one of the GNU Mirrors, unzip it, and run

configure
make
make install
            

If you wish to use pre-existing installations of nesC and TinyOS 1.x, please set up the environment variables described in the steps below to point to the proper directories. Otherwise, skip ahead to the installation instructions.

Using preexisting installations of TinyOS 1.x and nesC (v1.2.2 or later)

  1. If you already have TinyOS 1.x and nesC (version 1.2.2 or later, from CVS or a .tar.gz distribution) and the AVR tools and make (version 3.80 or later) installed, try:
    cd $PTII
    mkdir -p vendors/ptinyos
    cd $PTII/vendors/ptinyos
    ln -s location_of_your_tinyos-1.x_tree tinyos-1.x
    ln -s location_of_your_nesc_tree nesc
              
  2. Proceed to the step to Set up the necessary environment variables below.
  3. Proceed to the step to Reconfigure Viptos (or Ptolemy II) to recognize the new paths

Installation instructions

We assume that you have neither the nesC compiler nor TinyOS installed.
  1. The following AVR tools are needed:

    Instructions for installing the AVR tools are below:

    Note: If the files below do not work for you, you can use the older files instead: http://www.tinyos.net/dist-1.1.0/tools. See the original TinyOS 1.x installation directions for additional instructions.

    Choose and follow the appropriate directions for your operating system:

  2. You must have make version 3.80 or later installed. To check your make version, run make --version. If you have an earlier version, please choose the option that corresponds to your operating system:
  3. Make a directory into which to store the source code for TinyOS 1.x and nesC:
    mkdir -p $PTII/vendors/ptinyos
            
    The rest of these instructions assume the above path.

    Note that the value of $PTII should not have spaces in it.

  4. You can either get nesC from the .tar.gz distribution or from CVS.

    Getting nesC from a .tar.gz distribution

    1. Download nesc-1.2.7a.tar.gz or later version to $PTII/vendors/ptinyos
    2. Unzip and untar the nesc .tar.gz file:
      cd $PTII/vendors/ptinyos
      gunzip nesc-1.2.7a.tar.gz
      tar xf nesc-1.2.7a.tar  
              
      This should create a directory called nesc-1.2.7a.
    3. Change to the newly created directory.
      cd nesc-1.2.7a
              
    4. Skip ahead to the step to configure nesC.

    Getting nesC from CVS

    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 1.x, then nesC.

    Under Linux or Cygwin, you must have the following programs installed on your system:

    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.

    1. Get the nesC CVS Tree, see http://sourceforge.net/cvs/?group_id=56288
      cd $PTII/vendors/ptinyos
      cvs -d:pserver:anonymous@nescc.cvs.sourceforge.net:/cvsroot/nescc login 
      Hit Enter when prompted for a password
      cvs -z3 -d:pserver:anonymous@nescc.cvs.sourceforge.net:/cvsroot/nescc co -P nesc
              
    2. Bootstrap nesC
      cd $PTII/vendors/ptinyos/nesc
      ./Bootstrap
              
  5. Configure nesc:
    ./configure
          
    By default, this configuration will cause nesC to be installed in /usr/local.

    Make sure 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.

  6. Install nesc:
    make
    make install
          
  7. Under Windows with WinAVR-20040404, we had to copy 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.

    Under Windows with WinAVR-20040404, we also had to modify c:\usr\local\lib\ncc\nesc_nx.h so that

    #include <inttypes.h>
    
    is changed to
    #include <sys/types.h>
    
    Otherwise, when we try to compile nesC applications, the compiler complains that it cannot find the file.
  8. We have put into the TinyOS 1.x 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 1.x from the CVS repository rather than getting the packaged install version. To do this, type:
    cd $PTII/vendors/ptinyos
    cvs -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login 
    Hit Enter when prompted for a password
    cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P 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.

  9. Set up the necessary environment variables. TOSROOT sets the location of the TinyOS source tree. TOSDIR sets the tos subdirectory in the TinyOS source tree. PTINYOS_MOMLROOT sets the MoML output directory.
  10. Reconfigure Viptos (or Ptolemy II) to recognize the new paths:
    cd $PTII
    ./configure
            
  11. Under Linux or Cygwin, you must have the following programs installed on your system: If you install these under Cygwin, make sure /usr/local/bin is in your path and comes before any other paths to any older version.

    Configure and install the TinyOS 1.x nesC tools.

    cd $TOSROOT/tools/src/ncc
    ./Bootstrap
    ./configure
          
    By 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 install
          
  12. See if you have installed TinyOS 1.x and nesC correctly:
    cd $TOSROOT/apps/Blink
    make pc
    ./build/pc/main.exe 1
          
    The Blink application should successfully compile. When running the executable, you should see TOSSIM output. See $TOSROOT/doc/tutorial/lesson5.html or the online version of tutorial lesson 5 for more information.
  13. Unzip the pre-generated libraries:
    cd $PTII/vendors/ptinyos
    cat $PTII/ptolemy/domains/ptinyos/util/nc2moml/nc2moml-tinyos-1.1.15Dec2005cvs-1.tar.gz | gunzip | tar -xvf -
          
    This will create $PTII/vendors/ptinyos/moml and contains the MoML libraries corresponding to the Dec 2005 TinyOS RPM release.

    If you want to generate the MoML library files from scratch, see $PTII/ptolemy/domains/ptinyos/util/nc2moml/index.htm

  14. Unzip the pre-generated applications:
    cd $PTII/vendors/ptinyos
    cat $PTII/ptolemy/domains/ptinyos/util/ncapp2moml/ncapp2moml-tinyos-1.1.15Dec2005cvs-1.tar.gz | gunzip | tar -xvf -
          
    This will create $PTII/vendors/ptinyos/momlapp and contains the MoML applications corresponding to the Dec 2005 TinyOS RPM release.

    If you want to generate the MoML application files from scratch, see $PTII/ptolemy/domains/ptinyos/util/ncapp2moml/index.htm

  15. Run $PTII/bin/viptos and run one of the demos.
    You should see messages on stdout and eventually the images of the motes should blink