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........_____....._____....._____....._____....._____....._____....._____

guyd
  • 955
  • 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 06 '21 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 06 '21 at 10:37
  • Very different from what the question says. Maybe edit the question. – David Oct 06 '21 at 10:38
  • question edited as mentioned – guyd Oct 06 '21 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 06 '21 at 21:11
  • The bug now seems to be fixed (e.g. in "5.4.0-91-generic") – Eric Duminil Dec 15 '21 at 16:54

4 Answers4

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

  • 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 '21 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. – Alex Hope O'Connor Oct 20 '21 at 08:14
  • I have held back the kernel which works until an update comes https://askubuntu.com/questions/938494/how-to-i-prevent-ubuntu-from-kernel-version-upgrade-and-notification – ISparkes Oct 22 '21 at 05: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.

DevTomek
  • 141
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

buger
  • 31
  • 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. – Eric Duminil Oct 20 '21 at 12:25
  • "5.4.0-91-generic" is now working fine, and I can upload again to ESP8266 with the current kernel. – Eric Duminil Dec 15 '21 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

  • 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 '21 at 13:22