Using TinyOS with MacOS X (for Intel)

Matt Welsh
Last updated February 14, 2007

This page documents my approach to getting TinyOS (v1.1.15) to work on an Intel-based Mac running OS X Tiger 10.4.6. It may or may not apply to other versions of MacOS or TinyOS. I am primarily using TMote Sky motes and have not tested with other mote platforms.

Links you may find to be useful:

Instructions:
  • Install wget: "fink install wget"

  • Install textutils (for sha1sum): "fink install textutils"

  • Install FTDI drivers for MacOS from here:
    http://www.ftdichip.com/Drivers/VCP.htm
    Plug in a TMote Sky mote and verify that it is detected as /dev/tty.usbserial-M4A444LX (or something similar).

  • Create the directory $HOME/src which will contain the TinyOS and NesC compiler. cd to this directory.

  • Grab the latest version of the TinyOS 1.x sources from CVS using the following:
    cvs -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login
    
    cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -r tos-1-1-15Dec2005cvs-release -P tinyos-1.x
    

  • Set up your environment for TinyOS. You want the following commands to run each time you start up a shell, so put them in your $HOME/.bash_profile:
    export TOSROOT=$HOME/src/tinyos-1.x
    export TOSDIR=$TOSROOT/tos
    

  • Apply the following patch to $HOME/src/tinyos-1.x/tools/src/mspgcc/build-mspgcc:
    build-mspgcc-macosx.patch
    Note! To get this to work I am using gcc-3.3.6 rather than the rcommended version gcc-3.2.3. This is because gcc-3.2.3 does not seem to support the Intel MacOS platform (i386-apple-darwin). However ... this means that you are using a version of gcc that may introduce some bugs -- you will get a warning when you try to compile telos binaries. This is worth looking into. For now I am primarily using Linux to build TinyOS binaries.

    Also note that this uses the latest version of the MSPGCC package from CVS. I am not sure if this is 100% compatible with the TMote Sky and TinyOS. Seems to work with gthe programs I have tested it on.

  • You may need to apply the following patch to $HOME/src/tinyos-1.x/tools/src/mspgcc/build/mspgcc-cvs/msp430-libc/src/Makefile:
    mspgcc-Makefile.patch
    This patch prevents the build process from attempting to compile support for MSP430 models not used on the motes; some folks have reported an error such as
    cc1: error: MCU msp430x2001 not supported
    
    when compiling mspgcc without this patch.

  • Run these commands:
    cd $HOME/src/tinyos-1.x
    sudo tools/src/mspgcc/build-mspgcc install
    

  • Download nesc-1.2.4.tar.gz from the NesC sourceforge page.

  • Unpack nesc-1.2.4.tar.gz

  • Edit nesc-1.2.4/src/libcompat/pages.c and comment out line 184:
       /* #define USE_MMAP */
    
  • Build and install NesC with:
      DEFAULT_TARGET=telos ./configure 
      make
      sudo make install
    
    I set the default target to Telos because this seems to work better when using mig/ncg. For some reason the avr-gcc tools for MacOS under Fink are based on gcc-4.0 and this may be causing trouble when parsing NesC files.

  • Make a slight change to tools/src/sf/sfsource.c:saferead(). After the return from read(), change the next line to:
        if (n == -1 && (errno == EINTR || errno == EAGAIN))
    
    This allows the C-based SerialForwarder to work. Build it by typing "make".

  • Replace tools/java/net/tinyos/packet/SerialByteSource.java with the version found here:
    SerialByteSource.java
    This version is a stub that will not actually attempt to access the serial port, but also does not depend on javax.comm (which does not appear to be available for MacOS/Intel). You must use the C-based serial forwarder. Alternately you can try to install tinyos-1.x/beta/TOSComm but I have not tried this option.

  • Install msp430-bsl:
    cd /usr/local/bin
    sudo ln -sf $TOSDIR/../tools/src/mspgcc-pybsl/bsl.py ./msp430-bsl
    

  • You should now be able to install TinyOS binaries on motes:
      cd apps/Blink
      make telosb install bsl,/dev/tty.usbserial-* 
    

  • You should also be able to talk to motes over the serial port by starting up the C-based serialforwarder:
      cd tools/src/sf
      ./sf 9001 /dev/tty.usbserial-* 57600 telos &
      ./sflisten localhost 9001
    

If you have updates to this information please contact me at the email address found on my main web page. Thanks!