Skip to content

Commit 9b7a276

Browse files
authored
Merge pull request #220 from sandeepmistry/sdu-usage-example
Add SDU usage example
2 parents 91bee1d + c8b39d8 commit 9b7a276

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Usage
3+
This example demonstrates how to use the SAMD SDU library to update a
4+
sketch on an Arduino/Genuino Zero, MKRZero or MKR1000 board using an
5+
SD card. It prints out the date and time the sketch was compiled at
6+
to both Serial and Serial1.
7+
8+
Circuit:
9+
* Arduino MKRZero board with SD card
10+
OR
11+
* Arduino/Genuino Zero or MKR1000 board
12+
* SD shield or breakout connected with CS pin of 4
13+
* SD card
14+
15+
Non-Arduino/Genuino Zero, MKRZero or MKR1000 board are NOT supported.
16+
17+
Steps to update sketch via SD card:
18+
19+
1) Upload this sketch or another sketch that includes the SDU library
20+
via #include <SDU.h>
21+
22+
2) Update the sketch as desired. For this example the sketch prints out
23+
the compiled date and time so no updates are needed.
24+
25+
3) In the IDE select: Sketch -> Export compiled Binary
26+
27+
4) Copy the .bin file from the sketch's folder to the SD card and rename
28+
the file to UPDATE.bin. Eject the SD card from your PC.
29+
30+
5) Insert the SD card into the board, shield or breakout and press the
31+
reset button or power cycle the board. The SDU library will then update
32+
the sketch on the board with the contents of UPDATE.bin
33+
34+
created 23 March 2017
35+
by Sandeep Mistry
36+
*/
37+
38+
/*
39+
Include the SDU library
40+
41+
This will add some code to the sketch before setup() is called
42+
to check if an SD card is present and UPDATE.bin exists on the
43+
SD card.
44+
45+
If UPDATE.bin is present, the file is used to update the sketch
46+
running on the board. After this UPDATE.bin is deleted from the
47+
SD card.
48+
*/
49+
#include <SDU.h>
50+
51+
String message;
52+
53+
void setup() {
54+
Serial.begin(9600);
55+
Serial1.begin(9600);
56+
57+
// wait a bit
58+
delay(1000);
59+
60+
message += "Sketch compile date and time: ";
61+
message += __DATE__;
62+
message += " ";
63+
message += __TIME__;
64+
65+
// print out the sketch compile date and time on the serial port
66+
Serial.println(message);
67+
Serial1.println(message);
68+
}
69+
70+
void loop() {
71+
// add you own code here
72+
}
73+

0 commit comments

Comments
 (0)