PlatformIO in VS Code running on Linux Debian - access to /dev/ttyUSB0 - port doesn't exist

I can build a project in PlatformIO but when it comes to the upload to my ESP32 device the Terminal progresses but then faults:

A fatal error occurred: Could not open /dev/ttyUSB0, the port doesn’t exist

I check the Devices tab - /dev/ttyUSB0 is shown in the list with all the correct details CP2102 USB to Serial UART e.t.c.

I’ve updated the UDEV/rules.d/ details for PlatformIO as instructed when I added the extension to VS Code - CP2102 USB to Serial UART is top of the list.

I’ve added myself to the dialout user group - sudo adduser username dialout

And then changed the ownership of the /dev/ttyUSB0 entry - sudo chown username /dev/ttyUSB0

I can see that this file belongs to me and is accessible by the dialout group.

I tried the same project build and upload on VS Code and PlatformIO extension running on Mac OS X and it works perfectly - the project is built and uploaded to the ESP32.

What is going wrong with Linux Debian? I know it must be some kind of permissions issue with the VS Code & PlatformIO but I’m struggling to think what.

Did you do logout + login or a reboot after that?

Hello maxgerhardt - Thanks for the reply - yes, several times, but to no avail.

Please open a CLI and execute pio run -t upload 2>&1 | tee upload.log

Post the contents of the upload.log file.

Here it is:

processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.3.2) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20009.0 (2.0.9) 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/esp32dev/src/main.cpp.o
Building .pio/build/esp32dev/bootloader.bin
Generating partitions .pio/build/esp32dev/partitions.bin
esptool.py v4.5.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Compiling .pio/build/esp32dev/FrameworkArduino/Esp.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/FirmwareMSC.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/FunctionalInterrupt.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/HWCDC.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/IPv6Address.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Print.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/StreamString.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/USB.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/USBCDC.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/USBMSC.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/WString.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/base64.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/cbuf.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-adc.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-bt.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-cpu.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-dac.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-gpio.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-i2c-slave.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-i2c.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-ledc.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-matrix.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-misc.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-psram.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-rgb-led.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-rmt.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-spi.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-time.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-timer.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-tinyusb.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-touch.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-uart.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/firmware_msc_fat.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/libb64/cdecode.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/libb64/cencode.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/main.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/stdlib_noniso.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/wiring_pulse.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/wiring_shift.c.o
Archiving .pio/build/esp32dev/libFrameworkArduino.a
Indexing .pio/build/esp32dev/libFrameworkArduino.a
Linking .pio/build/esp32dev/firmware.elf
Retrieving maximum program size .pio/build/esp32dev/firmware.elf
Checking size .pio/build/esp32dev/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.7% (used 22076 bytes from 327680 bytes)
Flash: [==        ]  17.6% (used 230473 bytes from 1310720 bytes)
Building .pio/build/esp32dev/firmware.bin
esptool.py v4.5.1
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pio/build/esp32dev/firmware.bin
esptool.py v4.5.1
Serial port /dev/ttyUSB0

A fatal error occurred: Could not open /dev/ttyUSB0, the port doesn't exist
*** [upload] Error 2
========================= [FAILED] Took 11.71 seconds =========================

That is extrodinarily strange.

Just to make sure: You’re running Debian natively on your computer, not through a virutal machine or Windows Subsystem for Linux (WSL)?

What is the output of

sudo dmesg | tail -n 50

?

I’m running it on a Lenovo T450 laptop which I recently switched to running Linuxfx - a port of Debian Ubuntu as it was getting painfully slow running with Win10.

Here’s the output:

10499.744112] sd 0:0:0:0: [sda] Starting disk
[10499.977180] usb 3-3: Disable of device-initiated U1 failed.
[10499.980840] usb 3-3: Disable of device-initiated U2 failed.
[10499.985470] e1000e 0000:00:19.0 enp0s25: Failed to disable ULP
[10500.045657] usb 2-7: reset full-speed USB device number 4 using xhci_hcd
[10500.055931] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[10500.057871] ata1.00: ACPI cmd f5/00:00:00:00:00:a0(SECURITY FREEZE LOCK) filtered out
[10500.060522] ata1.00: ACPI cmd f5/00:00:00:00:00:a0(SECURITY FREEZE LOCK) filtered out
[10500.061339] ata1.00: configured for UDMA/133
[10500.321756] usb 2-8: reset high-speed USB device number 5 using xhci_hcd
[10500.447132] psmouse serio1: synaptics: queried max coordinates: x [..5676], y [..4758]
[10500.478103] psmouse serio1: synaptics: queried min coordinates: x [1266..], y [1096..]
[10500.598037] usb 3-3: reset SuperSpeed USB device number 2 using xhci_hcd
[10500.981793] usb 2-3: reset high-speed USB device number 6 using xhci_hcd
[10501.201185] usb 3-3.2: Disable of device-initiated U1 failed.
[10501.204935] usb 3-3.2: Disable of device-initiated U2 failed.
[10501.285785] xhci_hcd 0000:00:14.0: WARN: endpoint 0x82 has streams on device reset, freeing streams.
[10501.285869] xhci_hcd 0000:00:14.0: WARN: endpoint 0x83 has streams on device reset, freeing streams.
[10501.285959] xhci_hcd 0000:00:14.0: WARN: endpoint 0x04 has streams on device reset, freeing streams.
[10501.286178] usb 3-3.2: reset SuperSpeed USB device number 3 using xhci_hcd
[10501.465777] usb 2-3.4: reset high-speed USB device number 9 using xhci_hcd
[10501.669799] usb 2-3.3: reset full-speed USB device number 8 using xhci_hcd
[10501.873768] usb 2-3.1: reset full-speed USB device number 7 using xhci_hcd
[10502.065767] usb 2-3.4.1: reset high-speed USB device number 10 using xhci_hcd
[10502.245791] usb 2-3.4.3: reset full-speed USB device number 11 using xhci_hcd
[10502.347557] OOM killer enabled.
[10502.347560] Restarting tasks ... done.
[10502.364858] thermal thermal_zone2: failed to read out thermal zone (-61)
[10502.378293] input: Microsoft X-Box One S pad as /devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.4/2-3.4.3/2-3
.4.3:1.0/input/input24
[10502.396580] PM: suspend exit
[10502.414773] Bluetooth: hci0: Legacy ROM 2.5 revision 1.0 build 3 week 17 2014
[10502.414839] Bluetooth: hci0: Intel Bluetooth firmware file: intel/ibt-hw-37.8.10-fw-1.10.3.11.e.bseq
[10502.605139] e1000e 0000:00:19.0 enp0s25: NIC Link is Down
[10502.729750] Bluetooth: hci0: unexpected event for opcode 0xfc2f
[10502.747787] Bluetooth: hci0: Intel BT fw patch 0x32 completed & activated
[10502.813122] iwlwifi 0000:03:00.0: Applying debug destination EXTERNAL_DRAM
[10502.891326] iwlwifi 0000:03:00.0: Applying debug destination EXTERNAL_DRAM
[10502.892716] iwlwifi 0000:03:00.0: FW already configured (0) - re-configuring
[10502.903037] ACPI: \: failed to evaluate _DSM (0x1001)
[10502.903042] ACPI: \: failed to evaluate _DSM (0x1001)
[10502.903044] ACPI: \: failed to evaluate _DSM (0x1001)
[10502.903045] ACPI: \: failed to evaluate _DSM (0x1001)
[10506.480201] wlp3s0: authenticate with 14:49:bc:13:5c:10
[10506.486037] wlp3s0: send auth to 14:49:bc:13:5c:10 (try 1/3)
[10506.489575] wlp3s0: authenticated
[10506.493435] wlp3s0: associate with 14:49:bc:13:5c:10 (try 1/3)
[10506.560470] wlp3s0: RX AssocResp from 14:49:bc:13:5c:10 (capab=0x131 status=0 aid=8)
[10506.562407] wlp3s0: associated
[10506.628048] wlp3s0: Limiting TX power to 20 (20 - 0) dBm as advertised by 14:49:bc:13:5c:10
[10506.722094] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready

Okay at least the last 50 log lines don’t indicate anything wrong.

What’s the output of the commands

ls -l /dev/ttyUSB*
groups

Here’s the output:

crw-rw-rw- 1 root dialout 188, 0 Sep  2 10:32 /dev/ttyUSB0
jamesm adm dialout cdrom sudo dip plugdev lpadmin sambashare

Can you live-boot from a regular Ubuntu 22 Desktop image (e.g. boot from USB drive) and install PlatformIO there and retest? This is very fishy.

Thanks for the continued support. I tried my Arduino IDE this morning and it found the ttyUSB0 port without issue and I was able to upload to an Arduino board.

I’ve run the Ubuntu 22 Live disk on my laptop and tried to install PlatformIO as an extension in Visual Studio code. I have a problem getting the extension to install as it keeps asking for Python3.6+ even though I have installed Python3.11 on the system. I cannot test the Upload function until I get past this hurdle. I’ll keep working at it as I had the same problem when installing Python3 on my Linuxfx system, but eventually it worked.

i dont know if it will work but sometimes it does for me:

sudo chmod 777 /dev/ttyUSB0

jimbo1up, I noticed that you did not directly answer maxgerhardt’s question. He wanted to know if you are running Linux under an emulator, such as Virtual Box. In the specific case of Virtual Box you will need to enable the use of the USB port in the emulator. In the lower right corner you would see an icon for the USB port. Right Click on that and then Right Click on the USB host on your individual machine. You can test for whether this solves your issue with “ls -l /dev/ttyUSB0” both before, and then again just after the enabling of the USB port in the emulator. You should see that initially the node file does not exist, then later it does exist.

Hello normvp. I’m running it on the bare metal Lenovo T450 laptop, no VM is involved. I was pleasantly surprised by just how good the install was - all the special function keys Volume, Brightness, Media Control etc. worked the first time. Linux has come a long way over the years.

Thanks hannescam. I tried this but it made no difference. I’m trying to get things going with Live Ubuntu 20.04 as maxgerhardt suggested, but coming up against the issue of PlatformIO not recognising that Python3 is on the system. I’ve tried installing python3-venv as suggested by other people who have come up against this. For some reason, Ubuntu 20.04 just complains that it cannot find this and I get no further.