I am sorry for posting this question for the nth time but I am still not able to find a solution for this error.
I am trying to upload the WiFiScan(Arduino IDE example program)program code to ESP8266 using Arduino Mega 2560. I followed the procedure given here. And I tried uploading it with "Generic ESP8266 Module" and "Adafruit HUZZAH ESP8266" selected as the Board. But I am still getting the following error.
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
Connections-
ESP8266 - Arduino Mega2560
Tx - Tx1(Pin 18)
Rx - Rx1(Pin 19)
Gnd - Gnd
Vcc - 3.3V (Directly from Arduino's 3.3V pin)
CH_PD - 3.3V (Directly from Arduino's 3.3V pin)
GPIO0 - Push button K2 (refer photo)
RST - Push button K1
While pressing the K2 button(Flash button - GPIO0), I clicked the K1 button(Reset button - RST) and then released K2. According to the document, this should bring the ESP8266 to flash mode. Now when I upload the code, it throws the above error.