Cannot program ESP8266

Alex  Pilkevych picture Alex Pilkevych · Jul 12, 2015 · Viewed 21.5k times · Source

Blue led is blinking after powering up the module, the red one stays on, I can even connect to it via wifi. But I cannot program it. I tried Arduino IDE, different firmware flashers (Like NodeMCU, XTCOM). I'm using Arduino Mega.

Here's my initial setup:

VCC - 3.3 V on Arduino
RST - nothing
CH_PD - 3.3 V on Arduino
TX - RX on Arduino (TX is transmitting data to RX, so I don't need a voltage divider, right?)
RX - voltage divider (R1 = 10K, R2 = 20K) - TX on Arduino
GPIO0 - GND on Arduino
GPIO2 - nothing
GND - GND on Arduino

Then I tried uploading a sketch from the Arduino IDE and got the following error:

warning: espcomm_sync failed 
error: espcomm_open failed

After trying different IDEs, programmers, serial port I tried firmware flashers to at least see if I can communicate with it. NodeMCU for example just showed "Waiting MAC" with GPIO0 to ground and without.

I also tried connecting TX to TX and RX to RX but got the same results. Tried connecting RX through a voltage divider as well.

With this setup the blue led was constantly on. I remembered reading somewhere that that could happen due to insufficient power supply, so I also tried connecting both pins without the voltage dividers (the blue led is still blinking after the power up so hopefully I didn't burn them). I also tried connecting GPIO0 to 3.3V and not connecting it to anything at all, connecting RST to 3.3V, connecting GPIO2 to ground as well. On Mega there are 4 sets of TX and RX pins, so I tried them all out TX/RX0,1,2 and 3.

Still no idea what's going on :(

Answer

mikevanis picture mikevanis · Sep 28, 2015

The cause can be one of two things:

  1. Insufficient power. Try to power the ESP8266 from an external 3.3V power supply such as a lab supply. Two fully charged AA batteries should do the trick too. Make sure your serial adapter's GND pin is also connected to the ESP's GND pin in order to provide a common ground.

  2. ESP8266 is not in programming mode. Make sure GPIO0 is attached to GND and turn the ESP off and on again. It will then boot into programming mode. Once programmed, you can take it off GND.

EDIT:

Since this post, I've actually encountered a third, more notorious reason. Some ESP8266 modules (especially the ESP-12 packages) actually come with alternative non-core firmware on them. In this case, you have to update the firmware on the ESP. Here is a great tutorial on how to do this. I highly recommend you use the ESP Flash Download tool which is Windows-only unfortunately, but is less error prone than doing it in a serial terminal. But before you embark on this journey, make sure the cause isn't #1 or #2.