Esphome unable to flash USB permission denied?

I’ve turned the laptop off and restarted twice since running into this issue. Nothing seems to make any difference.

Specifically after usermod -a -G dialout your-username?

And you are sure both CLI and GUI is running as the same username? Do you have SELinux enabled?

If you’re fed up you could always do sudo chmod 666 /dev/ttyUSB0 then flash your device and restore the permissions back sudo chmod 660 /dev/ttyUSB0 (that change will not persist across reboot even if you don’t revert it).

Also check if another process is using the serial port. f.ex.

$ sudo lsof | grep ttyUSB
esphome   25576                  beikeland    3u      CHR              188,0      0t0        477 /dev/ttyUSB0

When I try to run that command I receive the following error

lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs Output information may be incomplete.

Are you sure diode is the user running esphome?

thats probably okay, for good measure try without the | grep ttyUSB and see that you do get a long list of all the open files on your system. we’re not interested in any fuse based files in any case. and as such no other output should indicate the file/serial port isn’t in use. (grep ttyUSB just filters out any lines not containing ttyUSB)

so that leaves us with the permissions, try chmod, if that works you probably aren’t running as the same user as you added to the dialout group after all; and also if it works you can move on to OTA flashing while you try to work out the permissions issue

I changed the permissions with chmod to 666 and I’m still getting the same error–I’m guessing it isn’t a permissions issue after all?

Presumably you also used sudo, and verified the permissions ls -l /dev/ttyUSB0?

Brings me back to, any chance you’re running with SELinux?

I had to look what SELinux was and I don’t think I am. Every command I tried in the CLI indicated it wasn’t installed so I’m thinking no.

then I’m all out of ideas, if everyone has read and write access to it, and its not in use then idk.

what happens if you try to open the (usb)serial port in a terminal like screen or minicom or whatever your favourite happens to be?

The only other thing I can suggest is try a different USB cable.

There’s actually no cable. The hardware plugs directly into the side of the laptop and I use jumper wires from there to the esp module.

Thanks everyone for trying to help out. I had planned on wiping the laptop and reinstalling a fresh copy of Ubuntu as it’s been 4 years and multiple OS upgrades throughout this time–maybe something ended up getting messed up during one of those?

I’ll report back if that makes any difference.

Have you done what the error message suggested?

Okay, as an update I found that my USB adapter that I was using failed since I last flashed a Sonoff device. I replaced it and I was able to flash very easily. I’m now running into issues which I will start a new thread for. Thanks for everyone’s attempt to help me with my issues!

The usb permission issue has been plaguing me for weeks. It happens on Ubuntu 18, Windows 10 and even Windows 7, which I installed on an old box just to check. From what I gather, Mac people are also getting the permission error trying to flash.

The same solutions are repeated all over the web - on Linux add yourself to dialout and open up permissions on the port with chmod. On Windows remove COM ports that the OS thinks are in use, and install CH34X drivers. The responses are always a mixture of, “Thanks, that was the problem!” and “Still doesn’t work for me.” I’m in the latter group.

Out of my collection of Arduinos and ESPs, the only controller I can still flash is an Arduino Uno R3 bought from Elegoo in 2017. What kind of problem could make Arduino and ESP stop being able to communicate over USB on multiple operating systems?

It is either ownership/permissions, a broken device, or not pressing the right buttons to trigger programming mode.

Or perhaps passing the flasher the wrong options.

I would never us windows for this stuff, didn’t even know esphome worked on windows. Stick to linux for this stuff, far easier to control and understand ownership and permissions.

I solved my USB-permission denied by updating the usb-driver (Silabs cp2102 to v10.1.8). Before that, I tried the Esphome-flasher on three different computers with win10/win7 without any success.

Using the esphome-flasher in windows is awesome.

Ahh well of course there is nothing to install on linux, any modernish distro will have the right kernel modules.

In case anyone is still looking to solve this - on Windows - open device manager, right click the port and check the port settings. Change the port bits per second to 115200; windows may have this set to a speed not tried by the ESPHome flasher e.g. 9600

1 Like