programming esp8266-01s with arduino mega

Hello,
The title explains everything.
I used this video. the schematic and the code can be found there.
I can’t upload the code because I am getting this error:

Archiving built core (caching) in: C:\Users\ARADAR~1\AppData\Local\Temp\arduino_cache_162989\core\core_esp8266_esp8266_generic_CpuFrequency_80,ResetMethod_ck,CrystalFreq_26,FlashFreq_40,FlashMode_qio,FlashSize_512K0,led_2,LwIPVariant_v2mss536,Debug_Serial,DebugLevel_None____,FlashErase_none,UploadSpeed_115200_4ad019f29ac23d61b3ca55a9df1ef2dd.a
Sketch uses 254144 bytes (50%) of program storage space. Maximum is 499696 bytes.
Global variables use 32948 bytes (40%) of dynamic memory, leaving 48972 bytes for local variables. Maximum is 81920 bytes.
C:\Users\Arad Arbel\Documents\ArduinoData\packages\esp8266\tools\esptool\0.4.13/esptool.exe -vv -cd ck -cb 115200 -cp COM3 -ca 0x00000 -cf C:\Users\ARADAR~1\AppData\Local\Temp\arduino_build_279084/WiFiScan.ino.bin 
esptool v0.4.13 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
	setting board to ck
	setting baudrate from 115200 to 115200
	setting port from COM1 to COM3
	setting address from 0x00000000 to 0x00000000
	espcomm_upload_file
	espcomm_upload_mem
	setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
An error occurred while uploading the sketch
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
resetting board
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
resetting board
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
trying to connect
	flush start
	setting serial port timeouts to 1 ms
	setting serial port timeouts to 1000 ms
	flush complete
	espcomm_send_command: sending command header
	espcomm_send_command: sending command payload
	read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

It worked in the past when I did the exact same thing with the same arduino and the same esp8266 board. suddenly it doesn’t. I already tried powering the esp only after connecting everything else but it’s not helping.

Thanks for ANY help,
Arad.

did you put the board into bootloader mode by connecting io 0 to ground at startup?

Juraj:
did you put the board into bootloader mode by connecting io 0 to ground at startup?

I am not sure which board you are talking about (arduino / esp). I guess it is the esp so yes, I did. also I did the same to the arduino by connecting reset to ground.

Problem solved. What a strange issue!
I just switched the tx/rx wires.

BEFORE:
arduino TX -> esp RX
arduino RX -> esp TX
that makes sense, right?

AFTER:
arduino TX -> esp TX
arduino RX -> esp RX

That is very weird, but working.

The problem now is after uploading... the code just doesn't seems to run. I tried esp blink, and wifiScan - but nothing. what is going on?

if you want to use the usb adapter of the arduino to flash the esp module, you must connect to it RX to TX and TX to RX. and since the USB adapter is connected to Atmega RX to TX, TX to RX, by connecting to RX of Atmega you connect to TX of the USB adapter.