How To Install A New Platform On Tinyos 2.0
How To Install A New Platform On Tinyos 2.0
How To Install A New Platform On Tinyos 2.0
0
Samuel Boivineau, Raja Jurdak, and Antonio Ruzzelli
Table of Contents
I. Main Steps .............................................................................................................................................3
1. Starting from scratch versus Adapting from a current platform .......................................................3
2. The process .......................................................................................................................................3
II. The example of AquisGrain .................................................................................................................4
1. Tree of Tinyos 2.0.............................................................................................................................4
2. The Serial Port ..................................................................................................................................8
3. Leds ..................................................................................................................................................9
4. Clock ..............................................................................................................................................10
5. Radio Frequency Module ............................................................................................................... 11
6. How to download an application on the board ...............................................................................12
I. Main Steps
Because many platforms are available today, it is possible to do a comparison between the platform to
port and existing platforms to see if some components are common. If so, then the code used can be
adapted to the new platform, usually by just looking the wiring of the boards, to check the pins used.
The two main components of a mote are the microcontroller and the radio frequency module.
The microcontroller is usually an Atmega128 or a MSP430. Both are fully supported by many
platforms so the code related to each one is available in tinyos-2.x/tos/platforms/<platform>. It is
important to check that every pin is well configured, from the pins connected to the leds to the pins
connected to the radio frequency module.
This radio frequency module can be a CC2420 or a CC1000, for example. This component is also fully
supported by many platforms.
2. The process
In order to port a new platform, each device needs to be tested alone. Next the whole platform can be
tested before releasing the “driver”.
Many others applications can be modified to just check the device tested is working, by blinking the
leds for example.
II. The example of AquisGrain
In Tinyos 2.0, each set of files such as chip-related files, or hardware-related files or component-related
files is located in a specific directory.
tinyos-2.x/
apps/ Every application should be stored in this directory.
doc/ The doc built by 'make aquisgrain doc'
support/ The system files for make, java, python or c.
tos/
chips/ Each specific chip has its own directory
lib/ For generic components
platforms/ Each platform has its own directory
sensorboards/ Each platform has its own directory
system/ System components (scheduler etc)
types/ Header files
There are basically two ways to add a new platform in tinyos-2.0. Either it can be created, or an
existing platform can be adapted.
After examining the existing platforms in Tinyos, we identified that MicaZ uses an Atmega128 and a
CC2420 tranceiver. Thus, we opted for an adaptation of the Micaz platform to Aquisgrain.
Identification of application that can validate this specific device (eg: TestSerial for the Uart)
When an application is built, what are the errors, files missing, etc ?
For each file needed, is there any adjustement (pins number, interrupts number, etc) or the file can be
copied from the MicaZ platform ?
Finally, is the device working properly ?
The tutorial1 of tinyos.net can be used as an help tool. However, it is based on an msp340 chip which
presents different set of files than our chip.
1
http://www.tinyos.net/tinyos-2.x/doc/html/tutorial/lesson10.html
File .platform
This file defines every file needed by make during the compilation.
#
# FILE: aquisgrain/.platform
#
# Includes that should take precedence come first. Platforms come before
# chips because they may override files. These must be specified as
# @includes instead of -I's to @opts, otherwise the %T won't be processed
# by ncc.
#
# $Id: .platform,v 1.4 2006/12/12 18:23:43 vlahan Exp $
#
push( @includes, qw(
%T/platforms/aquisgrain
%T/platforms/aquisgrain/chips/cc2420
%T/chips/cc2420
%T/chips/atm128
%T/chips/atm128/adc
%T/chips/atm128/pins
%T/chips/atm128/spi
%T/chips/atm128/i2c
%T/chips/atm128/timer
%T/lib/timer
%T/lib/serial
%T/lib/power
) );
@opts = qw(
-gcc=avr-gcc
-mmcu=atmega128
-fnesc-target=avr
-fnesc-no-debug
-fnesc-
scheduler=TinySchedulerC,TinySchedulerC.TaskBasic,TaskBasic,TaskBasic,runTask,postT
ask
);
File hardware.h
It is included when each .nc file is compiled. Hardware.h is used to define the main constants and
variables. The timer is accounted separately by a file named AGTimer.h.
#ifndef _H_hardware_h
#define _H_hardware_h
#include <atm128hardware.h>
#include <Atm128Adc.h>
#ifndef MHZ
/* Clock rate is ~8MHz except if specified by user
(this value must be a power of 2, see AGTimer.h) */
#define MHZ 8
#endif
#include "AGtimer.h"
enum {
PLATFORM_BAUDRATE = 57600L
};
#endif // _H_hardware_h
Final tree:
The illustration below shows the final tree of files added to the tinyos-2.x tree, in order to support the
Aquisgrain platform.
Illustration 1: File tree of Aquisgrain platform
2. The Serial Port
The microcontroller Atmega128 is provided with an UART which is used to connect a sensing device
to the MIB510 programming board. This last one is in turn connected to a PC through a serial cable.
This system allows two main functionnalities :
The TestSerial application that is located in "tinyos-2.x/apps/tests" can be used to test the serial port. By
using a timer, this application sends the incremental value of a counter to the serial port. Consequently
a led display the value received through the serial port. Thanks to this application, the serial port has
been successfully tested for both emission and reception.
The only file to add is PlatformSerialC.nc which details UART specifics. The PlatformSerialC.nc has
not been modified from the version of Mica Family.
3. Leds
The Atmega128 chip is also used on Mica boards, so their files are used like a base.
In contrast with the tinyos version 1, the version 2.0 names leds by number and not by colour. The rest
of PlatformLedsC.nc file is equal to the one for Mica boards.
Although leds might be tested separately, they have been tested in conjunction with the clock.
4. Clock
Because the clock is dependant of the microcontroller (counters and registers are built-in the
microcontroller), we just need to adapt the code of a platform using the Atmega128 chip. So the Micaz
board is choosen. All the files related to the counters/timers are copied into the aquisgrain directory :
This module is based on CC2420. Due to many files needed, a directory is created within
platforms/aquisgrain/chips/CC2420. The files from MicaZ platform are copied to this directory and
fitted to the AquisGrain platform.
InterruptCCA = HplCC2420InterruptsP.CCA;
HplCC2420PinsC.nc : It maps the CC2420 pins to Atmega128 pins for the aquisgrain platform.
CCA = IO.PortD5;
CSN = IO.PortB0;
FIFO = IO.PortE5;
FIFOP = IO.PortE4;
RSTN = IO.PortD7;
SFD = IO.PortD4;
VREN = IO.PortB5;
MotePlatformP.nc : It contains a function power_init() that starts the voltage regulator of the CC2420.
2
http://www.tinyos.net/tinyos-2.x/doc/html/tep102.html
6. How to download an application on the board
In order to download the application on the board, first check the number of the serial port provided by
windows in the Device Manager.
Then use this number minus one with /dev/ttySX (COM5 becomes /dev/ttyS4 and so on). The command
to build the binary is :
The option install can be replaced with reinstall that just sets the mote Id and download the binary
without recompiling it.
3
4
Firstly, the message is built by using mig, the message interface generator for nesC. Mig needs a
1 header file, describing the message structure, and mig will generate nesC files, so that we can
use the message structure over the radio and the serial connection.
Next, the NesC files (*.nc) are converted in one C file (app.c), and this file is compiled to exec
2 (main.exe).
Next, the binary file is translated in many formats, by using avr-objcopy with platform-specific
3 options.
4 Next, the symbols are set (the mote id in our case) on the binary.
Finally the mote is programmed by using the programming board options specified in the
5 command.