unable to flash esp32. the port doesn't exist

I've been trying to flash esp-wroom-32 for a long time, but I can't seem to get it. idf.py throws this error:

Serial port /dev/ttyUSB0
A fatal error occurred: Could not open /dev/ttyUSB0, the port doesn't exist
CMake Error at run_serial_tool.cmake:55 (message):
  /home/matvey/.espressif/python_env/idf5.1_py3.9_env/bin/python;;/home/matvey/esp/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32
  failed
FAILED: CMakeFiles/flash /home/matvey/esp/esp-idf/examples/get-started/hello_world/build/CMakeFiles/flash
cd /home/matvey/esp/esp-idf/components/esptool_py && /usr/bin/cmake -D IDF_PATH=/home/matvey/esp/esp-idf -D "SERIAL_TOOL=/home/matvey/.espressif/python_env /idf5.1_py3.9_env/bin/python;;/home/matvey/esp/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32" -D "SERIAL_TOOL_ARGS=--before=default_reset; --after=hard_reset;write_flash;@flash_args" -D WORKING_DIRECTORY=/home/matvey/esp/esp-idf/examples/get-started/hello_world/build -P /home/matvey/esp/esp-idf/components/ esptool_py/run_serial_tool.cmake
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /home/matvey/esp/esp-idf/examples/get-started/hello_world/build/log/idf_py_stderr_output_27303 and /home/matvey/esp/esp-idf/ examples/get-started/hello_world/build/log/idf_py_stdout_output_27303`

I have no idea what could be the problem, I changed the udev settings, but maybe it did not work for me.

Upvotes: 19

Views: 54760

Answers (5)

Chr_arj
Chr_arj

Reputation: 1

I was getting the same error while setting up esp-idf on Ubunto, i tried changing permission and all but it did not work.

this command was giving error $ idf.py -p ttyACM0 flash

this one worked $ idf.py -p /dev/ttyACM0 flash

Steps to verify if esp board is detected

type, ls /dev

disconnect esp and again give same command, find if the port is detected or not.

it will be ttyUSB0,1,2 orttyACM0,1,2

for me it was ttyACM0.

in windows it needs only COM3 (3 may be any thing) but in ubunto it needs full path.

Upvotes: 0

Vinay Chandra
Vinay Chandra

Reputation: 41

this is mostly because you do not have the necessary permission to connect though uart drivers

could solve it by granting permissions everytime you connect a device by $ sudo chmod a+rw /dev/ttyUSB0 but will again fail on reboot

to grant permissions do this instead

$ lsusb to identify the uart device your working with

$ sudo usermod -aG dialout $USER to add user to the dialout group

sudo nano /etc/udev/rules.d/99-usb-serial.rules

set the rules here

SUBSYSTEMS=="usb", ATTRS{idVendor}=="xxxx", ATTRS{idProduct}=="yyyy", GROUP="dialout", MODE="0666"

in this replace the xxxx and yyyy with ur deviceid and productid that you found after running lsusb

for example for this Bus 001 Device 012: ID 10c4:ea60 Silicon Labs CP210x UART Bridge

do this SUBSYSTEMS=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", GROUP="dialout", MODE="0666"

then reload sudo udevadm control --reload-rules

and All set

Upvotes: 4

Abd Alhaleem Bakkor
Abd Alhaleem Bakkor

Reputation: 139

Likely if you ls -l /dev/ttyUSB0 you will find the permissions are for the root user and dialout group...

In this case, add yourself to dialout group like this...
sudo usermod -aG dialout <yourUserName>

Then logout/restart.

Upvotes: 2

zubko
zubko

Reputation: 1797

Another thing can happen that the modem file name will be changed from /dev/ttyUSB0 to /dev/ttyUSB1 instead. So check the /dev directory for alternatives.

There is a very nice script in this answer: https://raspberrypi.stackexchange.com/a/132175/152061

Upvotes: 1

Cosme Urdaibay
Cosme Urdaibay

Reputation: 731

add yourself to dialout and change permissions on it

$ sudo adduser <username> dialout
$ sudo chmod a+rw /dev/ttyUSB0

It worked for me

Upvotes: 63

Related Questions