FOTB - Firmware Over The Bus
See: https://github.com/arduino/ArduinoCore-samd/pull/220
Steps:
Get SDUBoot.ino from https://github.com/arduino/ArduinoCore-samd/tree/master/libraries/SDU/extras/SDUBoot. Use this as starting point for an own version, let's say we name our version "MyBoot"
So we will have
MyBoot\ MyBoot\EFUBoot.ino
and we also need
MyBoot\boot MyBoot\build.sh
build.sh should contain something like this:
#!/bin/sh -x
ARDUINO=$ARDUINO_HOME/arduino
SKETCH_NAME="MyBoot.ino"
SKETCH="$PWD/$SKETCH_NAME"
BUILD_PATH="$PWD/build"
OUTPUT_PATH="./boot"
if [[ "$OSTYPE" == "darwin"* ]]; then
ARDUINO="/Applications/Arduino.app/Contents/MacOS/Arduino"
fi
buildSDUBootSketch() {
BOARD=$1
DESTINATION=$2
$ARDUINO --verify --board $BOARD --preserve-temp-files --pref build.path="$BUILD_PATH" $SKETCH
cat "$BUILD_PATH/$SKETCH_NAME.bin" | xxd -i > $DESTINATION
rm -rf "$BUILD_PATH"
}
mkdir -p "$OUTPUT_PATH"
buildSDUBootSketch "arduino:samd:arduino_zero_edbg" "$OUTPUT_PATH/zero.h"
Make it executable with help of
chmod g+x build.sh
And finally run it with
./build.sh
After that, you have a .h file in your boot-folder.
Copy/paste SDU.cpp/SDU.h and let them point to the .h file you just created.
Write your sketch and include your version of SDU.h/SDU.cpp with "#include". Upload your sketch as usual.
If you now apply you update according to your own SDUBoot variant and reboot your arduino, the new sketch is applied to main memory and arduino starts up with the new sketch.