Start Mote Programming for CS558L Projects

Wei Ye

This guide helps students who are working on a mote-related projects to set up programming environment and TinyOS source code.

Background

Before starting your project, you need to have some basic knowledge about motes and TinyOS. Following is the list of papers you need to read After you read the above papers, take a look at TinyOS tutorial. With all these preparations, you are ready to start mote programming.

Setting up Programming Environment

This section describes how to set up a development environment for programming motes. If you attended class presentations about cross-platform development with Linux, you should be easy to understand what is going on here.

1. Hardware requirement

You need the following hardware for your mote programming:
All lab machines run Redhat Linux (Fedora Core) and have a parallel port and a serial port. You can use any of them for your project. You need to check out rest of hardware from me.

2. Toolchain for Atmel AVR microcontroller

You need to install the toolchian on your machine, including cross compilers and a flash image loader (also called programmer). Before you set up the toolchain, check if it is already set up by some other users on the machine that you're using. If so, you can skip this section, and go to next section to download TinyOS source code. If the toolchain is not installed, you should follow the instructions below to install it. You need to install these tools as root.

All Mica2 and MicaZ motes have the Atmel AVR microcontroller. There are two cross compilers that you need to install. One is avr-gcc, the gcc compiler for the AVR architecture. The other one is nesC compiler. Click the above links to download the tar balls to your machine, and put them under directory /usr/local/. These are precompiled, statically-linked, cross compilers, so you can directly use them. Now extract the tar balls by

tar xzvf *.tgz

Now you will have the following directories

/usr/local/avr/
/usr/local/nesc/


The next step is to download TinyOS tools, including the flash programmer (uisp) that uploads the compiled binary to motes. They are also precompiled and statically-linked for your convenience. Put the tarball at /usr/local/bin/, and extract the files by

tar xzvf *.tgz

You should be able to see these tools and use them directly.

To allow uisp to access the parallel port for uploading the binary images to motes, you need to change permissions of parallel port one:

sudo chmod 666 /dev/parport0

If you are using a serial port, e.g., for mote to communicate with the host PC, you also need to change its permision as

sudo chmod 666 /dev/ttyS0

3. Download TinyOS source code

We will use the TinyOS verion 1.1.14 for the class, as I have tested this version in my work. You can get the source tarball here. Suppose you put it in your home directory. After extracting the tar ball, you should see the following directory:
tinyos-1.1.14/.
This directory has all TinyOS source code you need.

4. Setting up environment variables

In order to find the cross compilers, add the following directories into your PATH environment variable in .bash_profile (or .bashrc) file.

/usr/local/avr/bin
/usr/local/nesc/bin
Now define the environment variables TOSROOT and TOSDIR in the .bashrc file as follows.

TOSROOT=$HOME/tinyos-1.1.14
export TOSROOT
TOSDIR=$HOME/tinyos-1.1.14/tos
export TOSDIR


Now you are ready to start mote programming! You can first program some simple applications described in the TinyOS tutorial.
Good luck!

Created by Wei Ye on March 09, 2005.
Last modified on November 15, 2007.