Building and running a MOS example application

The MANTIS source code comes with several example applications, which can be found in the src/apps directory; a good way to become familiar with MANTIS is to build and install an example application, and then modify it.

The first step is to build and install an example application; in this tutorial, we'll use the LED example application found in src/apps/led_example.

The MANTIS source tree supports two different build systems — a standard autotools system (autogen, configure, make), and SCons. SCons is generally the preferred method for building software because it provides greater flexibility; using SCons, you can specify exactly which parts of the system that you do or do no want to be built into your image. Compiling and running your first application goes into SCons in more depth.

Building with SCons
To build an application with scons, type
$ cd src/apps/led_example
$ scons -D platform=telosb


The image that has been generated can now be found in src/apps/led_example/build-telosb.

other platforms (micaz, mica2, mica2dot) can be substituted as the platform argument.

there are a couple other arguments you can pass to scons:
  • load or load=app_name - load the built program onto a node. Specify an application name if more than one image is going to be built.
  • debug=1 - (mica2/micaz only) turn on NodeMD, runtime fault diagnosis.

Building with Autotools

Building with autotools is a little more complicated:

$ cd mantis-src
$ ./autogen.sh
$ cd build/telosb
$ ./configure && make


The previous commands will build the MOS kernel and all applications for telosb. The image is now located in build/telosb/src/apps/led_example.

To install the program, you should now change to the build directory;
for TELOSb:
$ bsl.py --telosb -e -c /dev/ttyUSB0 -p led_example.elf

Note that if you are using Windows with the VCP driver, the node will be located on /dev/ttySx, where X is one less than the COM number assigned by Windows.

for Mica2/MICAz:
$ mos_shell -p led_example.srec

(and reset the programming board)