If you spend your day in a terminal—or you are running Linux on an ARM64 machine like a Snapdragon X Elite where the official Electron-based Arduino IDE 2 doesn't publish native builds—you don't need a bulky graphical editor to build, flash, and debug microcontrollers.
By pairing
arduino-cli (Arduino’s official standalone command-line compiler and board manager) with tio (a lightweight, auto-reconnecting serial terminal), you get a fast, scriptable microcontroller workflow that fits right into Neovim, tmux, or a Makefile.Here is how to install, configure, and use both tools on Arch Linux / Omarchy—including support for classic Arduino boards and the Raspberry Pi Pico (RP2040 / RP2350).
Step 1: Install
arduino-cli and tioBoth packages are available directly in the official Arch repositories:
bash
sudo pacman -S arduino-cli
yay -S --noconfirm tio
Use code with caution.
arduino-clihandles board cores, library installation, compiling sketches, and flashing firmware over USB.tiois a modern serial terminal built specifically for embedded development. Unlikescreenorminicom,tioautomatically reconnects the split second your microcontroller reboots after a flash—so you never lose early boot logs or have to restart your serial monitor.
Step 2: Grant USB Serial Port Permissions (
uucp Group)On Arch-based distributions, USB serial devices (
/dev/ttyACM0, /dev/ttyUSB0) belong to the uucp group (rather than dialout as on Debian/Ubuntu). Add your user to uucp so you can flash boards without sudo:bash
sudo usermod -aG uucp $USER
Use code with caution.
Log out and back in—or run
newgrp uucp in your current terminal—to activate the group membership immediately.Step 3: Initialize
arduino-cli and Install Board CoresGenerate the default configuration file and update the package index:
bash
arduino-cli config init
arduino-cli core update-index
Use code with caution.
For Classic Arduino Boards (Uno, Nano, Mega)
Install the standard AVR toolchain:
bash
arduino-cli core install arduino:avr
Use code with caution.
For Raspberry Pi Pico / Pico W (RP2040 & RP2350)
Add Earle Philhower’s
arduino-pico board manager URL, update the index, and install the core:bash
arduino-cli config add board_manager.additional_urls \
https://github.com
arduino-cli core update-index
arduino-cli core install rp2040:rp2040
Use code with caution.
(Tip: If you ever need to install third-party libraries, search and install them straight from the terminal with
arduino-cli lib search <name> and arduino-cli lib install "<Exact Library Name>".)Step 4: Detect Your Board, Compile, and Upload
Plug your microcontroller into USB and check which port and FQBN (Fully Qualified Board Name) it shows up under:
bash
arduino-cli board list
Use code with caution.
You will see output showing the serial port (such as
/dev/ttyACM0) and the board's FQBN (for example, arduino:avr:uno or rp2040:rp2040:rpipicow).Compile Your Sketch
bash
# For an Arduino Uno:
arduino-cli compile --fqbn arduino:avr:uno ./MySketch
# For a Raspberry Pi Pico W:
arduino-cli compile --fqbn rp2040:rp2040:rpipicow ./MyPicoProject
Use code with caution.
Flash Over USB
bash
# For an Arduino Uno:
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno ./MySketch
# For a Raspberry Pi Pico W:
arduino-cli upload -p /dev/ttyACM0 --fqbn rp2040:rp2040:rpipicow ./MyPicoProject
Use code with caution.
(Note for first-time Raspberry Pi Pico flashes: Hold down the BOOTSEL button while plugging in the USB cable the very first time so it mounts as a mass-storage bootloader. Once flashed with an
arduino-pico sketch, subsequent uploads reset and flash automatically over USB without touching the button.)Step 5: Monitor Serial Output with
tioOnce flashed, connect to the board’s serial console using
tio:bash
tio /dev/ttyACM0
Use code with caution.
(By default,
tio connects at 115200 baud—which matches most modern serial sketches. If your sketch uses 9600 baud, pass -b 9600: tio -b 9600 /dev/ttyACM0.)Essential
tio Keyboard ShortcutsAll
tio commands start with Ctrl + T:Ctrl + TthenQ— Quittiocleanly and release the serial port.Ctrl + TthenL— Toggle logging serial output straight to a text file.Ctrl + TthenC— Clear the terminal screen.Ctrl + Tthen?— Show all built-in shortcuts.
The Two-Pane Workflow
The cleanest way to work is keeping
tio /dev/ttyACM0 running continuously in one terminal pane while running arduino-cli compile and arduino-cli upload in a second pane (or from a Makefile). Every time you upload new firmware, tio briefly pauses while the USB port resets and immediately reconnects the moment your board boots—capturing your very first Serial.println() line every single time.Bonus: Drop-In
Makefile TemplateSave this
Makefile inside any sketch folder so building and flashing is just make upload:makefile
FQBN = rp2040:rp2040:rpipicow
PORT = /dev/ttyACM0
SKETCH = .
build:
arduino-cli compile --fqbn $(FQBN) $(SKETCH)
upload: build
arduino-cli upload -p $(PORT) --fqbn $(FQBN) $(SKETCH)
monitor:
tio $(PORT)
Use code with caution.
No comments:
Post a Comment