Arduino

Arduino is Article description::an open source development platform. This document describes how to use the platform on Gentoo.

Note that in addition to official and clone Arduino products based on Atmel AVR microprocessors, the environment can also support other Atmel AVR microprocessors (such as ATtiny13), nRF52, STM32 microprocessors, etc.

Prepare the kernel for USB connection
The Arduino boards are connected to a computer via USB. With this connection it is possible to write binaries for the Arduino's microprocessor and get debug messages from the board during run mode. Different boards feature different USB interface chips. Consult the board's documentation regarding the USB interface used.

In case you prefer to use ICSP programming with an external adapter you don't need this for programming anymore, but you may still need it for debugging.

The following kernel support is required:

Arduino NANO (CH340)
These boards have used a range of serial converter chips, but mostly they use CH340.

Validate connectivity
After booting with the new kernel it is possible to test the board connectivity. First connect the board to one of USB ports and then check messages in kernel ring buffer:

For an Arduino NG:

For an Arduino MEGA:

Grant access
Every user privileged to connect to the board should be added to the  group. This group owns board's device file (for example ).

Prepare the toolchain
Because we need to compile code into binaries for a target platform (Atmel AVR microprocessors) different from the development platform (most often x86-64) we have to install a cross development toolchain.

Recommended: Install the toolchain using crossdev
If you haven't already, check out the section on Creating a cross-compiler from the Embedded Handbook. This will give you a good introduction to crossdev and how it works.

Installing crossdev
Install :

Creating local overlay
Before building the toolchain, you need to create a local overlay called.

If the main Portage tree is synchronized by using Git (or another method where Manifest files do not include ebuild checksums), you will need to inform Portage of this to prevent "masked by: corruption" errors.

Then instruct Portage and crossdev to use this overlay:

Build and install the toolchain
Now you are all set. The toolchain to build is specific to the architecture you are targeting with your development. Most Arduino users want the AVR toolchain only.

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

Troubleshooting
In the event you have problems with the gcc stages, try:

Discouraged: Install non-Gentoo toolchain
Using the original Atmel AVR toolchain seems to be possible but not tested.

Using the Debian precompiled toolchain is described over here.

Official sources
There is currently up to date of Arduino IDE in the official Gentoo repoisitory:

Many thanks to Virgil Dupras (hsoft).

Arduino overlay

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

In order to make use of the arduino-overlay:

Then you can check out the overlay:

Then 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
After first start of Arduino IDE (a link should be found in the application/development section of your application menu) it will create default sketch directory. This location can be changed in preferences (File/Preferences/Sketchbook location:).

If you are targeting any platforms that aren't included in the default distribution (such as ATtiny processors or ARM processors such as the STM32 or GD32) then you will need to install new Arduino platform implementations, which are known as cores. 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
After installing Eclipse IDE you can choose between two Eclipse plugins. Plugins can be installed via provided update sites. Simply add the given site via Menu/Help/Software-updates/Add-site.

Arduino Eclipse Extension
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
AVR Eclipse Plugin is a free Eclipse IDE plugin for developing boards with AVR Atmel microprocessors. It is not especially make for the Arduino boards, but it can used for that. It is not necessary to install Arduino IDE for using this plugin. More information can be found on the wiki site.

Use the update site "http://avr-eclipse.sourceforge.net/updatesite/" for installation of the plugin which is known to work with Eclipse Helios.

udev rule for Arduino NG
This rule can be used to make an symlink. This is especially useful in case of more than one Arduino boards.

For example create an file and add the line below:

udev rule for Arduino MEGA
This rule can be used to make an symlink, especially useful in case of more than one Arduino boards.

For example create an file and add the line below:

Problem with deprecated items in avr-libc v1.8.0 and above (and Mega 2560)
If you can see the messages below you have found this compatibility issue (Arduino forum).

To fix this manipulate your at the third line:

Insufficient permissions for /dev/ttyACM0
User accessing the serial port has to be a part of  in order to use it.

Add a user to the  group by issuing:

External resources

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