Cduino Manual

Architecture Overview

First take a look at the abstract on the home page.

The common code (make plus a bit of perl) required to compile and upload programs lives in the top-level directory. Modules live in their own subdirectories and link into the top level directory and each other as needed. For example, if a module needs to use serial communication, it will contain symbolic links to the serial communication implementation and headers in the uart module. The uart module itself contains both the uart interface and implementation, and a demonstration program showing how to use the interface. The overall architecture is thus more prototypal than hierarchical. This is a convenient arrangement for microcontrollers, where the target is often a self-contained or mostly self-contained system.

Basic Strategies for Using and Modifying

To start making your own stand-along program without caring about the rest of Cduino:

  1. Do cp --recursive --dereference some_module ~/new_program where some_module is the one that already comes closest to doing what you want.
  2. Grab code from other modules as needed and mix it in. Note that you are responsible for keeping track of the dependencies of this additional code. Generally this means checking for included headers, which should appear as symbolic links in the other module's subdirectories.

To add a new module to Cduino (a nice thing to do for others):

  1. Make a new subdirectory for it.
  2. Give it its own minimal Makefile that includes generic.mk (see for example the simple_blink module Makefile).
  3. Link (ln -s) to existing headers and sources in other modules as needed.
  4. Write a program that exercises the module using the simplest possible hardware setup. This is the program that the writeflash target will put on the chip when built in your module's subdirectory.
  5. Put comments in the module Makefile or give it a README in which you say what it does or give a pointer to that information, and describe any hardware required to exercise the module effectively.

generic.mk: What it Assumes and What it Provides

The code in generic.mk contains most of the voodoo required to compile and upload C code for the arduino. There are sensible defaults for all settings. The simplest possible Makefile for a module consists of a single line: include generic.mk (where generic.mk is a symbolic link to the file generic.mk in the distribution top-level directory).

To disable some troublesome crufty old Make behavior, the -R option must be passed to all make invocations that use generic.mk. The generic.mk file provides the following targets intended for public use: By default, the targets in generic.mk intended for public use behave like this:

So by default, you just write your code and type make -R writeflash in your module subdirectory. You may not need to know any further details.

If more control is needed, there are a number of Make variables that affect how generic.mk behaves. These occur in sections marked "Overridable" in that file.

Variable Overview