Arduino

Arduino is Article description::an open source development platform. This article describes the process of configuring a Gentoo system to connect to an Arduino, the installation of a cross-development toolchain, and the installation of the Arduino IDE.

In addition to both official and clone Arduino boards based on Atmel AVR microprocessors, the environment can support other Atmel AVR microprocessors including, but not limited to: ATtiny13 microprocessors, nRF52 SoCs, and STM32 microprocessors.

Prepare the kernel for USB connection
Arduino boards are connected to a computer via USB. With this connection it is possible to send compiled binaries "sketches" to the Arduino's microprocessor and receive debug messages from the board during execution. Each model of board features a different USB interface chip; consult the board's documentation if unsure about the USB interface in use.

If in-system programming with an external programmer is preferred the Arduino IDE is not required for programming the device, however it may still be required to receive debugging output.

In order to support Arduino devices the appropriate kernel driver must be enabled; it may be built into the kernel or as a module.

Arduino NANO (CH340)
This series of boards has included a range of serial converter chips, however the most commonly used is the CH340.

Validate connectivity
After support for the device has been enabled, and the computer rebooted if necessary, connectivity to the board must be validated: connect the Arduino to an available USB port then check for messages in the kernel ring buffer:

For an Arduino NG:

For an Arduino MEGA:

Grant access for non-root users
Any non-root user that wishes to connect to the device should be added to the  group, as the device's file (e.g. ) is owned by that group.

To add Larry to the group run the following command:

Prepare the toolchain
As Atmel AVR microprocessors require different compiled output from the development platform (most often x86-64) a cross development toolchain must be installed.

Recommended: Install the toolchain using crossdev
This section provides condensed instructions for creating a cross-compiler, originally found in the Embedded Handbook. Consult the handbook for an introduction to crossdev and its operation.

Installing crossdev
Install :

Create a local repository
Before the local toolchain can be built a local repository called  must be created.

If the main ebuild repository (gentoo) is synchronized using Git, or another method where Manifest files do not include ebuild checksums, Portage must be informed of this to prevent "masked by: corruption" errors:

Instruct Portage and crossdev to use this repository:

Build and install the toolchain
Select an appropriate toolchain for the targeted architecture (the board in use); Most Arduino users will only want the AVR toolchain.

AVR (Arduino/Genuino/ATmicro/ATmega/etc.)
Build and install the AVR toolchain with this command:

ARM (STM32/GD32/etc.)
Build and install the ARM toolchain with this command:

Troubleshooting
If issues are encountered when crossdev is compiling the gcc stages, try:

Discouraged: Install non-Gentoo toolchain
The vendor-provided Atmel AVR toolchain is available for use, however it is untested.

An (old) article describing the use of the precompiled Debian toolchain is available here.

Official sources
An up-to-date version of the Arduino IDE is available in the official Gentoo repoisitory:

Arduino overlay

 * Benefit: Currently up to date. Packaged. Updates through portage possible. Pure command line (no IDE) possible.
 * Drawback: Unofficial distribution with unofficial packages.

To use the arduino-overlay, first instruct Portage to use the repository:

Then, sync Portage to enable the new repository:

Install the command line sketch build tool:

Then install the IDE:

Official download

 * Benefit: Always up to date.
 * Drawback: Not packaged for Gentoo. All or nothing. Not built from source. Requires manual updates.

Official tarball downloads (including beta and hourly versions).

Configuring the Arduino IDE
The Arduino IDE will create a default sketch directory on first launch, located at. This location can be changed within the Arduino IDE's preferences.

If targeting any platforms that aren't included in the default distribution (E.g. ATtiny processors, or ARM processors such as the STM32 or GD32) new Arduino platform implementations (also known as "cores") must be installed. Cores can then be associated with board definitions.

Some example cores:
 * ARM
 * STM32/GD32: stm32duino
 * Nordic Semiconductor
 * NRF51/52: sandeepmistry/arduino-nRF5
 * Atmel AVR
 * ATtiny Series
 * ATtiny13: MCUdude/MicroCore
 * ATtiny24/25/44/45/85: damellis/attiny
 * ATmega Series
 * ATmega64/128/640/1280/1281/2560/2561: MCUdude/MegaCore
 * ATmega16/32/164/324/644/1284/8535: MCUdude/MightyCore
 * XTensa (see also esp-open-sdk)
 * Espressif
 * ESP8266: esp8266/Arduino (see also esp8266.com)
 * ESP31B/32: espressif/arduino-esp32 (older ESP31B support)

Using Eclipse IDE
Within the Eclipse IDE there are two available plugins for Arduino development. Plugins can be installed via user-provided update sites: Add the required site to Eclipse via Menu/Help/Software-updates/Add-site.

Arduino Eclipse Extension
The Arduino Eclipse Extension is a free Eclipse IDE plugin for Arduino projects developed by Jantje. It depends on the installation of Arduino IDE.

Use the update site "http://www.baeyens.it/eclipse/update" for the installation of a plugin version which is compatible with Arduino 1.0.4 and Eclipse Helios and Indigo.

Use the update site "http://www.baeyens.it/eclipse/V2" for installation of a plugin version which is compatible with Arduino 1.5.x and Eclipse Juno.

AVR Eclipse Plugin
The AVR Eclipse Plugin is a free Eclipse IDE plugin used to develop for boards with AVR Atmel microprocessors. The plugin is not designed for Arduino boards, but can used with them and It is not necessary to install the Arduino IDE to use this plugin. More information can be found on the official wiki.

Use the update site "http://avr-eclipse.sourceforge.net/updatesite/" to install the plugin.

udev rules
A udev rule can be used to create symlinks such as when the board is connected. This is particularly useful in cases where more than one Arduino board will be connected simultaneously.

Arduino NG
Create the file and add following line to the file:

Arduino MEGA
Create the file and add following line to the file:

Deprecated items in avr-libc v1.8.0 and above (and Mega 2560)
If the following message is received, a known compatibility issue has been encountered.

To resolve this issue modify to the following:

Insufficient permissions for /dev/ttyACM0
Users attempting to access the serial port in question must be a part of the  group.

Add a user to the  group by issuing:

Missing arduino-builder
If the following error message is encountered, the arduino-builder binary is not in the location that the Arduino IDE expects.

Run the following command to symlink the existing arduino-builder binary:

External resources

 * Energia - For MSP430 support.
 * Outdated guide for arduino on Gentoo (arduino official hosted site).
 * Arduino eclipse extension main site.