20

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.

5
  • The error message seems very clear. Your device is not located at /dev/ttyUSB0. What command line are you entering? Are you forcing a specific port? Usually the tool will search to find it. You might ls /dev/ttyUSB* to see what devices there are. Commented Oct 2, 2022 at 4:13
  • @TimRoberts The command I entered: "idf.py -p /dev/ttyUSB0 flash". "ls /dev/ttyUSB*" output "/dev/ttyUSB0". Also entering the command "idf_monitor.py" showed an error: "OSError: [Errno 16] Device or resource busy: '/dev/ttyUSB0'". Commented Oct 2, 2022 at 4:51
  • arduino ide sees the port and shows it as /dev/ttyUSB0 Commented Oct 2, 2022 at 5:14
  • 1
    Serial ports are one-user-at-a-time. If the IDE has the port open, you can't open it from your script. Commented Oct 2, 2022 at 18:15
  • Are you able to download a simple Arduino based program to your ESP32 over /dev/ttyUSB0 using your Arduino IDE? Commented Oct 3, 2022 at 23:19

5 Answers 5

70

add yourself to dialout and change permissions on it

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

It worked for me

Sign up to request clarification or add additional context in comments.

6 Comments

If the user is added to the correct group, why would we need to add global read/write?
I believe it has to do with the file that represents the device. Although it worked for me, I found out each time the device is plugged I've to change the file mod. Probably there's a better way to do it. In no way I'm an expert I'm sharing what I found out worked for me. Good luck and happy coding.
for arch-based distros it would be: usermod -a -G uucp <username>
$ sudo adduser $USER dialout $ sudo chmod a+rw /dev/ttyUSB0
thnaks, you saved a lot of time. but you don't need to adduser, you can just change usermode sudo usermod -aG dialout <yourUserName>
|
4

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

Comments

2

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.

Comments

1

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.