Flash an arduino mega2560 and esp8266 from sd card

Hello as the title suggests i would like to know how possible it is to load - flash an Arduino mega2560 from an SD card, does anyone know a good bootloader to achieve this ?

And can i do the same for my ESP8266, either flashing it directly from the SD card or use the mega to read the SD card and flash the ESP, I know both use STK500 v2 and i would already have the HEX files on the SD card one for each.

I was previously using a tool i made in C# and an FTDI plus DIP switch to flash either chip but the prototype is for a company and they asked it it would be possible to flash both from an SD card for easy of use :o :confused:

Any tips in the right direction is appreciated, many thanks from Ed.

As for the ATmega2560, the bootloader I've used for other AVR chips is avr_boot:

Unfortunately it does not currently work with ATmega2560 but there is a comment that claims to explain how to make it work:

I haven't had a chance to try it out yet.

in esp8266 you can use the Update object. examples for it are libraries ArduinoOTA, ESP8266HTTPUpdateServer and ESP8266httpUpdate

you can flash 2560 from esp8266 with ArduinoISP library if they are connected over SPI