Adafruit ItsyBitsy 32u4 issues on Archlinux fixed

A couple months back I started working on an “Okay to Wake” clock for my son.

Yeah, yeah, honey – I know I could just buy one on [insert website named after rainforest], but that’s no fun.

I decided on an ItsyBitsy 32u4 for a few reasons; inexpensive, more powerful than a Pro Micro, lots of PWM pins, ‘native’ USB, etc. It’s also really tiny.

Anyway, it should just be plug-and-play on any Linux machine, but instead… it’s had issues with all my computers, covering Windows 10, Fedora, and Archlinux. Maybe it’s just a finicky device? I don’t know, but I figured out how to get it working with my Archlinux install after way too long spent on troubleshooting.

The main issue I had was due to permissions on the /dev/ttyACM0 device. In Arch, the default ownership is root:uucp with wr-wr---- , so you would think ‘add your user to uucp and off we go’… but no. After power-cycling into the bootloader mode, for only a short second, the device is set to root:root and wr-------w , so it doesn’t matter which groups my user is in, I can’t access it. That results in this nice error when I try to upload to the board:

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/brandon/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/home/brandon/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avr109
         Overriding Baud Rate          : 57600
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

avrdude done.  Thank you.

I chased a theory for way too long on this: the bootloader enumerates with a difference USB productID , so I figured my system needed a udev rule added to set the permissions correctly for the bootloader device. A couple hours of learning udev rules and I realized that the device, no matter what I did, would always be root:root for a short time after. I finally did get a udev rule to set the user and group, and the permissions to rw-rw-rw- , but it wasn’t instant so the device was still locked off to avrdude .

The easy way

Eventually, I ended up in the #arduino channel on freenode asking, when I realized that I just need the IDE to wait a moment before trying to upload the code using avrdude . I was looking around in the Arduino IDE code for where it calls avrdude, when a moment of clarity came:

replace the avrdude executable with a script that waits a second, then calls avrdude.

Yup, that’s what this whole post leads up to. I hope it’s helpful to someone. Here are the (very simple) two steps to fix this issue if you hit the same problem:

First, move the avrdude binary in the Arduino folder, the path will change with new IDE releases:

$ cd ~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/
$ mv avrdude avrdude-bin

Then, create this script named avrdude instead:

#!/bin/bash

sleep 1
$0-bin "${@:1}"

Now the Arduino IDE will have to wait one second after noticing that /dev/ttyACM0 exists before trying to upload your code, and hopefully the device has settled by then. You can try increasing the sleep duration if you still have issues, but it really shouldn’t require longer than 2 seconds – you likely have a different problem if 2 doesn’t work.