Arduino IDE on Ubuntu – Can’t Open Device

arduino-ide

If you’ve just installed the Arduino IDE on Ubuntu, you’ve likely encountered an error similar to the one above the first time you tried to upload a sketch to your board. The error that I specifically get reads:

avrdude: ser_open(): can't open device "/dev/tty/ACMO": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device
Problem uploading to board. ...

I got this error today while doing a fresh install of Arduino 1.6.8 on Ubuntu 15.10, aka Wily Werewolf, but I’ve also run into it on previous Ubuntu versions as well. As I suspect this is not the last time I’ll encounter it, I figure I should write up the solution here instead of having to hunt it down again the next time it stumps me.

The first thing to do is to make sure that the Arduino board is actually visible to Ubuntu and that the Arduino IDE is properly configured for both the correct board and port.

Immediately after plugging the Arduino into the USB port of my laptop I ran dmesg:

dmesg output

And there it is. Besides verifying that the computer recognized the Arduino, the last line also tells me that it’s device node is /dev/ttyACM0.

Time to head back to the Arduino IDE to verify that the settings are correct for both the board type and the port (device node).

Arduino IDE tools menu

Everything looks good there, too. I’m using an Uno, and the port is correctly identified as /dev/ttyACM0. As I suspected from the beginning, the problem lies elsewhere, but I wanted to check the obvious first.

Since the error spit out by the IDE specifically said, “Permission denied,” the next logical thing to look at would be the file permissions of /dev/ttyACM0. I do this by running:

ls -l /dev/ttyACM0

The output is:

ls -l output

I can see that /dev/ttyACM0 is owned by the root user and the dialout group, both of which have read and write permissions. So everyone can’t read/write to ACM0. The only way an application that I launch can is if I am root or part of the dialout group. I’m not root, but am I part of the dialout group? To check, I run:

groups tpodlaski

groups output

Nope. I don’t belong to dialout. It seems that I have likely found the problem. To add myself to the dialout group, I run:

sudo usermod -a -G dialout tpodlaski

usermod output

The usermod command must be run as the root user or using sudo as illustrated here. Unless the permissions (and security) of your systems are really out of whack, the file that usermod changes, /dev/passwd, is not accessible to ordinary users.

Next comes an important step that I admit I forgot the first time. Log out of the desktop and then log back in. While Bash may show that you now belong to dialout, that information doesn’t propagate out to applications launched outside the command line without re-logging in.

Relaunching the IDE and attempting to upload a sketch to my Arduino Uno is now error free:

Arduino IDE successful upload message

So it was just a matter of not belonging to the correct group. Again, to add yourself to the dialout group, use the following command:

sudo usermod -a -G dialout [username]

Replacing [username] with your own username, of course.

As a side note, I should mention that there are other solutions out there that suggest crafting a custom udev rule for the Arduino that either assigns different file permissions or a different group to the device node with the board is plugged in. While it is likely a more elegant approach, it is definitely more complicated, and I have chosen the path of least resistance. If at some point in the future I learn that one approach is definitely better than the other, I will update this post.

1 comment

  1. thanks, that did the trick!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.