An alternative way of building arduino sketches with SCons.
This project is designed to be:
- Flexible. Code generation? Multiple builds for different boards uploaded to the correct ports from one script? No problem.
- Easy to understand. No source munging. No automatic library detection. No magic.
This can either be installed system-wide, or per-project. Either way,
arduino.py should be installed into
$SITE_SCONS is one of the directories listed in the
SCons man page under
On Linux the following directories are appropriate:
$HOME/.scons/site_scons can be accomplished by running
This script does not do any munging of your source files, so you may need
reorder your functions (or add function prototypes), and add
#include <Arduino.h>. Your sketch should be in a
.cpp file, rather than an
A script to compile and upload a basic sketch might look something like this:
env = Environment(tools=["default", "arduino"]) env.ConfigureBoard("atmega328") core = env.ArduinoCore() sketch = env.Sketch("blink", ["blink.cpp", core]) env.Upload(sketch)
examples directory for more examples.
Installing the tool into an environment gives it the following methods:
This sets defaults for a whole bunch of environment variables (described
below), based on the board name. The supported boards and their settings can be
Compile the arduino core library into a static library.
Compile a standard arduino library into a static library, and add it to the include path.
Compile an arduino library in a given directory into a static library, and add it to the include path.
env.Hex to compile a list of sources (either source
files or libraries) into a hex file (named name.hex) for uploading.
Adds an alias (named upload by default) which uploads the given hex file to an
arduino connected to
$UPLOAD_PORT. Strange things happen if this is called
multiple times with the same name; either add an alias which defers to multiple
upload targets, or use
Add an alias which defers to all upload targets in
$ALL_UPLOADS, which is
The root of the arduino install. By default this is taken from the environment
variable of the same name; if this is not found,
/usr/share/arduino is used.
The name of the board passed to
CPU frequency in Hz.
MCU string passed to gcc and avrdude.
Directory for the above variant.
Core name for this board; always "arduino".
Directory of the core library for this board.
The directory to build in, by default
The avrdude binary to use.
Flags to pass to avrdude.
The full avrdude command line.
The upload protocol to use with avrdude.
Upload speed for this board.
USB port to upload to, by default
The following variables have their standard meanings, and are set by
MIT licensed; see