Fixing the Issue of Failing to Flash Devices Using Arduino on Ubuntu


I recently came across an issue where Arduino, installed under Ubuntu, refused to upload to my ESP32 device stating that ‘/dev/ttyUSB0 is not available or accessible’. This might sound absurd, and after digging into this issue a bit, I think I found the issue. This is a security feature implemented by modern Ubuntu. But, the usual suggestion of adding the current user to the dialout
user group didn’t work.
sudo usermod -a -G dialout $USER
This might be a new security feature but, I will give a few pointers on how to actually setup Arduino on your Ubuntu machine.
Installation
The recommended, and the method I also use, is to install the Arduino IDE through the Flatpak repo. You can install the Classic IDE or the modern IDE. If you do not have Flatpak setup, you can follow the simple guide given by the Flatpak developers. Then, you can open the Gnome Software Centre, search for ‘Arduino’, and install the IDE.
Uninstalling brltty
brltty
is a preinstalled program on Ubuntu that’s known to cause problems with serial devices. So uninstall it using the following command. Unless you heavily rely on accessibility inputs, this program should not be important to you.
sudo apt remove brltty
Changing User Access to Serial Port
This actual fix is to give permission to the current user to access /dev/ttyUSB0
or whatever device that you have connected to Arduino. You can see the serial port that Arduino is trying to connect to. Use the following command to give your user the access to this device. Note that every time you disconnect and reconnect the device, you have to run this command.
sudo chmod a+rw /dev/ttyUSB0
Here, /dev/ttyUSB0
is the device that I want to connect to, yours may vary, and you have to add this here instead of /dev/ttyUSB0
. sudo
provides admin privileges to the current command, chmod
asks the device to edit access, a
indicates the current user, +rw
indicates read + write access and finally, /dev/ttyUSB0
is the device.
Not sure which device to connect to? An easy way is to use the following command.
ls /dev/tty*
This lists all the serial devices currently connected to your computer. In most cases, the device might be called ttyUSB0
or any other variant of ttyUSB…
. First run this command without the device attached, then run again WITH the device attached and see which device appeared. This is the serial device. You can use that to upload your code.
Hope this helps, I will continue to update this post with any further information I find on this matter, including any permanent fixes as well.
Subscribe to my newsletter
Read articles from Asanka Akash Sovis directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Asanka Akash Sovis
Asanka Akash Sovis
I'm a dedicated software engineer with a passion for bringing hardware and software together to create robust and efficient solutions. I thrive on optimizing performance, managing power consumption, and ensuring the reliability of devices from concept to deployment. 🦊