Вы находитесь на странице: 1из 26

Customs the Arduino IDE

Arduino IDE
Arduino 1.0.5
Arduino 1.5.x
Arduino 1.6.x

Arduino 1.0.5
The Arduino IDE (at least since 1.05) has the wonderful
capability of being customizable for new types of hardware.
You can add code that supports pin/port assignments or even
new kinds of processors (such as the xmega) by re-writing
the core libraries and headers and placing them into new
directories within the Arduino environment directories.

Arduino 1.0.5
boards.txt
The most important single file is the 'boards.txt' file, located in the
following directory:

{ARDUINO}/hardware/arduino/boards.txt

where '{ARDUINO}' represents the directory into which the Arduino


IDE and supporting files have been installed. This may be
'/usr/local/arduino' or '/usr/share/arduino' or one of many OTHER
possible choices depending on your operating system.

ARDUINO 1.0.5

ARDUINO 1.0.5
The prefix ('uno' in this case) is unique for a particular board.
So if you create a new board, you would write a similar
section and add it to 'boards.txt', with 'myboard' (or
whatever) in place of 'uno' at the beginning of each string,
and modify the description accordingly.

ARDUINO 1.0.5
Custom Libraries
Sometimes you will need to customize a standard library for your own use.
Unfortunately this may be due to the fact that, all too often, the libraries
don't support your hardware properly, and/or do NOT have the common
decency to mark members as 'protected' rather than 'private' (forcing you
to edit the library or clone it, rather than creating a derived class).
Fortunately, the Arduino IDE allows you to put your own libraries into a userspecific location:

{SKETCHBOOK}/libraries
Where '{SKETCHBOOK}' is the location of your default sketchbook
repository (as specified in 'preferences').

ARDUINO 1.0.5
Custom Libraries
The Arduino IDE will look in {SKETCHBOOK}/libraries for matching library
names when you '#include' a header file in the main 'INO' (or PDE) file.
So you will always need to specify the header file in the main 'INO' file so
that the Arduino IDE can locate it (along with any source files).

Additional information about custom libraries can be found here:


http://arduino.cc/en/Guide/Libraries

See also the official Arduino IDE 1.5+ Library specification

Arduino 1.5.x
Hardware Folders structure
The new hardware folders have a hierarchical structure organized in
two levels:

the first level is the vendor/maintainer


the second level is the supported architecture A vendor/maintainer can
have multiple supported architectures.

Arduino 1.5.x
Hardware Folders structure
For example, below we have three hardware vendors called "arduino",
"yyyyy" and "xxxxx":

hardware/arduino/avr/...
hardware/arduino/sam/...

- Arduino - AVR Boards


- Arduino - SAM (32bit ARM) Boards

hardware/yyyyy/avr/...

- Yyy - AVR

hardware/xxxxx/avr/...

- Xxx - AVR

the vendor "arduino" has two supported architectures (AVR and SAM),
while "xxxxx" and "yyyyy" have only AVR.

Arduino 1.5.x
Architecture configurations
Each architecture must be configured through a set of
configuration files:
platform.txtcontains definitions for the CPU architecture used

(compiler, build process parameters, tools used for upload, etc.)

boards.txtcontains definitions for the boards (board name,


parameters for building and uploading sketches, etc.)

programmers.txtcontains definitions for external programmers

(typically used to burn bootloaders or sketches on a blank CPU/board)

Arduino 1.5.x
Comments
Lines starting with # are treated as comments and will be
ignored
# Like in this example
# -------------------# I'm a comment!

Arduino 1.5.x
platform.txt
The platform.txt file contains information about a platform's specific aspects
(compilers command line flags, paths, system libraries, etc.).

The following meta-data must be defined:


name=Arduino AVR Boards
version=1.5.3

The name will be shown in the Boards menu of the Arduino IDE.
The version is currently unused, it is reserved for future use (probably
together with the libraries manager to handle dependencies on cores).

Arduino 1.5.x
platform.txt
The platform.txt file contains information about a platform's specific aspects
(compilers command line flags, paths, system libraries, etc.).

The following meta-data must be defined:


name=Arduino AVR Boards
version=1.5.3

The name will be shown in the Boards menu of the Arduino IDE.
The version is currently unused, it is reserved for future use (probably
together with the libraries manager to handle dependencies on cores).

Arduino 1.5.x
boards.txt
This file contains definitions and meta-data for the boards
supported. Every board must be referred through its short
name, the board ID. The settings for a board are defined
through a set of properties with keys having the board ID as
prefix.

Arduino 1.5.x
boards.txt
For example the board ID chosen for the Arduino Uno board is "uno".
An extract of the Uno board configuration (in boards.txt file) looks like:
[......]
uno.name=Arduino Uno
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.board=AVR_UNO
uno.build.core=arduino
uno.build.variant=standard
[......]

Arduino 1.5.x
boards.txt
Note that all the relevant keys start with the board
IDuno.xxxxx.

Theuno.nameproperty contains the name of the board


shown in the Boards menu of the Arduino IDE.

Theuno.build.boardproperty is used to set a compile-time


variableARDUINO_{build.board}to allow use of conditional
code between #ifdefs.

The Arduino IDE automatically generate abuild.boardvalue if


not defined. In this case the variable defined at compile time
will be ARDUINO_AVR_UNO.

Arduino 1.5.x
boards.txt
The other properties will override the corresponding global
properties of the IDE when the user selects the board. These
properties will be globally available, in other configuration
files too, without the board ID prefix:
uno.build.mcu

=> build.mcu

uno.build.f_cpu

=>

uno.build.board

=> build.board

uno.build.core

=> build.core

uno.build.variant

=> build.variant

build.f_cpu

Arduino 1.5.x
boards.txt
this explains the presence of {build.mcu} or {build.board} in
the platform.txt recipes: their value is overwritten
respectively by {uno.build.mcu} and {uno.build.board}
when the Uno board is selected!

Arduino 1.5.x
boards.txt
Moreover the IDE automatically provides the following
properties:

{build.core.path}
- The path to the selected board's core folder
(for example hardware/arduino/avr/core/arduino)

{build.system.path}
- The path to the selected platform's system folder if available
(for example hardware/arduino/sam/system)

{build.variant.path}
- The path to the selected board variant folder
(for example hardware/arduino/avr/variants/micro)

Arduino 1.5.x
Custom board menus
The board used in the example is the Arduino Duemilanove: this
board was produced in two models one with an ATmega168 CPU and
another with an ATmega328.

We are going then to define a custom menu "Processor" that allows


the user to choose between the two different microcontrollers.

We must first define a set of menu.MENU_ID=Text properties. Text is


what is displayed on the GUI for every custom menu we are going to
create and must be declared at the beginning of the boards.txt file:

Arduino 1.5.x
We have defined two options: "ATmega328" and
"ATmega168".

Note that the property keys must follow the format


BOARD_ID.menu.MENU_ID.OPTION_ID=Text.

Finally, the specific configuration for every option:

Arduino 1.5.x
[.....]
## Arduino Duemilanove w/ ATmega328
duemilanove.menu.cpu.atmega328=ATmega328
duemilanove.menu.cpu.atmega328.upload.maximum_size=30720
duemilanove.menu.cpu.atmega328.upload.speed=57600
duemilanove.menu.cpu.atmega328.build.mcu=atmega328p
## Arduino Duemilanove w/ ATmega168
duemilanove.menu.cpu.atmega168=ATmega168
duemilanove.menu.cpu.atmega168.upload.maximum_size=14336
duemilanove.menu.cpu.atmega168.upload.speed=19200
duemilanove.menu.cpu.atmega168.build.mcu=atmega168
[.....]

Arduino 1.6.x
1.6.3
The new Board Manager solves those issues. We had figured
out a way to add custom boards in v1.6.3 of the Arduino IDE,
but it was not officially supported by Arduino. Thanks to the
hard work of Federico Fissore and the Arduino developer
community, we can now add new boards just as easily using
officially supported methods. Let's get started.

Arduino 1.6.x
1.6.4
Version 1.6.4 of the Arduino IDEintroduced official support
for adding third party boards (like the Adafruit Flora and
Trinket) to the new Board Manager. This addition is great
news, because it allows users to quickly add new boards with
the click of a button. Previously the addition of new boards
required a cumbersome manual installation process, or in
certain cases,the download of a completely separate version
of the IDE with the new boards added.

Arduino 1.6.x
Index packet .json format
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.6.x--package_index.json-format-specification

https://
github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-b
oards-support-urls