FOTB - Firmware Over The Bus

From KONNEKTING Wiki
Revision as of 08:48, 8 March 2018 by E.burkowski (talk | contribs)
Jump to navigation Jump to search

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 "EFUBoot"

So we will have

EFUBoot\
EFUBoot\EFUBoot.ino

and we also need

EFUBoot\boot
EFUBoot\build.sh

build.sh should contain something like this:

 1#!/bin/sh -x
 2
 3ARDUINO=$ARDUINO_HOME/arduino
 4SKETCH_NAME="EFUBoot.ino"
 5SKETCH="$PWD/$SKETCH_NAME"
 6BUILD_PATH="$PWD/build"
 7OUTPUT_PATH="./boot"
 8
 9if [[ "$OSTYPE" == "darwin"* ]]; then
10	ARDUINO="/Applications/Arduino.app/Contents/MacOS/Arduino"
11fi
12
13buildSDUBootSketch() {
14	BOARD=$1
15	DESTINATION=$2
16
17	$ARDUINO --verify --board $BOARD --preserve-temp-files --pref build.path="$BUILD_PATH" $SKETCH
18	cat "$BUILD_PATH/$SKETCH_NAME.bin" | xxd -i > $DESTINATION
19	rm -rf "$BUILD_PATH"
20}
21
22mkdir -p "$OUTPUT_PATH"
23
24buildSDUBootSketch "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.