remote firmware after boot


i would like to have some hint about an idea that's on my mind :slight_smile:

First of all, sorry for my terrible english, hope that you can understand me.

i have an arduino mega and an esp8266 wifi module. i am using arduino core on the esp8266 and connected esp8266 on serial3 of the mega.

when arduino need some 'info' about a certain page on internet, he write on serial3 "ping"
and the mighty esp8266 reply with the required data.

add some control character for the end of message and everything it working fine!

Now, it will be great to 'boot' the mega with a firmware send via serial by the esp8266.

what i was thinking is

void setup() {
 //do all the init stuff, probaly not even required

  //read firmware+version
  //if version > current_version
  //install, reboot

on the esp8266, it's just matter of adding a new "command" apart the "ping" that fetch
the http page, adding another "firmware" that will fetch the hex page with the current firmware version
(including some header for crc or any fancy stuff ....)

it's that possible at all?
Everything it's clear, how to download the firmware, how to send it via serial and anything, i just
don't know how and if it's possible to install a firmware in that way, in a sort of "over the air" fashion.