0% found this document useful (0 votes)
23 views9 pages

Arduino Setup Guide for Arch Linux

Arduino is an open-source electronics prototyping platform designed for artists, designers, and hobbyists to create interactive objects. The document provides installation instructions for the Arduino IDE and various boards, as well as configuration details for establishing a serial connection and programming the boards. Additionally, it outlines alternatives to the Arduino IDE for building and uploading sketches using different tools and methods.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views9 pages

Arduino Setup Guide for Arch Linux

Arduino is an open-source electronics prototyping platform designed for artists, designers, and hobbyists to create interactive objects. The document provides installation instructions for the Arduino IDE and various boards, as well as configuration details for establishing a serial connection and programming the boards. Additionally, it outlines alternatives to the Arduino IDE for building and uploading sketches using different tools and methods.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Arduino - ArchWiki [Link]

org/title/Arduino

Arduino
Arduino is an open-source electronics prototyping platform based Related articles
on flexible, easy-to-use hardware and software. It is intended for
artists, designers, hobbyists, and anyone interested in creating AVR
interactive objects or environments.

Once hooked up and configured the user may perform read/write tasks over the
established serial connection. Examples are interfacing over UART using a serial
monitoring program, or programming the microcontroller. Writing, compiling and
uploading your code is facilitated by using the official Arduino IDE, which is available in
the official repositories. Equally the user may use a compiler and programmer of choice to
program the microcontroller.

1 Installation
▪ Install either arduino-cli ([Link]
li) for the official CLI or arduino-ide ([Link]
arduino-ide) for the new 2.x release of the IDE.
▪ Enable user access to the device.
▪ You may need to load the cdc_acm module.

1.1 Arduino IDE 1.x


The following section only applies to the 1.x version of the IDE. However, it may be possible
to adapt some of this for the new IDE.

1.1.1 AVR Boards


To use AVR boards such as the Arduino Uno you can install arduino-avr-core (http
s://[Link]/packages/arduino-avr-core/)AUR optionally to use Arch
Linux upstream avr-gcc instead of the bundled older avr-core. If you still want to use the
older arduino-core you need to install it in the board manager ([Link]
earn/starting-guide/cores). You can always switch between the different cores in the Tools
> Board menu.

1.1.2 Pinoccio Scout


Pinoccio Scouts ([Link] can
also be programmed using the Arduino IDE. Instructions can be found here ([Link]
[Link]/web/20160611045134/[Link] Alternative you can install
arduino-pinoccio ([Link]

1 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

AUR.

1.1.3 Intel Galileo


To use the Intel Galileo boards with Arch Linux install the Arduino IDE and download the
Galileo tools package via Tools > Board > Boards Manager. To fix the installation you can
follow this github post ([Link]

1.2 Arduino IDE 1.x or 2.x


These steps should be valid for both versions of the IDE.

1.2.1 AVR Boards


AVR boards are automatically installed by the 2.x release of the IDE however on both the
1.x and 2.x releases the AVR boards can be managed from the boards manager.

1.2.2 SparkFun
To use SparkFun boards such as the Pro Micro you need to download their board
definitions. More information here ([Link]
v3-hookup-guide/installing-mac--linux) and here ([Link]
_Boards).

1.2.3 RedBear Duo


You might need to install perl-archive-zip ([Link]
me=perl-archive-zip) or you will get an error about missing crc32.

2 Configuration
Most Arduino boards have a USB port which can be used for establishing a serial
connection. This serial connection allows the user to program the board. The main
microcontroller of most Arduinos, however, does not have a USB interface built-in. Hence,
the board is usually equipped with a USB to serial chip in between the main
microcontroller and the USB port.

To achieve the serial connection over USB, most genuine Arduino boards are equipped with
another ATmega microcontroller (e.g. ATmega16U2) or an FTDI USB UART converter (e.g.
FT232RL). Both of these chips register themselves over USB as an ACM device, and as such,
Linux will use the cdc_acm module. The Arduino will then show up as /dev/ttyACMx .

Non-genuine Arduino boards cheap out on the interfacing chip. They are typically
equipped with a Chinese WCH CH340x or a counterfeit of the aforementioned models. The
CH340x exposes itself as a proprietary UART over USB device. Here the ch341 module is
used, making such Arduinos show up as /dev/ttyUSBx . This naming pattern may be
customized by altering udev rules.

2 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

Some boards may be equipped with a main microcontroller which does expose a native
USB interface by itself. Whether the board has a dedicated interface chip or not, genuine
boards will come out of the factory with a proper boot loader ([Link]
lt-in-examples/arduino-isp/ArduinoISP/) preinstalled. Such boot loaders automatically
establish a serial connection over USB once they are connected.

Note: Some boards, notably the Pro Mini, do not expose USB at all and must be
programmed with additional hardware.

Tip: It may be useful to monitor the kernel messages with dmesg as the board is being
plugged in. If a successful connection has been established, the assigned port can be read
therein.

2.1 Accessing serial


For the boards that expose a UART over USB, it is necessary to allow read/write access to
the serial port to users[1] ([Link] As explained in
Udev#Allowing regular users to use devices, create a file containing:

/etc/udev/rules.d/[Link]

SUBSYSTEMS=="usb-serial", TAG+="uaccess"

Reload the udev rules and replug the Arduino device. Before uploading to the Arduino, be
sure to set the correct serial port, board, and processor from the Tools menu in 1.x and the
Select board option (located at the top of the IDE) in 2.x.

Note: Remember to keep any serial monitoring programs closed during uploading code
in order to free the serial port for the programmer.

3 stty
Preparing:

# stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe
-echok -echoctl -echoke noflsh -ixon -crtscts

Sending commands through Terminal without new line after command

# echo -n "Hello World" > /dev/ttyACM0

Note: As autoreset on serial connection is activated by default on most boards, you need
to disable this feature if you want to communicate directly with your board with the last
command instead of a terminal emulator (arduino IDE, screen, picocom...). If you have a

3 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

Leonardo board, you are not concerned by this, because it does not autoreset. If you have
an Uno board, connect a 10 µF capacitor between the RESET and GND pins. If you have
another board, connect a 120 ohms resistor between the RESET and 5V pins. See https://
[Link]/Main/DisablingAutoResetOnSerialConnection for more
details.

Reading what your Arduino has to tell you:

$ cat /dev/ttyACM0

4 Arduino-Builder
You can also build Arduino sketches with the arduino-builder ([Link]
[Link]/packages/arduino-builder/)AUR command line tool. In order to use the
provided arduino-avr-core ([Link]
core/)AUR with upstream avr-gcc ([Link]
cc) and avrdude ([Link] you need to
create a small settings file:

[Link]

{
"fqbn": "archlinux-arduino:avr:uno",
"hardwareFolders": "/usr/share/arduino/hardware",
"toolsFolders": "/usr/bin"
}

Compile a sketch with:

$ arduino-builder -build-options-file [Link] [Link]

Or pass all options via command line:

$ arduino-builder -fqbn archlinux-arduino:avr:uno -hardware /usr/share/arduino/hardware -tools /usr/bin b


[Link]

5 Alternatives to the IDE

5.1 Arduino-CMake
Using Arduino-CMake-Toolchain ([Link]
chain) and CMake ([Link] you can
build Arduino firmware from the command line using multiple build systems. CMake lets
you generate the build system that fits your needs, using the tools you like. It can generate
any type of build system, from simple Makefiles, to complete projects for Eclipse, Visual
Studio, XCode, etc.

4 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

Requirements: cmake ([Link] arduino


([Link] avr-gcc ([Link]
[Link]/packages/?name=avr-gcc), avr-binutils ([Link]
es/?name=avr-binutils), avr-libc ([Link]
r-libc), avrdude ([Link]

5.2 Makefile
Instead of using the Arduino IDE it is possible to use another editor and a Makefile.

Set up a directory to program your Arduino and copy the Makefile into this directory. A
copy of the Makefile can be obtained from this GitHub template ([Link]
wartz07/arduino-makefile). You will have to modify this a little bit to reflect your settings.
The makefile should be pretty self explanatory. Here are some lines you may have to edit.

PORT = usually /dev/ttyUSBx, where x is the usb serial port your arduino is plugged into
TARGET = your sketch's name
ARDUINO = /usr/share/arduino/lib/targets/arduino

Depending on which library functions you call in your sketch, you may need to compile
parts of the library. To do that you need to edit your SRC and CXXSRC to include the
required libraries.

Now you should be able to make && make upload to your board to execute your sketch.

5.3 Arduino-mk
arduino-mk ([Link] is another alternative Makefile
approach. It allows users to have a local Makefile that includes [Link].

For Arduino 1.5, try the following local Makefile (because Arduino 1.5's library directory
structure is slightly different):

ARDUINO_DIR = /usr/share/arduino
ARDMK_DIR = /usr/share/arduino
AVR_TOOLS_DIR = /usr
AVRDUDE_CONF = /etc/[Link]
ARDUINO_CORE_PATH = /usr/share/arduino/hardware/archlinux-arduino/avr/cores/arduino
ARDUINO_PLATFORM_LIB_PATH = /usr/share/arduino/hardware/archlinux-arduino/avr/libraries
BOARDS_TXT = /usr/share/arduino/hardware/archlinux-arduino/avr/[Link]
ARDUINO_VAR_PATH = /usr/share/arduino/hardware/archlinux-arduino/avr/variants
BOOTLOADER_PARENT = /usr/share/arduino/hardware/archlinux-arduino/avr/bootloaders

BOARD_TAG = uno
ARDUINO_LIBS =

include /usr/share/arduino/[Link]

In some cases you could need to install avr-libc ([Link]


s/?name=avr-libc) and avrdude ([Link]

5 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

de).

5.4 Scons
Using scons ([Link] together with arscons ([Link]
arscons) it is very easy to use to compile and upload Arduino projects from the command
line. Scons is based on python and you will need python-pyserial to use the serial interface.
Install python-pyserial ([Link]
al), scons ([Link] and arduino (http
s://[Link]/groups/x86_64/arduino/).

That will get the dependencies you need too. Create project directory (eg. test), then create
an arduino project file in your new directory. Use the same name as the directory and add
.ino (eg. [Link]). Get the SConstruct ([Link]
Construct) script from arscons and put it in your directory. Have a peek in it and, if
necessary, edit it. It is a python script. Edit your project as you please, then run

$ scons # This will build the project


$ scons upload # This will upload the project to your Arduino

5.5 PlatformIO
PlatformIO ([Link] is a python tool
to build and upload sketches for multiple Hardware Platforms, at the moment of writing
these are Arduino/AVR based boards, TI MSP430 and TI TM4C12x Boards. In the near future
the author plans to add a library function that allows to search and include libraries
directly from GitHub.

5.5.1 Installation
Install the platformio-core ([Link]
o-core) or platformio-git ([Link]
it/)AUR package.

5.5.2 Usage
The following is based on the official PlatformIO quickstart guide ([Link]
[Link]/en/latest/core/[Link]), which shows how to create and upload an example
project.

Create a new directory for the platformio project and enter the directory. Then run the
following command to initialize the project for a specific board (here the
megaatmega2560):

$ pio project init --board megaatmega2560

6 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

This downloads the tool chain and dependencies, and creates [Link] :

[Link]

; PlatformIO Project Configuration File


[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino

Create and add code to [Link] in the src/ folder such as the example code in the
quickstart guide ([Link]

Then compile the code and upload it to the devices specified in [Link]:

$ pio run
$ pio run --target upload

5.6 Emacs
It is possible to configure Emacs as IDE.

Install the package emacs-arduino-mode-git ([Link]


s/emacs-arduino-mode-git/)AUR in order to enable the arduino-mode in emacs.

Add to the init script:

~/.emacs

;; arduino-mode
(require 'cl)
(autoload 'arduino-mode "arduino-mode" "Arduino editing mode." t)
(add-to-list 'auto-mode-alist '("\.ino$" . arduino-mode))

You can compile and upload the sketches using Arduino-mk (see above) with
M-x compile make upload .

Main resource: here ([Link]

6 Troubleshooting

6.1 Consistent naming of Arduino devices


If you have more than one Arduino you may have noticed that they names
/dev/ttyUSB[0-9] are assigned in the order of connection. In the IDE this is not so much
of a problem, but when you have programmed your own software to communicate with an
Arduino project in the background this can be annoying. Use the following udev rules to
assign static symlinks to your Arduino's:

7 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

/etc/udev/rules.d/[Link]

SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="s


ensors/ftdi_%s{serial}"

Your Arduino's will be available under names like /dev/sensors/ftdi_A700dzaF . If you


want you can also assign more meaningful names to several devices like this:

/etc/udev/rules.d/[Link]

SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{seria


l}=="A700dzaF", SYMLINK+="arduino/nano"

which will create a symlink in /dev/arduino/nano to the device with the specified
serialnumber. You do need to unplug and replug your Arduino for this to take effect or run

# udevadm trigger

Common idVendor / idProduct pairs can be found in


/usr/share/arduino/hardware/archlinux-arduino/avr/[Link] in the
distribution package. Note that some of them (notably FTDI ones) are not unique to the
Arduino platform. Using serial attribute is a good way to distinguish between various
devices.

6.2 Error opening serial port


You may see the serial port initially when the IDE starts, but the TX/RX leds do nothing
when uploading. You may have previously changed the baudrate in the serial monitor to
something it does not like. Edit ~/.arduino/[Link] so that
serial.debug_rate is a different speed, like 115200.

6.3 Working with Uno/Mega2560


The Arduino Uno and Mega2560 have an onboard USB interface (an Atmel 8U2) that
accepts serial data, so they are accessed through /dev/ttyACM0 created by the cdc-acm
kernel module when it is plugged in.

The 8U2 firmware may need an update to ease serial communications. See [2] ([Link]
[Link]/t/easy-to-brick-arduino-uno-on-linux/47039) for more details and reply #11
for a fix. The original arduino bbs, where you can find an image explaining how to get your
Uno into DFU, is now in a read-only state. If you do not have an account to view the image,
see [3] ([Link]

You can perform a general function test of the Uno by putting it in loopback mode and
typing characters into the arduino serial monitor at 115200 baud. It should echo the
characters back to you. To put it in loopback, short pins 0 -> 1 on the digital side and either
hold the reset button or short the GND -> RESET pins while you type.

8 of 9 6/3/25, 1:53 PM
Arduino - ArchWiki [Link]

6.4 Not recognizing USB port with Mega2560 cheap Chinese clones
Try installing its driver: i2c-ch341-dkms ([Link]
c-ch341-dkms/)AUR.

6.5 Fails to upload: programmer is not responding


Changing processor setting from ATmega328P to ATmega328P (Old Bootloader) (See
Tools->Processor in Arduino IDE) may help with upload failures.

6.6 Serial port conflict with brltty


If the serial port for the arduino is not visible at /dev/ttyUSB* , and the journal contains
the following when the device is connected:

usb 3-1: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1
ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0

Then you may need to uninstall the brltty ([Link]


=brltty) package. See [4] ([Link]
ch341-uart-disconnected-from-ttyusb0/87208) for more details.

6.7 Failure to upload with Nano RP2040 Connect


If your upload fails with:

Failed uploading: uploading error: exit status 1

you have skipped #Accessing serial: follow its directions to allow read/write access to the
serial port to users.

7 See also
▪ Official website ([Link]
▪ IDE v2 Getting Started Guide ([Link]
ing-started-ide-v2)
▪ [Link]
arduinoftdi-device/

Retrieved from "[Link]

9 of 9 6/3/25, 1:53 PM

You might also like