ESP32 - "Upload port doesn't exist"

I have a problem flashing the ESP32.
Tested with two boards:
ESP32 D1 Mini NodeMCU WiFi Modul + Bluetooth
(https://www.az-delivery.de/products/esp32-d1-mini
ESP32 NodeMCU Module WLAN WiFi
(ESP32 NodeMCU Module WLAN WiFi Dev Kit C Development Board mit CP2102 )

Both boards have the ESP32-WROOM 32 Soc and the CP210X UART-bridge.
The USB-Port is recognized as USB1:


$ pio device list
/dev/ttyS0
----------
Hardware ID: PNP0501
Description: ttyS0

/dev/ttyUSB1
------------
Hardware ID: USB VID:PID=10C4:EA60 SER=0001 LOCATION=3-13.3
Description: CP2102 USB to UART Bridge Controller - CP2102 USB to UART Bridge Controller

/dev/ttyUSB0
------------
Hardware ID: USB VID:PID=0403:6001 SER=A7004VtB LOCATION=3-12
Description: FT232R USB UART - FT232R USB UART

My platformio.ini looks like this:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

When I try to flash the boards the result is: Could not open /dev/ttyUSB1

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/ttyUSB1
Uploading .pio/build/esp32dev/firmware.bin
esptool.py v4.5
Serial port /dev/ttyUSB1

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

The user is in the dialout group.
I tried different cables and different USB ports, no change.

Strange is, that with the Arduino IDE the result is the same.
What is the reason and how can I solve it?

OK, seems to be a matter of the driver or udev-system.

I tried to flash under windows: → works
I tried to flash under Ubuntu/VM-ware with native driver: → works
Flashing under Ubuntu with Ubuntu kernel driver: → DOES NOT WORK
dmesg says:

[ 3597.866078] usb 3-13.2: new full-speed USB device number 16 using xhci_hcd
[ 3598.001995] usb 3-13.2: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
[ 3598.001998] usb 3-13.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3598.001999] usb 3-13.2: Product: CP2104 USB to UART Bridge Controller
[ 3598.002000] usb 3-13.2: Manufacturer: Silicon Labs
[ 3598.002001] usb 3-13.2: SerialNumber: 02FUQVGU
[ 3598.015115] cp210x 3-13.2:1.0: cp210x converter detected
[ 3598.015822] cp210x 3-13.2:1.0: failed to get vendor val 0x370c size 13: -121
[ 3598.015825] cp210x 3-13.2:1.0: GPIO initialisation failed: -121
[ 3598.015934] usb 3-13.2: cp210x converter now attached to ttyUSB1
lsusb:
Bus 003 Device 016: ID 10c4:ea60 Silicon Labs CP210x UART Bridge

driver is loaded:

ls -al /lib/modules/"$(uname -r)"/kernel/drivers/usb/serial/cp210x.ko
-rw-r--r-- 1 root root 88705 Nov  2 18:02 /lib/modules/6.2.0-37-generic/kernel/drivers/usb/serial/cp210x.ko

Can anybody help me in this issue or has simular experience?
I work with linux all the time and don´t want to fireup windows everytime I change my code.
Regards

I think that already proves that the adapter itself is working but that there’s a problem with the cp210x driver instead. Try filing an issue there or trying different Linux live-distributation to see if others do not have this problem.

Hallo Max,

that is my conclusion too! I will try to compile the driver myself and than we will see.
Regards

I searched the web for “cp210x failed to get vendor val” and found a lot of problems with the cp210x UART-bridge chip under linux. Could be a wrong driver but also a buggy firmware on that chip. Some posts are even 14 years old, so the error is not new.
Who knows which chips and old firmware the chinese recycle on their ESP boards nowadays
But anyway: The windows driver seems to be more robust against the error or the developer of the driver smarter. I can use the ESP-Boards under windows…
I close the issue now while it is not PlatformIO related.
Regards

OK, after nearly one day of trying, errors and reading thousends of posts I figured it out:
The reason was another daemon process which occupied the port. Checking with

$ sudo lsof /dev/ttyUSB0
lsof: WARNING: can't stat() fuse.portal file system /run/user/1000/doc
      Output information may be incomplete.
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
gpsd      1024 gpsd    9u   CHR  188,0      0t0  779 /dev/ttyUSB0

one can see that the port is used by a daemon process. The process was a former setup gpsd for a GPS receiver with the same UART-bridge. To deactivate this daemon you have to stop and mask the corresponding services and sockets.

$ sudo systemctl status gpsd
$ sudo systemctl status gpsd.socket
$ sudo systemctl stop gpsd.service

and to make it permanent:

$ sudo systemctl mask gpsd.service 
Created symlink /etc/systemd/system/gpsd.service → /dev/null.

After reboot the services should be gone and the captured USB-Port should be freed.
Hope this helps others with the same problem either.
Regards
Stefan

1 Like