- Sat Nov 13, 2021 1:31 am
#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