remote programming a Mega with an Uno

Hi there,
our hobby flyer club has a very remote weather station and we need to update the sketch sometimes.

I was looking at Nick Gammon's nice

and was wondering if it would be possible to use that to accomplish what we need.

Mega, Uno and the SD card are all connected to one SPI bus (directly or via "bit banged" SPI).
Uno is always connected to the ICSP of the Mega.

Mega checks online if a new sketch is available.
If yes,
the old sketch is erased from SD,
the new sketch is uploaded by the Mega to the SD card,
(Content is verified?),
Mega sends string with result, and if all ok,
Mega turns Uno on.

Uno starts programming the Mega via ICSP from SD card.

(Uno verifies?)
Uno sends string with result.
Uno resets Mega and turns itself off.

Turning on/off is done by a toggle flip flop and an N6020 FET (a similar one turns ethernet shield off during night to save power).

The mentioned fixed filename sketch would be changed to just directly start programming the mega (skipping buttons to be pressed etc.)

Would that work?


This is another option:

Our programmer never got that working, something with static IPs wouldn't work.

That's why I'm looking into other, non bootloader options.

Were you able to use it, did it work for you?

Thank you!

Yes, I use it all the time and it works great but I only use it on my local network with static IPs. I haven’t tried it with dynamic IPs or on the Internet. I know the developer does use it over the Internet though.

If you wanted to try your SD idea with only one Arduino you might consider this:

it doesn’t currently work on the Mega and it’s a large bootloader so it might use up more memory than you have to spare once you get your downloading code in there. An ATmega1284P would probably provide plenty enough memory for you and is supported by avr_boot. I know there’s a more lightweight version called 2boots but I haven’t tried it and some other people reported having troubles with getting it working.

Thank you for your reply! It is that he fails to even burn that “LoathingKernel/Ariadne-Bootloader” onto a Mega.

But you are the third person confirming it is working.

Anyhow, thanks also for the other links, very interesting, never found those, have to dig further (3:30 am here in LA).

But for now, I would really try to use the “no bootloader change” route, so the initial question stands.

Would it be possible to do the mentioned stuff with Nick Gammons excellent code?

It is that he fails to even burn that "LoathingKernel/Ariadne-Bootloader" onto a Mega.

I'm using it with Megas, no problem. I've contributed some code to Ariadne and am pretty experienced with it so I may be able to help with that problem given more information if you decided to give it another try. I haven't tested the most recent work done on it quite as thoroughly but I didn't have any problems when I did.

Would it be possible to do the mentioned stuff with Nick Gammons excellent code?

I can't say but hopefully someone else here can.

Dear Pert,
thank you for your kind offer, I will sit down with our programer later today and document what goes wrong.
Hopefully you can help us getting it going!
That would be really cool!