Upload a sketch to an Arduino, from an Arduinio?

Hey!

I want to be able to give a friend of mine an Arduino Mega which is pre programmed with the ability to upload a sketch to another Arduino mega. Kind of like a Master Board which can be used to upload a specific sketch to many other boards.

I have read about the SPI but dont 100% understand its capabilities but im pretty sure this is where I should be looking...

Would it be possible to write a sketch which contains a sort of "payload" (the ACTUAL program I want uploaded to another Arduino) which could be hooked up to another arduino of the same kind (via SPI) which will upload the desired sketch apon powering up the 2 devices while connected via SPI?

Does that sort of make sense?

Thanks in advance for your answers! :slight_smile:

I have tried with AVR pocket programmer it worked for me.It cost around 1000rs (INDIAn) .There is option in file upload program using programmer.You can use that option

I want to be able to give a friend of mine an Arduino Mega which is pre programmed with the ability to upload a sketch to another Arduino mega. Kind of like a Master Board which can be used to upload a specific sketch to many other boards

Q1:Whether you want to share code with your friend or not? If not you can share hex file generated so your coding part can,t seen by your friend.
http://arduino.cc/en/Guide/ArduinoMini
Try this hope it might help.

So if I used some kind of HEX file generation on my sketch, could he then upload that HEX file via the Arduino IDE without actually being able to see the code?

Yes He cant check the code you have written.If your friend smart enough , he can use the interface used in board and use these hexfile to create his own product.

He can download this link .Where it allows use to select the Hex file.Usually ur hex file is saved in temp by default and you can change in preference to select the folder.

Horendus:
Does that sort of make sense?

Yes. The 'Arduino ISP' sketch receives a payload via the USB serial interface and uploads it to a target Arduino via the ICSP header. Your sketch would be similar, but taking the payload from some local storage device instead of the USB serial interface. I'm reasonably confident that Nick Gammon has posted a sketch that does this - I think his implementation uses a local SD card to store the payload. That seems like a good approach because it would be easy to plug the SD card into a PC to prepare the payload so this wouldn't require any extra complexity within your solution - it would also make it possible to support multiple payloads, or to update the payload for bugfixes and so on, without having to rewrite your solution.

There are Arduino clones around with integral SD card sockets, and there are shields to add SD sockets to standard UNO and compatible Arduinos.

It would also be possible to store the payload within the program space of your sketch, but this would require your solution to contain the payload which places obvious constraints on the size of your Arduino relative to the size of the target.

Great info guys! Thanks!

Does Arduino IDE store the hex files anywhere? If not is this easy to do in say, Atmel Studio?

If you enable verbose logging in the IDE and then upload a sketch, you will see the log output showing where the temporary files used during the upload are stored.

Horendus:
Great info guys! Thanks!

Does Arduino IDE store the hex files anywhere? If not is this easy to do in say, Atmel Studio?

You can set your hex file output in preferences. By default you can check in temporary file. with folder with similar file name build7159765377742401037.tmp , Just look for hex file