Computing stuff tied to the physical world

Compile and upload the bare minimum

To make things compile, we’ll need some definitions in the global “Arduino.h” header file. To be honest, the standard one is filled with gobbledygook with lots of #define‘s, all with global scope. The potential name clashes are a recipe for disaster in the long term.

But let’s ignore that for now. The first objective is simply to get some code to compile and upload. So let’s start with the following definitions in the “Arduino.h” header file:

#define INPUT 0
#define OUTPUT 1

#define LOW 0
#define HIGH 1

extern void pinMode (int pin, int mode);
extern void digitalWrite (int pin, int level);
extern void delay (int ms);

We’ll also need a “main.cpp” file, with the following code in it:

extern void setup ();
extern void loop ();

int main () {
    while (true)
    return 0;

Some additional code and definitions are needed to get any C or C++ program off the ground, this code has been copied over from the embello project. It consists of:

  • the low-memory jump vector table with (mostly) dummy entries
  • code to initialise RAM (inited data as well as “bss” blank memory)
  • default interrupt handlers which enters an infinite loop unless re-defined

And lastly, we’ll need a “linker definition file” to define the layout of the generated binary file and the placement of all the code. It’s about 50 lines of code and available on GitHub.

All of this has been developed and documented earlier on the weblog. It’s merely being re-purposed and adjusted here to fit the Arduino IDE’s wishes and conventions.

Here is the result of all this tinkering so far:

Screen Shot 2015 10 20 at 22 13 30

The boards.txt and platform.txt files have been been tweaked a bit, with config settings to launch the uploader tool. Note that these settings are Mac OSX specific for now, it should be straightforward to adjust them further to support Windows and Linux (see issue #2).

The next step will be to add a bit of library code to support some of the standard Arduino runtime functions on the LPC824, such as digitalWrite(), delay(), etc.

[Back to article index]