Search code examples
esp8266esp32

Problem uploading code to ESP8266: esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for package header


I'm trying to upload the example Blink code to my ESP8266 modules, 1 of which is an ESP8266-07, the other a WeMos D1 mini PRO. I've installed the library for the ESPs according to online instructions. I'm uploading from Ubuntu 16.04, Arduino 1.8.9. I've also made sure to use sudo chmod 666 /dev/ttyUSB0.

I've tried uploading both through a normal USB cable and through a USB-TTL board, both of which made no difference. My Tools > Board settings are "Generic ESP8266 module" for the ESP8266-07 and "LOLIN(WEMOS) D1 mini Pro" for my mini Pro. In all 4 cases (2 different boards, 2 uploading cables/gateways), I've got the same error message.

raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for package header

I've also tried uploading the code to my Node MCU, in which case, I got a different error:

esptools.FatalError: Invalid head of package (0x46)

Solution

  • I've resolved the problems with the ESP8266-07 and D1 mini Pro by changing the upload speed to 115200.
    Another important thing to note is to set the right boards: "Generic ESP8266 module" for the ESP8266-07 and "LOLIN(WEMOS) D1 mini Pro" for the mini Pro. I sometimes forget to do so when changing between the 2 boards.
    However, I haven't yet resolved the problem where my NodeMCU keeps returning esptool.FatalError: Invalid head of packet (0x46)