As of ESP8266 community version 2.6.x, an upload of a sketch to the ESP8266 fails with:
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
Reverting back ti library version 2.5.2 solves the probem, but obviously means that I can't use the latest version of the library. Ine difference is that esptool.py has been updated from version 2.6 to to 2.7 and then 2.8 in later versions of the ESP8266 community library.
The esptool can be found on my linux system in
~/arduino15/packages/esp8266/hardware/esp8266/2.6.0/tools/esptool
The really strange thing is that after exporting the binary and running esptool.py manually, with:
./esptool.py --port /dev/ttyUSB2 write_flash 0x000000 mybinary.bin
then it works just fine. It only seems to fail when the upload is initiated from the Arduino IDE. Here is the output from the IDE:
esptool.py v2.7
Serial port /dev/ttyUSB2
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: cc:50:e3:55:db:52
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...
esptool.py v2.7
Serial port /dev/ttyUSB2
Connecting........_____....._____....._____....._____....._____....._____....._____
Traceback (most recent call last):
File "/home/johnc/.arduino15/packages/esp8266/hardware/esp8266/2.6.0/tools/upload.py", line 25, in <module>
esptool.main(fakeargs)
File "/home/johnc/.arduino15/packages/esp8266/hardware/esp8266/2.6.0/tools/esptool/esptool.py", line 2841, in main
esp.connect(args.before)
File "/home/johnc/.arduino15/packages/esp8266/hardware/esp8266/2.6.0/tools/esptool/esptool.py", line 483, 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
Warning: file /home/johnc/.arduino15/packages/esp8266/tools/python/3.7.2-post1/python links to an absolute path /usr/bin/python
The thing that's a bit odd is that after detecting the RAM size, it outputs this:
Auto-detected Flash size: 4MB
Hard resetting via RTS pin...
esptool.py v2.7
Serial port /dev/ttyUSB2
Connecting........_____....._____....._____....._____....._____....._____....._____
Its as if the esptool.py process is being restarted? Presumably if the original process is still running or hung, then the port could be busy which is why it can't reconnect. So what is causing this? This does not happen when esptool.py is run manually from the command line or with library version 2.5.2. After detecting the flash size it should move on to setting the flash parameters and preparing/performing the upload as follows:
Auto-detected Flash size: 4MB
Flash params set to 0x0340
Compressed 317680 bytes to 222562...
Wrote 317680 bytes (222562 compressed) at 0x00000000 in 19.6 seconds (effective 129.3 kbit/s)...
The line 'Hard resetting via RTS pin...' should come only after the upload is completed.
Anyone come across this or have any idea why it is failing?
Not sure if its an IDE or ESP8266 library problem.