Good idea, I think. Maybe someone has already done it.
I'm no bootloader expert, but it certainly sounds possible to me, and also might work light
years better than what I have tried - ie, using XBees to try and load a new sketch into an
Arduino chip. Basically, the latter doesn't work worth poo, since the normal transfer program
[avrdude] and normal bootloaders do not throttle and/or repeat packets properly, so the
transfers lose sync.
The XBee scheme worked in the past with slow bootloader transfers [eg, adafruit describes
it], but not anymore with optiboot, etc.
Normally, the uploading process first initiates an Arduino hard reset that causes a branch to
the bootloader, so it can start accepting the new code. I think you would have to include a
section in "every" sketch you wrote that could accept data, and store it to the I2C eeprom.
Then, produce a software reset that would branch to the [hacked] bootloader and read from
the I2C eeprom into Flash. Then, branch to the start location.
You could have a variable in I2C eeprom that would hold the version number, and a flag to
indicate whether the Flash has been updated, so it wouldn't try to do this every time you
turned the chip on.
This could be made more reliable than trying to Flash the sketch directly [ie using the IDE
as normal], since you could have packets and repeat packets and CRCs on the data transfers
to I2C eeprom. You can also get 32KB and 128KB I2C eeproms.
Hmmm, cool. Do it, and send me the code - please! ;-)