SCons

SCons is a software construction tool, much like make. It is written entirely in Python, so you have the power of a real programming language to customize your build environment at will.

It is not a compiler/linker, but rather a scripting tool to invoke the toolchain-specific compilers/linkers installed on your development host. That is, even if you install SCons, you still have to install the compilers/linkers SCons will invoke.

We thank Chris Snyder for his contribution to setting up this environment.

Installation

See the SCons project's Download page for installation and setup instructions. In our experience, the process is straightforward.

Building Firmware

This section describes the SCons command line and options, and shows an example build.

SCons commands are entered at the command line in the form:

 scons [ options...  ] [ name=val...  ] [ project ] 

Always issue Scons commands from the top level directory, openwsn-fw/. It will not work if you navigate down into the directory structure.

Inline Help

Typing scons without any option will print the help text.

 Example help output...
C:\Users\Thomas\Desktop\openwsn-fw>scons --help
scons: Reading SConscript files ...
 ___                 _ _ _  ___  _ _
| . | ___  ___ ._ _ | | | |/ __>| \ |
| | || . \/ ._>| ' || | | |\__ \|   |
`___'|  _/\___.|_|_||__/_/ <___/|_\_|
     |_|                  openwsn.org
scons: done reading SConscript files.
Usage:
    scons [<variable>=<value> ...] <project>
    scons docs
    scons [help-option]
project:
    A project is represented by a subdirectory of the
    firmware\openos\projects directory, for a particular board. For
    example, the 'oos_openwsn' project may be built for telosb. To specify a
    project, exclude the leading digits in the directory name, like '03' for
    oos_openwsn.
    variable=value pairs
    These pairs qualify how the project is built, and are organized here into
    functional groups. Below each variable's description are the valid
    options, with the default value listed first.
    board        Board to build for. 'python' is for software simulation.
                 telosb, wsn430v14, wsn430v13b, gina, z1, pc, python
    toolchain    Toolchain implementation. The 'python' board requires gcc
                 (MinGW on Windows build host).
                 mspgcc, iar, iar-proj, gcc
    Connected hardware variables:
    bootload     Location of the board to bootload the binary on.
                 COMx for Windows, /dev entries for Linux
                 Supports parallel operation with a comma-separated list,
                 for example 'COM5,COM6,COM7'.
    jtag         Location of the board to JTAG the binary to.
                 COMx for Windows, /dev entry for Linux
    fet_version  Firmware version running on the MSP-FET430uif for jtag.
                 2, 3
    Simulation variables:
    fastsim      Compiles the firmware for fast simulation.
                 1 (on), 0 (off)
    These simulation variables are for a cross-platform build, and are valid
    only from an amd64-linux build host.
    simhost      Host platform and OS for simulation. Default selection is
                 the current platform/OS, which of course is not a cross-
                 build. x86-windows cross-build requires MinGW-w64 toolchain.
                 amd64-linux, x86-linux, amd64-windows, x86-windows
    simhostpy    Home directory for simhost cross-build Python headers and
                 shared library.
    Common variables:
    verbose      Print each complete compile/link comand.
                 0 (off), 1 (on)
docs:
    Generate source documentation in build\docs\html directory
help-option:
    --help       Display help text. Also display when no parameters to the
                 scons scommand.
Use scons -H for help about command-line options.

Options

The following options are available:

NameExplanation
--helpDisplay OpenWSN-specific help (see Inline Help section)
-HDisplay generic SCons help

name=val Pairs

These pairs specify how to build the project, and optionally load onto hardware.

NameValues
(default listed first)
Notes
board
telosb, gina, pc, wsn430v14, wsn430v13b, python
 
toolchain
mspgcc, iar, iar-proj
 
jtaglocation of the target JTAG deviceIf you set this option, the executable, if built successfully, will be loaded onto the target over JTAG.
fet_versionversion numberWhen using the jtag options, and loading onto an MSP430 using a MSP-FET430uif, indicates which firmware is running on it.
bootloadlocation of the target mote(s) for bootload

If you set this option, the binary file, if built successfully, will be loaded onto the target(s) using the appropriate bootloader. You can specify multiple locations, separated by commas. The bootloading happens in parallel; 50 boards load as fast as a single board.

verbose0 (OFF) or 1 (ON)Print complete command/link command

Project

The OpenWSN project to build. Don't include the numeric prefix in the project's directory name. For example, use 'bsp_leds' rather than '01bsp_leds'.

Example Build

To build the oobsp_leds project for the TelosB platform, using mspgcc on Windows, and load the resulting binary on TelosB boards connected to COM ports 12-14 of your computer, type:

scons board=telosb toolchain=mspgcc bootload=COM12,COM13,COM14 bsp_leds

You should see console output like this:

C:\Users\Thomas\Desktop\openwsn-fw>scons board=telosb toolchain=mspgcc bootload=COM12,COM13,COM14 bsp_leds
scons: Reading SConscript files ...
 ___                 _ _ _  ___  _ _
| . | ___  ___ ._ _ | | | |/ __>| \ |
| | || . \/ ._>| ' || | | |\__ \|   |
`___'|  _/\___.|_|_||__/_/ <___/|_\_|
     |_|                  openwsn.org
scons: done reading SConscript files.
scons: Building targets ...
Compiling firmware\openos\projects\common\01bsp_leds\01bsp_leds.o
Compiling build\telosb_mspgcc\bsp\board.o
Compiling build\telosb_mspgcc\bsp\bsp_timer.o
Compiling build\telosb_mspgcc\bsp\debugpins.o
Compiling build\telosb_mspgcc\bsp\eui64.o
Compiling build\telosb_mspgcc\bsp\leds.o
Compiling build\telosb_mspgcc\bsp\radiotimer.o
Compiling build\telosb_mspgcc\bsp\spi.o
Compiling build\telosb_mspgcc\bsp\uart.o
Compiling build\telosb_mspgcc\bsp\cc2420\radio.o
Archiving build\telosb_mspgcc\bsp\libbsp.a
Indexing build\telosb_mspgcc\bsp\libbsp.a
Linking firmware\openos\projects\common\01bsp_leds_prog.exe
msp430-size firmware\openos\projects\common\01bsp_leds_prog.exe
   text    data     bss     dec     hex filename
   2912       0      38    2950     b86 firmware\openos\projects\common\01bsp_le
ds_prog.exe
msp430-objcopy --output-target=ihex firmware\openos\projects\common\01bsp_leds_p
rog.exe firmware\openos\projects\common\01bsp_leds_prog.ihex
msp430-objcopy --output-target=binary firmware\openos\projects\common\01bsp_leds
_prog.exe firmware\openos\projects\common\01bsp_leds_prog.bin
telosb_bootload(["firmware\openos\projects\common\01bsp_leds_prog.phonyupload"],
 ["firmware\openos\projects\common\01bsp_leds_prog.ihex"])
starting bootloading on COM12
 starting bootloading on COM13starting bootloading on COM14
MSP430 Bootstrap Loader Version: 1.39-telos-8
MSP430 Bootstrap Loader Version: 1.39-telos-8
Mass Erase...
Mass Erase...
MSP430 Bootstrap Loader Version: 1.39-telos-8
Mass Erase...
Transmit default password ...
Transmit default password ...
Transmit default password ...
Invoking BSL...
Invoking BSL...
Invoking BSL...
Transmit default password ...
Transmit default password ...
Transmit default password ...
Current bootstrap loader version: 1.61 (Device ID: f16c)
Changing baudrate to 38400 ...
Current bootstrap loader version: 1.61 (Device ID: f16c)
Changing baudrate to 38400 ...
Program ...
Current bootstrap loader version: 1.61 (Device ID: f16c)
Changing baudrate to 38400 ...
Program ...
Program ...
2912 bytes programmed.
Reset device ...
2912 bytes programmed.
Reset device ...
2912 bytes programmed.
Reset device ...
done bootloading on COM14
done bootloading on COM13
done bootloading on COM12
scons: done building targets.