Remote sketch uploading has been something I have long wanted for my projects. I can outline two major cases:
1) Remote flashing over TFTP – useful for remote locations where it won’t be convenient to go physically
2) Flashing from SD card – useful when you can provide firmware (compiled to .bin sketch) for downloading by end clients
Typically case 1 would require Internet connectivity and setting up port forwarding so that the unit is visible behind firewalls. Clients do not not like the idea of someone poking their firmware remotely as well, but for unattended projects this is adequate solution. The problem here comes from the greater hardware dependency on the Ethernet chip, most common are the WizNet 5100 and ENC28J60.
The ENC28J60 options are Andrew Lindsay’s work on TFTP client for Nanode that downloads a .hex image in SRAM and a custom bootloader to flash it afterwards. Not an elegant solution in my view.
Another option, unfortunately not open-source is the one from Sketch Garden:
Sketch Garden lets you upload sketches to your Nanode over the web instead of with an FTDI cable. You develop your sketches in the Arduino environment as normal, compile and upload them to Sketch Garden, currently in private beta.
This means you can reprogram your Nanode in the field, from any computer anywhere.
Using Sketch Garden requires a new web enabled bootloader, available from Wicked Device soon.
Well, no good as well, I don’t want someone else to re-program my NaNodes quietly at night so they attack me in my sleep 🙂
The options for WizNet5100 chipset seem more viable, I found at least two bootloaders for that chipset:
I tried the first one but failed to get it working, It does connect but then hangs for some reason. I haven’t had the time to poke further.
The second one seems really advanced one where the DHCP provides the binary image for flashing, looks way over my head at this time so I didn’t even try it.
So I re-focused on flashing a sketch from SD card, it looks like more platform compatible option. The option I was reviewing was this one:
I just released my proof-of-concept dual bootloader(serial/mmc) for the arduino platform. Code is on github
- Just 2kb of flash, fits into normal 2kb bootblock of most atmega chips
- Serial (stk500v1) bootloader, compatible with avrdude and Arduino IDE
- Additional MMC bootloader, can read directly a intel .hex format file from an MMC/SD
- Includes all of ladyada’s fixes to the original bootloader
You might ask why?. I have quite a few arduino “in the field”. With this bootloader, I can simply drag a .hex file to an SD card, insert it in an SD shield, and field-upgrade my boards without additional hardware. But I can still use the serial/usb port to develop on the very same hardware.
Well, lots of us tried to get this to work as it is the best option so far, but failed. The author seems to have abandoned the project and is not responding, therefore few of us opened a new thread in the Arduino Forums to try to get it working.
It all stalled, until one day I found an example in the PetitFatFs that was doing exactly what I needed! The AVR_BOOT provided the ability to flash a sketch from SD card. With minor tweaks, it was working on Arduino Ethernet.
I have created a fork on github here. The downsides are that this is a 4KB bootloader and it doesn’t support flashing over FTDI, but I can live with that. I have modified the original code to check if the binary image is changed and only upon change to re-flash it as the original version was flashin upon every reset. I also added some LED blinking on pin 9 so that I can visualise the re-flashing process.
I plan to modify the bootloader to look for sketch name in the EEPROM as well and if found, to flash from that name rather than the fixed “app.bin” name. That will allow the sketch to modify the firmware as needed.
This bootloader can work for both Arduino’s and Nanode’s with SD card, so I find it more platform independent.
I will be selling pre-flashed with that bootloader ATMega328s in the store soon.
Page views: 15025