Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By khoih-prog
#92679 Just testing OK with latest kernel

- linux-5.11.0-38-generic
- linux-5.4.0-90-generic

It seems recent kernel release has fixed the issue

Working kernels

- linux-5.11.0-38-generic
- linux-5.11.0-36-generic
- linux-5.8.0-48-generic
- linux-5.4.0-90-generic
- linux-5.4.0-86-generic

Not working kernels

- linux-5.11.0-37-generic
- linux-5.4.0-89-generic
- linux-5.4.0-88-generic
Last edited by khoih-prog on Tue Nov 09, 2021 10:03 pm, edited 2 times in total.
User avatar
By Robert_XY
#92766 Hi:

I found the solution on this link https://stackoverflow.com/questions/69433568/nodemcu-esp8266-cannot-upload-sketch-timeout-error. In my case I upgrade from 4.15.0-20-generic to 4.15.0-161-generic and I get the same error that you have. I went back to 4.15.0-20-generic and works perfect.
User avatar
By abellisco
#92820 Hi.
I posted a topic yesterday about this issue, but it has not been approved yet...
I ran into the same issue with Linux Ubuntu and some Wemos D1 mini and R2 cards.
here follows my proposal. It worked fine for me.
It would be interesting to check if it works in other cases.
I also have a full runbook with all the tests performed and traces of the sessions.
--------------------------------------------------------------------------
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header: a possible solution

Summary:
I'm sure there is no single cause for the error, as could be seen in the amount of mentions to it on the Web.
The procedure suggested here is based on a minor modification to be done in the esptool.py program, and some previous tests are proposed to identify if the solutions applies (or not) to the problem you may have.
The esptool.py program allows to define some options in its command line (see --before option, https://github.com/espressif/esptool):
'default_reset',
'no_reset',
'no_reset_no_sync'

You can try with a simple commmand 'chip_id':
1st try: --before default_reset
$ python esptool.py -p /dev/ttyUSB0 --before default_reset chip_id
(if result:)
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header

if this is what you get, then try:

2nd try: --before no_reset
$ python esptool.py -p /dev/ttyUSB0 --before no_reset chip_id
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting........
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 68:c6:3a:d4:d1:a7
Uploading stub...
Running stub...
Stub running...
Chip ID: 0x00d4d1a7
Hard resetting via RTS pin...

if it works, then this solution may apply to the problem you have:

Modify esptool.py, located in .arduino15/packages/esp8266/3.0.3/tools/esptool, Line 511 (if the Esp8266 board was installed using the Board manager)

##original code
def connect(self, mode='default_reset', attempts=DEFAULT_CONNECT_ATTEMPTS, detecting=False):
""" Try connecting repeatedly until successful, or giving up """
print('Connecting...', end='')
sys.stdout.flush()
last_error = None

try:
for _ in range(attempts) if attempts > 0 else itertools.count():
last_error = self._connect_attempt(mode=mode, esp32r0_delay=False) ## line1 to modify
if last_error is None:
break
last_error = self._connect_attempt(mode=mode, esp32r0_delay=True) ## line2 to modify
if last_error is None:
break
finally:

## modified code
try:
for _ in range(attempts) if attempts > 0 else itertools.count():
last_error = self._connect_attempt(mode='default_reset', esp32r0_delay=False) ## changed
if last_error is None:
break
last_error = self._connect_attempt(mode='no_reset', esp32r0_delay=True) ## changed
if last_error is None:
break
finally:

Save it, and now try again to upload your Arduino sketch.

Hope this helps
rgds
Abel