7

After a fresh install of Ubuntu, I tried to upload sketch using Arduino IDE v1.8.16 (installed using a .deb file downloaded from web).

An error occurred while uploading the sketch avrdude: ser_open(): can't open device "/dev/ttyACM0": Device or resource busy

After a first install of Arduino IDE on a new Linux machine need to be a member of : sudo usermod -a -G dialout $USER and logoff, logon ,which didn't change as expected.

So I tried to chmod of connected port /dev/ttyUSB0, which didn't change the error message ( by the way, also on USB1, and ACM0 I got the same output- when trying to upload to Nano).

Now I get this error:

esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____
Traceback (most recent call last):
  File "/home/guy/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/upload.py", line 66, in <module>
    esptool.main(cmdline)
  File "/home/guy/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 3552, in main
    esp.connect(args.before, args.connect_attempts)
  File "/home/guy/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 529, in connect
    raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

To verify it is not an IDE error, I tried using esptool.py to erase flash, and I got the same behaviour Connecting........_____....._____....._____....._____....._____....._____....._____

6
  • An error regarding Serial port is known Do you mean there is a known error or are you referring to the error you received?
    – David
    Oct 6, 2021 at 10:35
  • @David perhaps a not optimal explanation, try this: After a new installation of ubuntu ( or first time using Arduino IDE on a PC, there is a need to add user to the dialout group
    – guyd
    Oct 6, 2021 at 10:37
  • Very different from what the question says. Maybe edit the question.
    – David
    Oct 6, 2021 at 10:38
  • question edited as mentioned
    – guyd
    Oct 6, 2021 at 10:44
  • Nano seems to be Arduino. While esptool is used for Espressif ESP8266 and/or ESP32. Please clarify the used hardware MCU model.
    – N0rbert
    Oct 6, 2021 at 21:11

4 Answers 4

7

this happens to the latest ubuntu with the latest kernel and several versions of arduino-ide ( from snap, from apt install, even with the latest version installed from arduino's website ) tried several board version's tried modded esptool tried not-modded esptool tried several (not charge only) cables tries several esp32 boards and esp32 vendors ( wemos, nodemcu, etc. )

I believe that there might be a problem with the serial driver? All boards are working great on windows with all versions of arduino-ide tested on Ubuntu 20.04, and same cables. I ruled out any possible problem in regards to : software (ide), cables, boards.

will dig more into this.

LE: Found the issue! Looks like there is a bug in the kernel driver for ch340/ch341 I had one old kernel installed ( 5.9.x ) and with this one works. That took me to some search over the internet :) so here it is

      Bug ID: 214131
     Summary: ch341 communication problem
     Product: Drivers
     Version: 2.5

Kernel Version: 5.14-rc5 Hardware: All OS: Linux Tree: Mainline Status: NEW Severity: normal Priority: P1 Component: USB

It looks to me that starting kernel 5.10.x till 5.14-rc5 the bug is present.

Happy coding guys

3
  • 1
    So from what I understand, there's no end user solution here but to wait for an update? This is troublesome but strangely enough, my Arduino Nano running on CH340 runs just fine. Only the ESP boards experience the problem.
    – Jacobski
    Oct 19, 2021 at 21:36
  • Seems to have fixed itself after recent kernel patch for me, before that booting into 5.3.0-64 worked as a temporary fix. Oct 20, 2021 at 8:14
  • I have held back the kernel which works until an update comes askubuntu.com/questions/938494/…
    – ISparkes
    Oct 22, 2021 at 5:44
4

Workaround for ESP boards:

Settings prior to uploading the sketch:

  • Boardtype: Generic ESP8266
  • Flash size: 4MB
  • Reset method: "dtr (aka nodemcu)" (default)

Then:

  1. Change reset method to: "no dtr (aka ck)" (Tools -> Reset Method)
  2. Then press Flash button
  3. Press Reset shortly
  4. Then release Flash
  5. Upload sketch in the Arduino IDE

Arduino

Source: https://forum.manjaro.org/t/manjaro-21-1-0-und-esp8266-sketch-upload-doesnt-work-anymore/79712/2

Note: Tested on ESP8266 (NodeMCU)

Update:

This issue has been fixed in the latest kernel version. Please update the kernel and test again.

6
  • I tried it already as it seemed like ESP32 or pro micro waiting for that reset ( not successfully though)
    – guyd
    Oct 8, 2021 at 16:48
  • 1
    @Guy.D I successfully tested on ESP8266 (NodeMCU)
    – DevTomek
    Oct 9, 2021 at 18:23
  • I cannot find "Tools -> Reset Method". Is it in Arduino IDE, next to Board/Upload Speed/Debug Port/...? Oct 20, 2021 at 11:55
  • 1
    @EricDuminil You have to select correct board e.g. 'Generic ESP8266 Module'
    – DevTomek
    Oct 20, 2021 at 15:01
  • @DevTomek: Thanks. I downgraded my kernel, but it's good to know that other temporary fixes are available. Oct 20, 2021 at 15:33
3

with kernel linux-image-5.4.0-87-generic @ ubuntu 18.04 I have exactly the same problem (running latest arduino, board definitions and libz), when I reboot to 5.4.0-86-generic it works again, dunno why, but spent like hour today finding out what changed (bcs I use arduino for a long time on this computer and always everything worked smoothly...)

So try to boot older kernel, maybe it helps

2
  • 1
    I can confirm this works fine with "5.4.0-86-generic", on Ubuntu 18.04 and Linux Mint 19.3. This issue was really hard to track down, amid all the "RTFM, Noobie" answers telling people to press buttons, change permissions, add users to groups or use DIP switches. "5.4.0-87", "5.4.0-88" and "5.4.0-89" all have this bug. Let's hope the next version won't. Oct 20, 2021 at 12:25
  • "5.4.0-91-generic" is now working fine, and I can upload again to ESP8266 with the current kernel. Dec 15, 2021 at 16:54
0

Thank you, the workaround works for me!!

5.4.0-89-generic #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

VID: 1A86 PID: 7523

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Error404
    Oct 30, 2021 at 13:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .