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
  • 987

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

oddyutza
  • 86
  • 3
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
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