espressif / esptool

Espressif SoC serial bootloader utility
https://docs.espressif.com/projects/esptool
GNU General Public License v2.0
5.6k stars 1.39k forks source link

Port doesn't exist (ESPTOOL-737) #918

Closed Massimiliano-solutiontech closed 1 year ago

Massimiliano-solutiontech commented 1 year ago

Operating System

Ubuntu 22.04 LTS

Esptool Version

v4.6.2

Python Version

Python 3.10

Full Esptool Command Line that Was Run

esptool flash_id

Esptool Output

esptool.py v4.6.2
Found 3 serial ports
Serial port /dev/ttyUSB1
/dev/ttyUSB1 failed to connect: Could not open /dev/ttyUSB1, the port doesn't exist
Serial port /dev/ttyUSB0
/dev/ttyUSB0 failed to connect: Could not open /dev/ttyUSB0, the port doesn't exist
Serial port /dev/ttyS4
/dev/ttyS4 failed to connect: Could not open /dev/ttyS4, the port doesn't exist

A fatal error occurred: Could not connect to an Espressif device on any of the 3 available serial ports.

What is the Expected Behaviour?

Connect and read the flash_id

More Information

The serial port is connected and the OS detects it (I'm using an ESP-Prog so two serials shows up)

❯ ll /sys/class/tty/ttyUSB*
lrwxrwxrwx 1 root root 0 set  7 19:19 /sys/class/tty/ttyUSB0 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0/ttyUSB0/tty/ttyUSB0/
lrwxrwxrwx 1 root root 0 set  7 19:19 /sys/class/tty/ttyUSB1 -> ../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.1/ttyUSB1/tty/ttyUSB1/
❯ sudo setserial -g /dev/ttyUSB*
/dev/ttyUSB0, UART: unknown, Port: 0x0000, IRQ: 0
/dev/ttyUSB1, UART: unknown, Port: 0x0000, IRQ: 0

Even that fails

❯ esptool --port /dev/ttyUSB1 flash_id
esptool.py v4.6.2
Serial port /dev/ttyUSB1

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

Other Steps to Reproduce

No response

Massimiliano-solutiontech commented 1 year ago

Solved, the user wasn't in the dialout group. Maybe the error could be more descriptive:

try:
    self._port = serial.serial_for_url(port)
except serial.serialutil.SerialException:
    raise FatalError(f"Could not open {port}, {sys.exc_info()[1]}")

instead of the actual

try:
    self._port = serial.serial_for_url(port)
except serial.serialutil.SerialException:
    raise FatalError(f"Could not open {port}, the port doesn't exist")
jakub-kocka commented 1 year ago

Thank you @Massimiliano-solutiontech for the good poin, we'll do that change.

IgorPierre commented 2 months ago

Hello, my problem was solved with: sudo chmod 777 /dev/ttyUSB0