Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 97c4f00

Browse files
authoredMar 19, 2020
[skip changelog] Migrate relevant documentation pages from arduino/Arduino wiki (#616)
* Migrate relevant documentation from arduino/Arduino wiki * Trim trailing whitespace * Add newline to end of file * Increase heading levels so that the minimum level is h2 This is required for table of contents generation. * Use supported line break markup The backslash at end of line to cause line break is not supported by the documentation build system. * Update links to migrated pages * Fix list markup The documentation build system requires a blank line before the start of a list
1 parent 0866d99 commit 97c4f00

File tree

7 files changed

+1206
-3
lines changed

7 files changed

+1206
-3
lines changed
 

‎docs/FAQ.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ When you run `arduino-cli board list`, your board doesn't show up. Possible caus
1111
## What's the FQBN string?
1212

1313
For a deeper understanding of how FQBN works, you should understand
14-
Arduino Hardware specification. You can find more information in this
15-
[arduino/Arduino wiki page][0].
14+
Arduino Hardware specification. You can find more information in the
15+
[Arduino platform specification][0].
1616

1717

18-
[0]: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
18+
[0]: platform-specification.md
15.6 KB
Loading

‎docs/library-specification.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
This is the specification for the 3rd party library format to be used with Arduino IDE 1.5.x onwards.
2+
3+
* rev.1 has been implemented starting with IDE version 1.5.3 (now superseded by rev.2)
4+
* rev.2 will be implemented starting from version 1.5.6
5+
* rev.2.1 will be implemented starting from version 1.6.10
6+
* rev.2.2 will be implemented starting from version 1.8.10
7+
8+
This new library format is intended to be used in tandem with the Arduino IDE"s **Library Manager**, available since version 1.6.2. The Library Manager allows users to automatically download and install libraries needed in their projects, with an easy to use graphic interface. It doesn't yet take care of dependencies between libraries.
9+
More information about how Library Manager works are available [here](https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ).
10+
11+
Arduino IDE 1.5.x+ supports multiple microcontroller architectures (e.g. AVR, SAM, etc), meaning that libraries may need to work on multiple architectures. The new 1.5 library format doesn’t contain special support for cross-architecture libraries, but it does provide a preprocessor based mechanism for libraries to target sections of code to specific architectures.
12+
13+
## See also
14+
15+
The Arduino library style guide is here : http://arduino.cc/en/Reference/APIStyleGuide
16+
17+
The style guide for examples is here : http://arduino.cc/en/Reference/StyleGuide
18+
19+
## 1.5 library format (rev. 2.2)
20+
21+
### Library metadata
22+
23+
The most significant addition to the format is the ability to add information about the library itself through a properties file called **library.properties**.
24+
25+
This file allows the *Library Manager* to search and install a library and its dependencies in an easy and automated way. It must be located in the root of the library folder.
26+
27+
#### library.properties file format
28+
29+
The library.properties file is a key=value properties list. Every field in this file is UTF-8 encoded. Unless noted otherwise below, **all fields are required**. The available fields are:
30+
31+
* **name** - the name of the library. Library names must contain only basic letters (`A`-`Z` or `a`-`z`) and numbers (`0`-`9`), spaces (` `), underscores (`_`), dots (`.`) and dashes (`-`). It cannot start or end with a space, and also it cannot start with a number. Note that libraries with a `name` value starting with `Arduino` will no longer be allowed [addition to the Library Manager index](https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ) as these names are now reserved for official Arduino libraries.
32+
* **version** - version of the library. Version should be [semver](http://semver.org/) compliant. 1.2.0 is correct; 1.2 is accepted; r5, 003, 1.1c are invalid
33+
* **author** - name/nickname of the authors and their email addresses (not mandatory) separated by comma ","
34+
* **maintainer** - name and email of the maintainer
35+
* **sentence** - a sentence explaining the purpose of the library
36+
* **paragraph** - a longer description of the library. The value of **sentence** always will be prepended, so you should start by writing the second sentence here
37+
* **category** - (defaults to `Uncategorized`) if present, one of these:
38+
* Display
39+
* Communication
40+
* Signal Input/Output
41+
* Sensors
42+
* Device Control
43+
* Timing
44+
* Data Storage
45+
* Data Processing
46+
* Other
47+
* **url** - the URL of the library project, for a person to visit. For example, the library's GitHub page. This is used for the "More info" links in Library Manager
48+
* **architectures** - (defaults to `*`) a comma separated list of architectures supported by the library. If the library doesn’t contain architecture specific code use `*` to match all architectures. This field is used as one factor in determining priority when multiple libraries match an `#include` directive and to provide a warning message when the library is compiled for a board of an architecture that doesn't match any on the list.
49+
* **depends** - **(available from Arduino IDE 1.8.10)** (optional) a comma-separated list of dependencies (libraries that are needed to build the current library). Library Manager will offer to install the dependencies during installation of the library. Since spaces are allowed in the `name` of a library, but not commas, you can refer to libraries containing spaces in the name without ambiguity for example:
50+
51+
`depends=Very long library name, Another library with long-name`
52+
53+
* **dot_a_linkage** - **(available from Arduino IDE 1.6.0 / arduino-builder 1.0.0-beta13)** (optional) when set to `true`, the library will be compiled using a .a (archive) file. First, all source files are compiled into .o files as normal. Then instead of including all .o files in the linker command directly, all .o files are saved into a .a file, which is then included in the linker command. [1.5 format library folder structure](#layout-of-folders-and-files) is required.
54+
* **includes** - **(available from Arduino IDE 1.6.10)** (optional) a comma separated list of files to be added to the sketch as `#include <...>` lines. This property is used with the "Include library" command in the IDE. If the `includes` property is missing all the headers files (.h) on the root source folder are included.
55+
* **precompiled** - **(available from Arduino IDE 1.8.6/arduino-builder 1.4.0)** (optional) set to `true` to allow the use of .a (archive) and .so (shared object) files. The .a/.so file must be located at `src/{build.mcu}` where `{build.mcu}` is the architecture name of the target the file was compiled for. Ex: `cortex-m3` for the Arduino DUE. The static library should be linked as an ldflag.
56+
* **ldflags** - **(available from Arduino IDE 1.8.6/arduino-builder 1.4.0)** (optional) the linker flags to be added. Ex: `ldflags=-lm`
57+
58+
Example:
59+
60+
name=WebServer
61+
version=1.0.0
62+
author=Cristian Maglie <c.maglie@example.com>, Pippo Pluto <pippo@example.com>
63+
maintainer=Cristian Maglie <c.maglie@example.com>
64+
sentence=A library that makes coding a Webserver a breeze.
65+
paragraph=Supports HTTP1.1 and you can do GET and POST.
66+
category=Communication
67+
url=http://example.com/
68+
architectures=avr
69+
includes=WebServer.h
70+
depends=ArduinoHttpClient
71+
72+
### Layout of folders and files
73+
74+
Each folder has a specific purpose (sources, examples, documentation, etc). Folders not covered in this specification may be added as needed to future revisions.
75+
76+
#### Library Root folder
77+
78+
The library root folder name must start with a basic letter (`A`-`Z` or `a`-`z`) or number (`0`-`9`), followed by basic letters, numbers, spaces (` `), underscores (`_`), dots (`.`) and dashes (`-`). The maximum length is 63 characters.
79+
80+
#### Source code
81+
82+
For 1.5.x+-only libraries, the source code resides in the **src** folder. For example:
83+
84+
Servo/src/Servo.h
85+
Servo/src/Servo.cpp
86+
87+
The source code found in **src** folder and *all its subfolders* is compiled and linked in the user’s sketch. Only the *src* folder is added to the include search path (both when compiling the sketch and the library). When the user imports a library into their sketch (from the "Tools > Import Library" menu), an #include statement will be added for all header (.h) files in the src/ directory (but not its subfolders). As a result, these header files form something of a de facto interface to your library; in general, the only header files in the root src/ folder should be those that you want to expose to the user's sketch and plan to maintain compatibility with in future versions of the library. Place internal header files in a subfolder of the src/ folder.
88+
89+
For backward compatibility with Arduino 1.0.x, the library author may opt to place source code into the root folder, instead of the folder called **src**. In this case the 1.0 library format is applied and the source code is searched from the **library root folder** and the **utility** folder, for example:
90+
91+
Servo/Servo.h
92+
Servo/Servo.cpp
93+
Servo/utility/ServoTimers.h
94+
Servo/utility/ServoTimers.cpp
95+
96+
This will allow existing 1.0.x libraries to compile under 1.5.x+ as well and vice-versa. If a library only needs to run on 1.5.x+, we recommend placing all source code in the src/ folder. If a library requires recursive compilation of nested source folders, its code must be in the src/ folder (since 1.0.x doesn’t support recursive compilation, backwards compatibility wouldn’t be possible anyway).
97+
98+
#### Library Examples
99+
100+
Library examples must be placed in the **examples** folder. Note that the **examples** folder must be written exactly like that (with lower case letters).
101+
102+
Servo/examples/...
103+
104+
Sketches contained inside the examples folder will be shown in the Examples menu of the IDE.
105+
106+
#### Extra documentation
107+
108+
An **extras** folder can be used by the developer to put documentation or other items to be bundled with the library. Remember that files placed inside this folder will increase the size of the library, so putting a 20MB PDF in a library that weights a few kilobytes may not be such a good idea.
109+
110+
The content of the *extras* folder is totally ignored by the IDE; you are free to put anything inside such as supporting documentation, etc.
111+
112+
### Keywords
113+
114+
A list of keywords for the library may be specified in a file named keywords.txt located in the root of the library folder. When a keyword of any installed library is used in a sketch the Arduino IDE colors it.
115+
116+
Servo/keywords.txt
117+
118+
An example keywords file:
119+
```
120+
# Syntax Coloring Map For ExampleLibrary
121+
122+
# Datatypes (KEYWORD1)
123+
Test KEYWORD1
124+
125+
# Methods and Functions (KEYWORD2)
126+
doSomething KEYWORD2
127+
128+
# Instances (KEYWORD2)
129+
130+
# Constants (LITERAL1)
131+
```
132+
This keywords file would cause the Arduino IDE to highlight `Test` as a DataType, and `doSomething` as a method / function.
133+
134+
#### keywords.txt format
135+
keywords.txt is formatted in four fields which are separated by a single true tab (not spaces):
136+
```
137+
KEYWORD KEYWORD_TOKENTYPE REFERENCE_LINK RSYNTAXTEXTAREA_TOKENTYPE
138+
```
139+
It is permitted to leave a field empty.
140+
##### `KEYWORD_TOKENTYPE`
141+
KEYWORD_TOKENTYPE | Use for | Theme property
142+
---|---|---
143+
`KEYWORD1` | datatypes | `editor.data_type.style`
144+
`KEYWORD2` | functions | `editor.function.style`
145+
`KEYWORD3` | structures | `editor.function.style`
146+
`LITERAL1` | constants | `editor.reserved_word_2.style`
147+
`LITERAL2` | ? | `editor.function.style`
148+
149+
##### `REFERENCE_LINK`
150+
This field specifies the [Arduino Language Reference](https://www.arduino.cc/reference/en) page to open via **Right Click > Find in Reference** or **Help > Find in Reference** when the cursor is on that keyword. Generally it does not make sense to define the `REFERENCE_LINK` field for 3rd party library keywords since they are not likely to be in the Arduino Language Reference.
151+
152+
##### `RSYNTAXTEXTAREA_TOKENTYPE`
153+
In Arduino IDE 1.6.5 and newer this field overrides `KEYWORD_TOKENTYPE`. In previous IDE versions the `RSYNTAXTEXTAREA_TOKENTYPE` field is ignored and `KEYWORD_TOKENTYPE` is used instead.
154+
155+
RSYNTAXTEXTAREA_TOKENTYPE | Theme property | KEYWORD_TOKENTYPE equivalent
156+
---|---|---
157+
`RESERVED_WORD` | `editor.reserved_word.style` | `KEYWORD3`
158+
`RESERVED_WORD_2` | `editor.reserved_word_2.style` | `LITERAL1`
159+
`DATA_TYPE` | `editor.data_type.style` | `KEYWORD1`
160+
`PREPROCESSOR` | `editor.preprocessor.style` | `KEYWORD3`
161+
`LITERAL_BOOLEAN` | `editor.literal_boolean.style` | `LITERAL1`
162+
163+
### Development flag file
164+
165+
Normally the Arduino IDE treats the contents of the library folder as read-only. This is to prevent users from accidentally modifying example sketches. During the library development process you may want to edit example sketches in place using the Arduino IDE. With Arduino IDE 1.6.6 and newer, the read-only behavior can be disabled by adding a file named .development to the root of the library folder. A [library.properties](#libraryproperties-file-format) file must also be present. The [Library Manager indexer](https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ) will not pick up releases that contain a .development file so be sure not to push this file to your remote repository.
166+
167+
### A complete example
168+
169+
A hypothetical library named "Servo" that adheres to the specification follows:
170+
171+
Servo/
172+
Servo/library.properties
173+
Servo/keywords.txt
174+
Servo/src/
175+
Servo/src/Servo.h
176+
Servo/src/Servo.cpp
177+
Servo/src/ServoTimers.h
178+
Servo/examples/
179+
Servo/examples/Sweep/Sweep.ino
180+
Servo/examples/Pot/Pot.ino
181+
Servo/extras/
182+
Servo/extras/Servo_Connectors.pdf
183+
184+
## Working with multiple architectures
185+
186+
In 1.5.x+, libraries placed in the user’s sketchbook folder (in the libraries/ subfolder) will be made available for all boards, which may include multiple different processor architectures. To provide architecture-specific code or optimizations, library authors can use the ARDUINO_ARCH_XXX preprocessor macro (#define), where XXX is the name of the architecture (as determined by the name of the folder containing it), e.g. ARDUINO_ARCH_AVR will be defined when compiling for AVR-based boards. For example,
187+
188+
#if defined(ARDUINO_ARCH_AVR)
189+
// AVR-specific code
190+
#elif defined(ARDUINO_ARCH_SAM)
191+
// SAM-specific code
192+
#else
193+
// generic, non-platform specific code
194+
#endif
195+
196+
Alternatively, if a library only works on certain architectures, you can provide an explicit error message (instead of allowing the compilation to fail in a difficult to understand way):
197+
198+
#if defined(ARDUINO_ARCH_AVR)
199+
// AVR-specific code
200+
#elif defined(ARDUINO_ARCH_SAM)
201+
// SAM-specific code
202+
#else
203+
#error “This library only supports boards with an AVR or SAM processor.”
204+
#endif
205+
206+
## Old library format (pre-1.5)
207+
208+
In order to support old libraries (from Arduino 1.0.x), Arduino 1.5.x+ will also compile libraries missing a library.properties metadata file. As a result, these libraries should behave as they did in Arduino 1.0.x, although they will be available for all boards, including non-AVR ones (which wouldn’t have been present in 1.0.x).
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
Starting from version 1.6.4 the Boards Manager of the Arduino IDE can be used to automatically install support for **3rd party hardware** by simply entering an URL in the **File > Preferences** dialog. The URL must be provided by the 3rd party hardware producer and should point to a JSON file that contains an index of the boards available to install and the location of the installation archives. Boards Manager also allows easy updates of installed Boards when new versions are released.
2+
3+
## Naming of the JSON index file
4+
5+
The IDE may use many different index files coming from different vendors, so each vendor should name his own index file in a way that won't conflict with others. The file must be named as follows:
6+
7+
`package_YOURNAME_PACKAGENAME_index.json`
8+
9+
The prefix `package_` and the postfix `_index.json` are **mandatory** (otherwise the index file is not recognised by the IDE) while the choice of `YOURNAME_PACKAGENAME` is left to the packager.
10+
We suggest using a domain name owned by the packager. For example:
11+
12+
`package_arduino.cc_index.json`
13+
14+
or
15+
16+
`package_example.com_avr_boards_index.json`
17+
18+
The index URL is periodically checked for updates so expect a constant flow of downloads (proportional to the number of active users).
19+
20+
## JSON Index file contents
21+
22+
The root of the JSON index is an array of `packages`:
23+
24+
```json
25+
{
26+
"packages": [
27+
PACKAGE_XXXX
28+
]
29+
}
30+
```
31+
32+
3rd party vendors should use a single `PACKAGE_XXXX` that is a dictionary map with the vendor's metadata, a list of `PLATFORMS` and a list of `TOOLS`. For example:
33+
34+
```json
35+
{
36+
"name": "arduino",
37+
"maintainer": "Arduino LLC",
38+
"websiteURL": "http://www.arduino.cc/",
39+
"email": "packages@arduino.cc",
40+
41+
"platforms": [
42+
PLATFORM_AVR,
43+
PLATFORM_ARM,
44+
PLATFORM_XXXXX,
45+
PLATFORM_YYYYY,
46+
],
47+
48+
"tools": [
49+
TOOLS_COMPILER_AVR,
50+
TOOLS_UPLOADER_AVR,
51+
TOOLS_COMPILER_ARM,
52+
TOOLS_XXXXXXX,
53+
TOOLS_YYYYYYY,
54+
],
55+
}
56+
```
57+
58+
The metadata fields are:
59+
60+
* `name`: the folder used for the installed cores. The [vendor folder](platform-specification.md#hardware-folders-structure) name of the installed package is determined by this field
61+
* `maintainer`: the extended name of the vendor that is displayed on the Boards Manager GUI
62+
* `websiteURL`: the URL to the vendor's website, appears on the Boards Manager as a "More info" link
63+
* `email`: the email of the vendor/maintainer
64+
65+
Now, before looking at `PLATFORMS`, let's explore first how `TOOLS` are made.
66+
67+
### Tools definitions
68+
69+
Each tool describes a binary distribution of a command line tool. A tool can be:
70+
71+
* a compiler toolchain
72+
* an uploader
73+
* a file preprocessor
74+
* a debugger
75+
* a program that performs a firmware upgrade
76+
77+
basically anything that can run on the user's host PC and do something useful.
78+
79+
For example, Arduino uses two command line tools for the AVR boards: avr-gcc (the compiler) and avrdude (the uploader).
80+
81+
Tools are mapped as JSON in this way:
82+
83+
```json
84+
{
85+
"name": "avr-gcc",
86+
"version": "4.8.1-arduino5",
87+
"systems": [
88+
{
89+
"host": "i386-apple-darwin11",
90+
"url": "http://downloads.arduino.cc/tools/avr-gcc-4.8.1-arduino5-i386-apple-darwin11.tar.bz2",
91+
"archiveFileName": "avr-gcc-4.8.1-arduino5-i386-apple-darwin11.tar.bz2",
92+
"size": "24437400",
93+
"checksum": "SHA-256:111b3ef00d737d069eb237a8933406cbb928e4698689e24663cffef07688a901"
94+
},
95+
{
96+
"host": "x86_64-linux-gnu",
97+
"url": "http://downloads.arduino.cc/tools/avr-gcc-4.8.1-arduino5-x86_64-pc-linux-gnu.tar.bz2",
98+
"archiveFileName": "avr-gcc-4.8.1-arduino5-x86_64-pc-linux-gnu.tar.bz2",
99+
"size": "27093036",
100+
"checksum": "SHA-256:9054fcc174397a419ba56c4ce1bfcbcad275a6a080cc144905acc9b0351ee9cc"
101+
},
102+
{
103+
"host": "i686-linux-gnu",
104+
"url": "http://downloads.arduino.cc/tools/avr-gcc-4.8.1-arduino5-i686-pc-linux-gnu.tar.bz2",
105+
"archiveFileName": "avr-gcc-4.8.1-arduino5-i686-pc-linux-gnu.tar.bz2",
106+
"size": "25882375",
107+
"checksum": "SHA-256:7648b7f549b37191da0b0be53bae791b652f82ac3cb4e7877f85075aaf32141f"
108+
},
109+
{
110+
"host": "i686-mingw32",
111+
"url": "http://downloads.arduino.cc/tools/avr-gcc-4.8.1-arduino5-i686-mingw32.zip",
112+
"archiveFileName": "avr-gcc-4.8.1-arduino5-i686-mingw32.zip",
113+
"size": "46044779",
114+
"checksum": "SHA-256:d4303226a7b41d3c445d901b5aa5903458def3fc7b7ff4ffef37cabeb37d424d"
115+
}
116+
]
117+
},
118+
```
119+
120+
The field `name` and `version` are respectively the name and version of the tool.
121+
Each tool is uniquely identified by the triple (`vendor`, `name`, `version`) and there can be many different versions of the same tool available at the same time, for example:
122+
123+
* (`arduino`, `avr-gcc`, `4.8.1-arduino2`)
124+
* (`arduino`, `avr-gcc`, `4.8.1-arduino3`)
125+
* (`arduino`, `avr-gcc`, `4.8.1-arduino5`)
126+
* (`arduino`, `avrdude`, `5.11`)
127+
* (`arduino`, `avrdude`, `6.0`)
128+
* (`arduino`, `avrdude`, `6.1`)
129+
* .....
130+
131+
Each tool version may come in different build flavours for different OS. Each flavour is listed under the `systems` array. In the example above `avr-gcc` comes with builds for:
132+
133+
* Linux 64-bit (`x86_64-linux-gnu`),
134+
* Linux 32-bit (`i686-linux-gnu`),
135+
* Windows (`i686-mingw32`),
136+
* Mac (`i386-apple-darwin11`)
137+
138+
The IDE will take care to install the right flavour based on the `host` value, or fail if a needed flavour is missing.<br>
139+
Note that the IDE does not use this information to select the toolchain during verify. If you want the IDE to use this specific version you should use the notation {runtime.tools.TOOLNAME-VERSION.path} in the platform.txt.
140+
141+
The other fields are:
142+
143+
* `url`: the download URL of the tool's archive
144+
* `archiveFileName`: the name of the file saved to disk after the download (some web servers don't provide the filename through the HTTP request)
145+
* `size`: the size of the archive in bytes
146+
* `checksum`: the checksum of the archive, used to check if the file has been corrupted. The format is `ALGORITHM:CHECKSUM`, currently `MD5`, `SHA-1`,`SHA-256` algorithm are supported, we recommend `SHA-256`. On *nix or MacOSX you may be able to use the command `shasum -a 256 filename` to generate SHA-256 checksums. There are many free options for Windows including md5deep, there are also online utilities for generating checksums.
147+
148+
##### How a tool's path is determined in platform.txt
149+
150+
When the IDE needs a tool it downloads the corresponding archive file and unpacks the content into
151+
a private folder that can be referenced from `platform.txt` using one of the following properties:
152+
153+
* `{runtime.tools.TOOLNAME-VERSION.path}`
154+
* `{runtime.tools.TOOLNAME.path}`
155+
156+
For example to obtain the avr-gcc 4.8.1 folder we can use `{runtime.tools.avr-gcc-4.8.1-arduino5.path}` or `{runtime.tools.avr-gcc.path}`.
157+
158+
### Platforms definitions
159+
160+
Finally, let's see how `PLATFORMS` are made.
161+
162+
```json
163+
{
164+
"name": "Arduino AVR Boards",
165+
"architecture": "avr",
166+
"version": "1.6.6",
167+
"category": "Arduino",
168+
"help": {
169+
"online": "http://www.arduino.cc/en/Reference/HomePage"
170+
},
171+
"url": "http://downloads.arduino.cc/cores/avr-1.6.6.tar.bz2",
172+
"archiveFileName": "avr-1.6.6.tar.bz2",
173+
"checksum": "SHA-256:08ad5db4978ebea22344edc5d77dce0923d8a644da7a14dc8072e883c76058d8",
174+
"size": "4876916",
175+
"boards": [
176+
{"name": "Arduino Yún"},
177+
{"name": "Arduino Uno"},
178+
{"name": "Arduino Diecimila"},
179+
{"name": "Arduino Nano"},
180+
{"name": "Arduino Mega"},
181+
{"name": "Arduino MegaADK"},
182+
{"name": "Arduino Leonardo"},
183+
],
184+
"toolsDependencies": [
185+
{ "packager": "arduino", "name": "avr-gcc", "version": "4.8.1-arduino5" },
186+
{ "packager": "arduino", "name": "avrdude", "version": "6.0.1-arduino5" }
187+
]
188+
},
189+
```
190+
191+
Each PLATFORM describes a core for a specific architecture. The fields needed are:
192+
193+
* `name`: the extended name of the platform that is displayed on the Boards Manager GUI
194+
* `architecture`: is the architecture of the plaftorm (avr, sam, etc...). It must match the architecture of the core as explained in the [Arduino platform specification](platform-specification.md#hardware-folders-structure)
195+
* `version`: the version of the platform.
196+
* `category`: this field is reserved, a 3rd party core must set it to `Contributed`
197+
* `help`/`online`: is a URL that is displayed on the Boards Manager as an "Online Help" link
198+
* `url`, `archiveFileName`, `size` and `checksum`: metadata of the core archive file. The meaning is the same as for the TOOLS
199+
* `boards`: the list of boards supported (note: just the names to display on the GUI! the real boards definitions are inside `boards.txt` inside the core archive file)
200+
* `toolsDependencies`: the tools needed by this core. Each tool is referenced by the triple (`packager`, `name`, `version`) as previously said. Note that you can reference tools available in other packages as well.
201+
202+
The `version` field is validated by both Arduino IDE and [JSemVer](https://github.com/zafarkhaja/jsemver). Here are the rules Arduino IDE follows for parsing versions ([source](https://github.com/arduino/Arduino/blob/master/arduino-core/src/cc/arduino/contributions/VersionHelper.java)):
203+
204+
* Split the version at the - character and continue with the first part.
205+
* If there are no dots (`.`), parse `version` as an integer and form a Version from that integer using `Version.forIntegers`
206+
* If there is one dot, split `version` into two, parse each part as an integer, and form a Version from those integers using `Version.forIntegers`
207+
* Otherwise, simply parse `version` into a Version using `Version.valueOf`
208+
209+
Note: if you miss a bracket in the JSON index, then add the URL to your Preferences, and open Boards Manager it can cause the Arduino IDE to no longer load until you have deleted the file from your arduino15 folder.
210+
211+
### Example JSON index file
212+
213+
```json
214+
{
215+
"packages": [
216+
{
217+
"name": "myboard",
218+
"maintainer": "Jane Developer",
219+
"websiteURL": "https://github.com/janedeveloper/myboard",
220+
"email": "jane@janedeveloper.org",
221+
"help": {
222+
"online": "http://janedeveloper.org/forum/myboard"
223+
},
224+
"platforms": [
225+
{
226+
"name": "My Board",
227+
"architecture": "avr",
228+
"version": "1.0.0",
229+
"category": "Contributed",
230+
"help": {
231+
"online": "http://janedeveloper.org/forum/myboard"
232+
},
233+
"url": "https://janedeveloper.github.io/myboard/myboard-1.0.0.zip",
234+
"archiveFileName": "myboard-1.0.0.zip",
235+
"checksum": "SHA-256:ec3ff8a1dc96d3ba6f432b9b837a35fd4174a34b3d2927de1d51010e8b94f9f1",
236+
"size": "15005",
237+
"boards": [
238+
{"name": "My Board"},
239+
{"name": "My Board Pro"}
240+
],
241+
"toolsDependencies": [
242+
{
243+
"packager": "arduino",
244+
"name": "avr-gcc",
245+
"version": "4.8.1-arduino5"
246+
},
247+
{
248+
"packager": "arduino",
249+
"name": "avrdude",
250+
"version": "6.0.1-arduino5"
251+
}
252+
]
253+
},
254+
{
255+
"name": "My Board",
256+
"architecture": "avr",
257+
"version": "1.0.1",
258+
"category": "Contributed",
259+
"help": {
260+
"online": "http://janedeveloper.org/forum/myboard"
261+
},
262+
"url": "https://janedeveloper.github.io/myboard/myboard-1.0.1.zip",
263+
"archiveFileName": "myboard-1.0.1.zip",
264+
"checksum": "SHA-256:9c86ee28a7ce9fe33e8b07ec643316131e0031b0d22e63bb398902a5fdadbca9",
265+
"size": "15125",
266+
"boards": [
267+
{"name": "My Board"},
268+
{"name": "My Board Pro"}
269+
],
270+
"toolsDependencies": [
271+
{
272+
"packager": "arduino",
273+
"name": "avr-gcc",
274+
"version": "4.8.1-arduino5"
275+
},
276+
{
277+
"packager": "arduino",
278+
"name": "avrdude",
279+
"version": "6.0.1-arduino5"
280+
}
281+
]
282+
}
283+
],
284+
"tools":[]
285+
}
286+
]
287+
}
288+
```
289+
In the example there is one `PACKAGE`, My Board. The package is compatible with the AVR architecture. There are two versions of the `PACKAGE`, 1.0.0 and 1.0.1. No `TOOLS` needed to be installed so that section was left blank.
290+
291+
Here is the Boards Manager entry created by the example:
292+
![Boards Manager screenshot](img/boards-manager-screenshot.png)
293+
294+
## Installation archive structure
295+
296+
The installation archives contain the Board support files. Supported formats are .zip, .tar.bz2, and .tar.gz.
297+
298+
The folder structure of the core archive is slightly different from the standard manually installed Arduino 1.5+ compatible hardware folder structure. You must remove the architecture folder(e.g., `avr` or `arm`), moving all the files and folders within the architecture folder up a level.
299+
300+
***
301+
302+
After adding Boards Manager support for your boards, please share the JSON index file URL on the [Unofficial list of 3rd party boards support urls](https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls).

‎docs/platform-specification.md

Lines changed: 589 additions & 0 deletions
Large diffs are not rendered by default.

‎docs/sketch-build-process.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
The process the Arduino environment uses to build a sketch. More useful information can be found in the [Arduino platform specification](platform-specification.md). Note that the following refers specifically to the build process for AVR targets. Other architectures will have a similar build process.
2+
3+
## Overview
4+
5+
A number of things have to happen for your Arduino code to get onto the Arduino board. First, the Arduino environment performs some minor pre-processing to turn your sketch into a C++ program. Next, dependencies of the sketch are located. It then gets passed to a compiler (avr-gcc), which turns the human readable code into machine readable instructions (or object files). Then your code gets combined with (linked against) the standard Arduino libraries that provide basic functions like `digitalWrite()` or `Serial.print()`. The result is a single Intel hex file, which contains the specific bytes that need to be written to the program memory of the chip on the Arduino board. This file is then uploaded to the board: transmitted over the USB or serial connection via the bootloader already on the chip or with external programming hardware.
6+
7+
## Pre-Processing
8+
9+
The Arduino environment performs a few transformations to your sketch before passing it to the avr-gcc compiler:
10+
- All .ino and .pde files in the sketch folder (shown in the IDE as tabs with no extension) are concatenated together, starting with the file that matches the folder name followed by the others in alphabetical order, and the .cpp extension is added to the filename.
11+
- If not already present, `#include <Arduino.h>` is added to the sketch. This header file (found in the core folder for the currently selected board) includes all the definitions needed for the standard Arduino core.
12+
- Prototypes are generated for all function definitions in .ino/.pde files that don't already have prototypes. In some rare cases prototype generation may fail for some functions. To work around this, you can provide your own prototypes for these functions.
13+
- `#line` directives are added to make warning or error messages reflect the original sketch layout.
14+
15+
No pre-processing is done to files in a sketch with any extension other than .ino or .pde. Additionally, .h files in the sketch are not automatically #included from the main sketch file. Further, if you want to call functions defined in a .c file from a .cpp file (like one generated from your sketch), you'll need to wrap its declarations in an 'extern "C" {}' block that is defined only inside of C++ files.
16+
17+
## Dependency Resolution
18+
19+
The sketch is scanned recursively for dependencies. There are predefined include search paths:
20+
21+
1. Core library folder (as defined by [`{build.core}`](platform-specification.md#boardstxt))
22+
1. Variant folder (as defined by [`{build.variant}`](platform-specification.md#boardstxt))
23+
1. Standard system directories (e.g., [`{runtime.tools.avr-gcc.path}/avr/include`](platform-specification.md#tools))
24+
1. Include search paths added to resolve prior dependencies
25+
26+
If the dependency is not present in any of those locations, the installed libraries are then searched (see the [**Location Priority** table](#location-priority) below for library locations). For information on the allowed library sub-folder structures see [the Arduino library specification](library-specification.md#source-code). `-I` options are generated for the path to each library dependency and appended to the [`includes` property](platform-specification.md#recipes-to-compile-source-code), to be used in [compilation recipes](platform-specification.md#recipes-to-compile-source-code) in platform.txt.
27+
28+
If multiple libraries contain a file that matches the `#include` directive, the priority is determined by applying the following rules, one by one in this order, until a rule determines a winner:
29+
30+
1. A library that is architecture compatible wins against a library that is not architecture compatible (see [**Architecture Matching**](#architecture-matching))
31+
1. A library that has better "folder name priority" wins (see [**Folder Name Priority**](#folder-name-priority))
32+
1. A library that is architecture optimized wins against a library that is not architecture optimized (see [**Architecture Matching**](#architecture-matching))
33+
1. A library that has a better "location priority" wins (see [**Location Priority**](#location-priority))
34+
1. A library that has a folder name with a better score using the "closest-match" algorithm wins
35+
1. A library that has a folder name that comes first in alphanumeric order wins
36+
37+
### Architecture Matching
38+
39+
A library is considered **compatible** with architecture `X` if the `architectures` field in [library.properties](library-specification.md#library-metadata):
40+
- explicitly contains the architecture `X`
41+
- contains the catch-all `*`
42+
- is not specified at all.
43+
44+
A library is considered **optimized** for architecture `X` only if the `architectures` field in library.properties explicitly contains the architecture `X`. This means that a library that is optimized for architecture `X` is also compatible with it.
45+
46+
Examples:
47+
48+
`architectures` field in `library.properties` | Compatible with `avr` | Optimized for `avr`
49+
---|---|---
50+
not specified | YES | NO
51+
`architectures=*` | YES | NO
52+
`architectures=avr` | YES | YES
53+
`architectures=*,avr` | YES | YES
54+
`architectures=*,esp8266` | YES | NO
55+
`architectures=avr,esp8266` | YES | YES
56+
`architectures=samd` | NO | NO
57+
58+
### Folder Name Priority
59+
60+
The "folder name priority" is determined as follows (in order of highest to lowest priority):
61+
62+
Rule | Example for `Servo.h`
63+
---|---
64+
The folder name matches the include 100% | `Servo`
65+
The folder name matches the include 100%, except with a `-master` suffix | `Servo-master`
66+
The folder name has a matching prefix | `ServoWhatever`
67+
The folder name has a matching suffix | `AwesomeServo`
68+
The folder name contains the include | `AnAwesomeServoForWhatever`
69+
70+
### Location Priority
71+
72+
The "location priority" is determined as follows (in order of highest to lowest priority):
73+
74+
1. The library is in the sketchbook (`{sketchbook path}/libraries`)
75+
1. The library is bundled with the board platform/core ([`{runtime.platform.path}/libraries`](platform-specification.md#global-predefined-properties))
76+
1. The library is bundled with the [referenced](platform-specification.md#referencing-another-core-variant-or-tool) board platform/core
77+
1. The library is bundled with the IDE ([`{runtime.ide.path}/libraries`](platform-specification.md#global-predefined-properties))
78+
79+
## Compilation
80+
81+
Sketches are compiled by avr-gcc and avr-g++ according to the variables in the boards.txt file of the selected board's [platform](platform-specification.md).
82+
83+
The sketch is built in a temporary directory in the system-wide temporary directory (e.g. /tmp on Linux).
84+
85+
Files taken as source files for the build process are .S, .c and .cpp files (including the .cpp file generated from the sketch's .ino and .pde files during the sketch pre-processing step).
86+
Source files of the target are compiled and output with .o extensions to this build directory, as are the main sketch files and any other source files in the sketch and any source files in any libraries which are #included in the sketch.
87+
88+
Before compiling a source file, an attempt is made to reuse the previously compiled .o file, which speeds up the build process. A special .d (dependency) file provides a list of all other files included by the source. The compile step is skipped if the .o and .d files exist and have timestamps newer than the source and all the dependent files. If the source or any dependent file has been modified, or any error occurs verifying the files, the compiler is run normally, writing a new .o & .d file. After a new board is selected from the Tools menu, all source files are rebuilt on the next compile.
89+
90+
These .o files are then linked together into a static library and the main sketch file is linked against this library. Only the parts of the library needed for your sketch are included in the final .hex file, reducing the size of most sketches.
91+
92+
The .hex file is the final output of the compilation which is then uploaded to the board.
93+
94+
If verbose output during compilation is checked in the Preferences dialog, the complete command line of each external command executed as part of the build process will be printed in the editor console.
95+
96+
## Uploading
97+
98+
Sketches are uploaded by avrdude. The upload process is also controlled by variables in the boards and main preferences files. See the [Arduino platform specification](platform-specification.md) page for details.
99+
100+
If verbose output during upload is checked in the Preferences dialog, debugging information will be output to the editor console, including avrdude command lines and verbose output.

‎mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,7 @@ nav:
103103
- monitor: rpc/monitor.md
104104
- settings: rpc/settings.md
105105
- debug: rpc/debug.md
106+
- sketch-build-process.md
107+
- library-specification.md
108+
- platform-specification.md
109+
- package_index.json specification: package_index_json-specification.md

0 commit comments

Comments
 (0)
Please sign in to comment.