SD Sketch Update
How to use the new Arduino SDU library for SAMD boards to update the sketch on your board, putting it on an SD!
Components and Supplies
Apps and Online Services
About This Project
SD Update
Executing an SD update using the SAMD SDU (Secure Digital Update) library is very easy! You simply have to include the SDU library with your sketch to gain access to this very cool feature.
The library includes the routine. This routine starts when the boards boot and search for a file on the SD called UPDATE.bin. If file is found, the current sketch on the board will be overwritten with the new one.
What Do You Need?
- Arduino MKRZero
- SD card
or
- Arduino/Genuino MKR1000
- MKR SD Proto Shield
- SD card
or
- Arduino MKRFox1200
- MKR SD Proto Shield
- SD card
Example
- First of all, open the blink example under File->Examples->01.Basics->Blink and modify it to include the OTA library like shown below.
1#include <SDU.h> 2// the setup function runs once when you press reset or power the board 3void setup() { 4 // initialize digital pin LED_BUILTIN as an output. 5 pinMode(LED_BUILTIN, OUTPUT); 6} 7// the loop function runs over and over again forever 8void loop() { 9 digitalWrite(LED_BUILTIN, HIGH); // turn the LED ON10 delay(1000); // wait for a second 11 digitalWrite(LED_BUILTIN, LOW); // turn the LED OFF12 delay(1000); // wait for a second
- Upload it on the board
- Now modify the Blink code to have a faster LED in this way
1#include <SDU.h> 2// the setup function runs once when you press reset or power the board 3void setup() { 4 // initialize digital pin LED_BUILTIN as an output. 5 pinMode(LED_BUILTIN, OUTPUT); 6} 7// the loop function runs over and over again forever 8void loop() { 9 digitalWrite(LED_BUILTIN, HIGH); // turn the LED ON10 delay(250); // wait for a second 11 digitalWrite(LED_BUILTIN, LOW); // turn the LED OFF12 delay(250); // wait for a second 13}
- Export the binary by clicking on Sketch->Export compiled Binary
- Go in the folder you chose to save your sketch and rename the .bin file in UPDATE.bin
- Put this file on the SD card and then insert it in the MKRZero or the MKR SD ProtoShield
- Reset the board
You should now see the BUILTIN_LED that blinks faster so your sketch has been updated!
Suggest changes
The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.
License
The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.