Yun application code reflashing remotely or USB stick

I have a mini project were I would like to install a couple of Yun's monitoring data at various locations, I know there will be a need to refresh the application code but do not really want to use a laptop & Arduino IDE.

Ideally I would like to either remote flash them over via the wifi or USB memory stick with the application code flash file, then both will refresh the ATmega32u4 uC.

How does the IDE re-flash the ATmega32u4 over the wifi, does it dump a file onto the linux side and then refresh the uC? Does the Arduino IDE produce a .hex file which can be used to flash the uC?

I suppose it would be possible to use the ISP socket and then use external memory/control to refresh the device.

Just interested if/how this would be possible?

brendonshaw: How does the IDE re-flash the ATmega32u4 over the wifi, does it dump a file onto the linux side and then refresh the uC?

Yes.

After building your sketch, copy the compiled hex file to your Yun. Then run the following code which assumes you copied it to the /tmp directory (a temporary folder in RAM - won't survive a reset, but is fast and doesn't wear out flash memory.)

cd /tmp
/usr/bin/merge-sketch-with-bootloader.lua     /tmp/Sketch.cpp.hex
/usr/bin/run-avrdude     /tmp/Sketch.cpp.hex

This merges the USB bootloader with your sketch, which must be done once and only once. It then programs the sketch onto the '32U4 using the ICSP pins (if your sketch uses SPI through the ICSP header, make sure any hardware doesn't conflict with those pins, for example make sure MISO is not being driven by your slave unless it is selected.)

Does the Arduino IDE produce a .hex file which can be used to flash the uC?

Yes. Buried deep down in a temporary folder, the name of which often changes. In the IDE, open Preferences under the File menu, and enable verbose compiler output. That will show you the location where the hex file was created.

Good luck, you're definitely on the right track with the way you're thinking.