With the SD card bootloader ready, I thought I need a mechanism to be able to download firmware from the Internet and save it to the SD card, so that upon the next reset, the Arduino is re-flashed with the newly downloaded sketch. So, I created a basic sketch that does that, it looks up a file called “app.bin” from my site (DNS resolved) and downloads it to the SD card. It is a compiled Arduino sketch that is converted to .bin format with a command like that:
avr-objcopy -I elf32-avr -O binary ledfade9.cpp.elf app.bin
As a to-do remains that I figure a neat way to reset the Arduino after the sketch is downloaded so that the flashing takes place immediately. I lean toward using the hardware watchdog reset, but I need to check the implications on the bootloader as well. Until then, a “dirty” hack maybe used to jump directly to the bootloader address, but this is not elegant solution:
cli(); asm volatile("jmp 0x7000");
Note that it is a 4KB bootloader, so hence the 0x7000 address
So the possible use of this sketch is to include it in the “setup” section of the code, so that it check for new firmware over the Internet and re-flashes itself. Combined with the SD bootloader’s capability to use file name of your choice via EEPROM string, it makes a nice add-on.
My code is available on github
Page views: 3963