Installing tinyos-2.x on Mac OS X (Tiger & Leopard)

From TinyOS Wiki
Jump to: navigation, search

This tutorial provides instructions for getting tinyos-2.x up and running on Mac OS X v10.4 (Tiger) and v10.5 (Leopard). For Snow Leopard, please refer to Installing_TinyOS-2.x_on_Mac_OS_X_(Snow_Leopard). This procedure has been tested on an intel dual core Macbook Pro, but should be helpful for other platforms as well. If you run into problems, find that something doesn't work for you in this tutorial, or want to provide feedback of any kind, feel free to email me (Kevin Klues) at klueska(at)gmail.com and I'll try and update this tutorial as soon as possible.

This tutorial assumes that you are installing tinyos-2.x from a vanilla distribution of Tiger without any additional software. Because of this, some of the initial steps involve setting up the development tools and other additional software that is required by more important steps later on. Some of these steps may be skipped if you think you have already performed them, but be warned that doing anything other than following the procedure listed here may cause you to run into problems.

OK, lets get started.....

Contents

Installing the Developer Tools

If you are doing any sort of development work at all in OS X it's probably a good idea to download the set of tools described in this section. You can either install them directly from the Tiger installation cd or from the apple developer website. Most of you will probably have already completed this step before reading this tutorial.

Installing from the installation cd:

Installing from the cd is very straightforward and much faster than downloading the XCode developer tools from the website. Simply insert the tiger installation cd and follow the steps listed below.
  • Open the Xcode Tools folder in the Finder window that pops up
    • If no finder window pops up, just open a new one and select the installation CD from the list of mounted drives in the Toolbar
  • Double click XCodeTools.mkpkg and run the installation
Installing from the developer website:

If you decide to install these tools from the developer website, you will need to sign up for a developer account. After signing in, go to the Downloads section and select Developer Tools from the Download menu on the right hand side of the screen. Scroll down to Xcode Tools 2.2.1 and download the disk image to your hard drive. Once you have downloaded the '.dmg' file follow the instructions below to install the Xcode tools.
  • Open a Finder window and browse to the location you saves the Xtools disk image.
  • Open the downloaded xcode_2.2_*.dmg file to mount the disk image
  • Double click on XCodeTools.mkpkg and run the installation

Installing Darwin Ports

Darwin Ports is a package management system for Mac OS X that is designed to meet the same functionality requirements as the FreeBSD ports architecture while maintaining extensibility for future enhancement.

Darwin ports can be installed using the binary installer found here.
Simply enter your email address and click on the download button.

Once darwin ports is installed, packages can be installed by running sudo port install <package>. For a list of available packages, you can run the command port list.

Installing Stow

Once you have installed darwin ports, a whole new world of applications are made available for use on the Mac. One of these programs is known as stow. Stow is another package management system similar to darwin ports, but it contains some slightly different features. Stow allows one to "organize applications available in standard tar files and keep application binaries logically arranged for easy access". We will be using stow to keep our installation of the various tools required by tinyos-2.x organized. More information about stow can be found at this website.

Now that we have darwin ports at our disposal, installing stow is very straight forward. We simply need to run the following commands.
  • sudo port install stow
  • sudo mkdir -p /stow/repository

And now you need to set your path to include a '/stow/bin' directory.

  • Open up the file ~/.profile from your home directory
  • Add the following two lines to export the PATH correctly whenever a new shell is opened
    • PATH=/stow/bin:/stow/sbin:$PATH
    • export PATH

And thats all there is too it. We create a folder hierarchy under '/stow/repository' so that we have a consistent place for installing all of the programs found below. How to actually perform these installations using stow will become clear later on in the tutorial.

Downloading tinyos-2.x from cvs

For anonymous cvs access, browse to the location where you want to install the tinyos-2.x source tree and run the following set of commands.

  • cvs -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos login
  • cvs -z3 -d:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P tinyos-2.x
If you are a developer (and you know it if you are), browse to the location where you want to install the tinyos-2.x source tree and run this alternate set of commands, replacing developername with your sourceforge username as appropriate.
  • export CVS_RSH=ssh
  • cvs -z3 -d:ext:developername@tinyos.cvs.sourceforge.net:/cvsroot/tinyos co -P tinyos-2.x

You will also want to download tinyos.sh for setting up your tinyos environment variables correctly. You will need to edit this file to have TOSROOT point to the absolute path of your tinyos-2.x installation directory. You can put this file wherever you please, but I have chosen to place it inside of my tinyos-2.x folder. I have also added the line "source $TOSROOT/tinyos.sh" into the '.profile' file in my home directory so that this script gets run any time I open a new shell. Again, if you choose to do this, $TOSROOT will have to be replaced with the absolute path to your tinyos-2.x tree.

Installing nesc

tinyos-2.x requires nesc-1.2 or higher in order to compile source code to binaries. The steps involved in installing nesc version 1.3.0 can be seen below.
  • NOTE: If you plan to install the avr tools for mica support, make sure to use nesc 1.2.9 or above!!
  • Download the nesc-1.3.0 tarball from sourceforge (or whichever is the newest)
  • Install nesc using the standard configure/make/make install procedure
    • cd nesc-1.3.0
    • ./configure --prefix=/stow/repository/nesc-1.3.0
    • make
    • sudo make install
  • Run stow to install nesc into standard installation directories
    • cd /stow/repository
    • sudo stow nesc-1.3.0

Installing avr tools for Mica Support

Previously I was giving instructions for using darwin ports to install the avr tools, but its recently become a problem for many people to get this procedure to work. For this reason, I have now precompiled the binaries, and am distributing them on this site for people to download and install manually.

  • For intel-based Macs download: this tarball
  • For power pc based Macs download: this tarball
  • Extract the tarball into your /stow/repository directory
    • tar zxvf avr-tools-i686-apple-darwin.tar.gz
    • sudo mv avr-tinyos /stow/repository/
  • Use stow to install the tools
    • cd /stow/repository
    • sudo stow avr-tinyos

Installing msp430 tools for Telos Support

Getting the msp430 tools to compile correctly was a bit tricky. Because of this, I am right now just providing a tarball with all of the compiled binaries. When I have time, I will update this tutorial to include instructions on how to compile these tools yourself, but to get people going immediately, here is how to install the binaries.
  • For intel-based macs, download this tarball.
  • For power-pc macs, download this tarball.
  • Extract the tarball into your /stow/repository directory
    • tar zxvf msp430-tools-i686-apple-darwin.tar.gz
    • sudo mv msp430-tinyos /stow/repository/
  • Use stow to install the tools
    • cd /stow/repository
    • sudo stow msp430-tinyos

Installing FTDI Drivers

Go to this web address and download the drivers appropriate for your platform.
Install the drivers by opening up the disk image file and double clicking on FTDIUSBSerialDriver.pkg.

Installing the tinyos-2.x toolset

(Note: Before proceeding further, make sure you have setup your tinyos.sh script correctly and have run it in the current environment.)

Now, cd into your $TOSROOT directory and run the following commands:
  • cd tools
  • NOTE: For Leapord users, you will have to open the configure.ac file and remove the '-n' from line 109
  • ./Bootstrap
  • ./configure --prefix=/stow/repository/tinyos-2.x-tools
  • make
  • sudo make install
  • cd /stow/repository/
  • sudo stow tinyos-2.x-tools
  • sudo tos-install-jni
  • cd $TOSROOT/support/sdk/java
  • make
Depending on the version of java you have installed you may see some warnings during this stage of compilation. As long as you don't see any errors, you should be good to go.

Compiling an Application

Run the following commands to compile the Blink application for telosb
  • cd $TOSROOT/apps/Blink
  • make telosb

If all has gone well, the compilation should complete without problems. There will probably be an error, however, in executing the command objdump and displaying the correct number of bytes in RAM and ROM. This is due to the lack of objdump and ld in Mac OS X. This error will not hav any adverse affects on compiling or installing your program however, so it is safe to continue.

One way to avoid this error is to create links from your msp430-objdump into your standard /stow/bin directory.

  • cd /stow/bin
  • sudo ln -s msp430-objdump objdump
Since avr and msp430 binaries are both stored in standard elf format, this new link will work for binaries compiled for both mica and telos based platforms.

You may also see errors indicating that you don't have the 'sha1sum' command on your system. For some reason on the mac this application is called 'gsha1sum' and can be installed via darwin ports. So what you can do is the following:

  • sudo port install coreutils
  • cd /stow/bin
  • sudo ln -s /opt/local/bin/gsha1sum ./sha1sum

Installing an Application for Mica Based Motes

Since the mica motes need to be programmed from a programming board that only has a serial input, the first thing you will need to do is get ahold of a USB-serial cable that is compatible with your mac. I've been told that most of the ones out there work, but if you run into problems in this section you may want to try a different cable before proceeding.

OK, so once you have your cable and you have connected it to your MIB510 programming board, simply run the following commands:
  • cd $TOSROOT/apps/Blink
  • make mica2 install mib510,/dev/'<serialport>'
Where <serialport> gets replaced by the tty device used by your USB-serial cable. (On my machine this was at /dev/tty.USA19H5d1P1.1).

Installing an Application for telos Based Motes

Installing an application on a telosb mote in Mac OS is similar to how it is done in linux except for in how the USB device itself is named.
Installing the Blink application on a telos mote that has an FTDI chip with serial ID M4A5L58H would be performed as follows:
  • cd $TOSROOT/apps/Blink
  • make telosb install bsl,/dev/tty.usbserial-M4A5L58H

To see which telos devices you currently have plugged in, you can always run the command motelist and match the serial ids against the devices listed in your /dev directory.

Running a Java Application

To test that serial applications are running on Java, we can use the TestSerial application in the tinyos-2.x/apps/tests directory. Simply run the following.
  • For Telos based motes
    • cd $TOSROOT/apps/tests/TestSerial
    • make telosb install bsl,/dev/tty.usbserial-M4A5L58H
    • java TestSerial -comm serial@/dev/tty.usbserial-M4A5L58H:telos
  • For mica based motes
    • cd $TOSROOT/apps/tests/TestSerial
    • make mica2 install mib510,/dev/tty.USA19H5d1P1.1
    • java TestSerial -comm serial@/dev/tty.USA19H5d1P1.1:mica2

NOTE: See the 'telosb' and 'mica2' directives at the end of the call to 'java TestSerial'. If you install this application on the micaz, or tmote platforms you will want to make sure you change this accordingly.

You should now see output similar to the following:

$ java TestSerial -comm serial@/dev/tty.usbserial-M4A5L58H:telos
serial@/dev/tty.usbserial-M4A5L58H:115200: resynchronising
Sending packet 0
Received packet sequence number 4481
Sending packet 1
Received packet sequence number 4482
Received packet sequence number 4483
Sending packet 2
Received packet sequence number 4484
Sending packet 3
Received packet sequence number 4485
Sending packet 4
Received packet sequence number 4486
Sending packet 5
Received packet sequence number 4487
Sending packet 6
Received packet sequence number 4488
Sending packet 7
Received packet sequence number 4489
...
If all has worked out, you should be be up and running with your new installation of tinyos-2.x on Mac OS X!!!!

Questions or comments can either be sent directly to me (klueska(at)gmail.com) or the tinyos-help mailing list.