Ptolemy II PtinyOS Domain Installation Notes for Cygwin

These are the quick instructions for setting up the Ptolemy II PtinyOS domain. If you have problems, please see the general Ptolemy II PtinyOS Domain Installation Notes page.
  1. Follow the Ptolemy II Cygwin Installation instructions and download the Cygwin devel tools and install them.
  2. Under Windows, you will need to edit you jni_md.h file
    1. Edit the file <jdk_root>/include/win32/jni_md.h, Where jdk_root is the installation root (eg., c:/Program Files/Java/jdk1.5.0_01
    2. Replace the segment:
     typedef __int64 jlong;
     
    with:
     #ifdef __GNUC__
     typedef long long jlong;
     #else
     typedef __int64 jlong;
     #endif
     
  3. 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 set your path using the System control panel, then add c:\cygwin\usr\local\bin; to your PATH. Note that you need to use backslashes here.

  4. Download the WinAVR tools:
    1. Download WinAVR-20040404-bin-install.exe
    2. Install WinAVR in any directory, C:\WinAVR is preferred, directories with spaces in the pathname might not work?

  5. Set the PTII environment variable to be the location of your Viptos download. Under Windows, use forward slashes. For example c:/viptos. This file should be found at $PTII/ptolemy/domains/ptinyos/doc/installViptosUnderCygwin.htm

    Under Cygwin bash, either do

    	export PTII=where Viptos is located
    	
    for example:
    	export PTII=c:/viptos
    	
    or use the System control panel (For details, see Set the value of the PTII environment variable)/.

  6. To get the new environment variables start a new Cygwin shell
  7. Make a directory into which to store the source code for TinyOS 1.x and nesC:
    mkdir -p $PTII/vendors/ptinyos
            

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

  8. Install nesC from a .tar.gz distribution
    1. Download nesc-1.2.7a.tar.gz 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. Configure nesc:
      ./configure
            
    5. Install nesc:
      make
      make install
            
    6. 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.
  9. 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
          
    OR We've made a zipped version of the tinyos-1.x cvs repository available for archival purposes.
    1. Download tinyos-1.x-2007-01-17.zip
    2. Unzip it in $PTII/vendors/ptinyos
    Either method will create a directory tinyos-1.x. For more information about cvs and tinyos-1.x, see http://sourceforge.net/cvs/?group_id=28656.
  10. 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.
  11. If you set the environment variables via the System control panel, start up a new Cygwin bash shell so that you see the new variables.
  12. Reconfigure Viptos (or Ptolemy II) to recognize the new paths:
    cd $PTII
    ./configure
            
  13. Compile:
    make
    
  14. Configure and install the TinyOS 1.x nesC tools.
    cd $TOSROOT/tools/src/ncc
    ./Bootstrap
    ./configure
          
    make
    make install
          
  15. 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.
  16. 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

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

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