Among all the good things in the Arduino platform, is the huge amount of libraries. They either come from the standard Arduino distribution or from third party developer. And what’s even better is that they are all written in C++ ! Here is a list of some of the library i’m planning to use for this project:
- Arduino distrib’s library :
- Core Library:
- Hardware serial communication library
- Additional Library:
- SPI library (SPI is a communication protocol used to connect chips or other devices to the Arduino)
- Core Library:
- Third party distrib:
I will probably use other one, but for now these are the only one which sound really useful …
Compiling Arduino Core library:
So as Arduino is an OpenSource project, all the source code are freely available. You can get them here: https://github.com/arduino/Arduino/tree/master/hardware/arduino/cores/arduino In order to understand how to compile them, i have used mainly two sources of informations:
- The Arduino web page explaining how to setup eclipse IDE to compile Arduino code (This article include a paragraph about how to compile Arduino Core Library)
- The output of the Arduino IDE ( Check File->Preferences->Show verbose output during: compilation / upload )
After several tests, here are the GCC options i’m using for compiling the Core Library (and all the other one in fact !):
- Compiling C Code:
- -c : Do not invoke linker after compilation
- -g : Generate debug informations
- -Os: Optimize code to reduce it’s size
- -Wall: Enable all warning
- -ffunction-sections : Place functions item into its own section in the output file
- -fdata-sections : Place data items into its own section in the output file
- -mmcu=atmega328p: Select the right type of AVR to use
- -DF_CPU=16000000L: Specify the clock frequency of the AVH in hertz
- -MMD: ???
- -DUSB_VID=null: ???
- -DUSB_PID=null: ???
- -DARDUINO=105: Version of the Arduino libs
- Compiling C++ Code:
- All the previous one plus:
- -fno-exceptions: Disable C++ exception support which are not supported by Arduino (And probably the underlying AVR hardware…)
Hate MakeFile, love CMake :
As i’m working under a Linux environment (Raspian on Raspberry Pi), i need some kind of MakeFile to drive the build process. I’m not a fan of this kind of file so i decided to go and use CMake to generate them for me! CMake is a great tool that allow you to write all your program/library specification using a simple language and which convert this specifications into a very complete Makefile or even a Project for the Microsoft Compiler !
Here is the Specification file i use to build the ArduinoCore Library:
Compiling others library:
Others libraries, including Arduino additional libraries and third party libraries are build the exact same way. So actually i’m building 4 library:
- Arduino Core
- Arduino SPI
- Arduino SPI RAM
- Arduino MIDI
Here is a link to the git hub project that host all of those library with the appropriate CMakeLists.txt (CMake specification file).
As always: Feel free to use it !