Upload Arduino sketch (HEX) through the internet / Local LAN

Hello everyone,

I'm new on Arduino's world, and I have a challenge that may can help almost arduino lovers!
After a deep research, I found a couple of topics in this forum, almost just without any solution maybe because the people just give up.

The idea is basically upload the arduino sketch through the internet or the local lan.
I was thinking about upload the .hex file (generated by the Arduino IDE) to a SD-Card through the internet / LAN.
After the upload is done, arduino could check out for a "Software Update", and then execute the process to load the .hex file to it self.

Let's supose that you have an Arduino device that you can connect by the internet, upload a .hex file to the SD, and send a command to arduino to execute the update process and load the .hex file from SD ? Is that possible ?

I see this topic ATmega Hex Uploader - Microcontrollers - Arduino Forum but it's to use Arduino as AVR Programmer.
Mr. Nick Gammon has created a amazing project !

Also I found some interesting posts related to TFTP Bootloader:
http://playground.arduino.cc/Code/TFTPBootloader1
http://forum.arduino.cc/index.php?topic=87455.0

I have not tested yet the TFTP solution... any one has been tested this ?

Thanks!

I have not tested yet...

Nor have you asked a question or made a point or posted in the correct place.

PaulS:

I have not tested yet...

Nor have you asked a question or made a point or posted in the correct place.

Sorry PaulS, my bad... I mean that I have not tested the TFTP solution... and I was talked with Mr. Nick Gammon before post this in the forum!
I'll correct my post!

Thanks!

So you are asking can the chip program itself? The short answer is yes, because that is what the bootloader does. However whether you can fit the code to read from the SD card into the bootloader section, I'm not sure. One possible solution would be to have two chips. One is setup up to program the other one. The programming one saves new code into the SD card, and then when requested puts the second chip into programming mode, and programs it. The drawback is needing two chips, but after all they cost around $5, so it isn't that big a deal.

I seem to remember reading a post from somebody who was talking about work in progress to make it possible to upload sketches via Ethernet using an Ethernet-capable bootloader. I can't remember the details - did I make that up?

Quite possibly, but you mentioned an SD card.

I seem to remember reading a post from somebody who was talking about work in progress to make it possible to upload sketches via Ethernet using an Ethernet-capable bootloader. I can't remember the details - did I make that up?

Thanks Nick / PeterH,

Actually I found in this forum a couple of posts related of this work, but seems without solution...
I have check out how the TFTP bootloader works, and it's looks like that's only allow you to upload the sketch for about 5 seconds after the hardware reboot...
I know that in my post I was asking about to use the SD-Card to upload the sketches to the Arduino, but that's not necessary can work by that way.
The point is that I was thinking about upgrade the sketches remotely, and I put the SD Card on this just to make sure that nothing wrong happens (Let's supose that during upload the sketch by TFTP for some reason you loose the connection), probably you have to come there to reset the device by hand... and if you use the SD Card, you just will start upload the sketch after you make sure that have been done the download to SD Card!

Please correct me if I'm wrong, as I mentionated the TFTP works only for 5s after the arduino is rebooted or powered on...
Is that possible to configure a kind of command that you can add to the all of sketches to call the TFTP mode to start the download of the new sketch ?

Thanks!

rmartins:
Is that possible to configure a kind of command that you can add to the all of sketches to call the TFTP mode to start the download of the new sketch ?

I believe it is possible to reboot Arduino by code.

zoomx:

rmartins:
Is that possible to configure a kind of command that you can add to the all of sketches to call the TFTP mode to start the download of the new sketch ?

I believe it is possible to reboot Arduino by code.

I have heard that's possible, but some hardware changes is required!
Thanks for the suggestion!

No, I believe that you don't require any hardware modification.

You can jump to zero (jmp 0 in assembler) or you can enable watchdog and wait.

http://forum.arduino.cc/index.php/topic,42436.0.html
http://forum.arduino.cc/index.php/topic,49581.0.html

Jumping to address 0 doesn't cause a hardware reset and thus would not enable the bootloader. The watchdog idea could be made to work.
I still think more reliable would be my suggestion of two chips: one to do the work, and the other to reprogram the first one.

Nick, thanks for the suggestion!
Do you have some diagram how to use the two chips and the sketch ?
Your idea is the best and reliable, since we need to make sure that's nothing wrong happens! Otherwise if the hardware is far away and it's crashes, we have to take a ride and fix that by hand!

I'm pretty sure that this idea is going to help a lot of people that have to handle with projects by distance that some times needs a firmware upgrade, and it can be done remotely !

Do you suggest this for this task: Gammon Forum : Electronics : Microprocessors : Atmega chip stand-alone programmer to upload .hex files

Thank Nick for all your help!

Something similar to that. That particular sketch reads in an existing file on an SD card, under interaction via the serial monitor.

A modified version could:

  • Connect to the serial port.
  • Forward incoming/outgoing data from the "main" processor to the Ethernet port (if required)
  • If a new sketch arrives, save it to disk (SD card).
  • If the new sketch has arrived fully (eg. a sumcheck proves it is OK) it goes into programming mode, and programs the main board.

I would thoroughly test this in the lab before deploying it, otherwise you will be taking a lot of rides!

That would be awesome!!
I think that will open the door for many projects that can be upgraded remotely with a stable project!