Skip to content

Commit 628fba2

Browse files
committed
FlashFormatter: add warning about sketch execution
1 parent 00c1d01 commit 628fba2

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

examples/flashFormatter/flashFormatter.ino

+50-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,57 @@ void setup() {
1616
Serial.begin(9600);
1717
while(!Serial);
1818

19-
if(!flashFormatter.checkandFormatPartition()){
20-
Serial.println("Failed to format partition");
21-
} else {
22-
Serial.println("Partition formatted successfully");
19+
/* WARNING! Running this sketch all the content of the QSPI flash may be erased.
20+
* The sketch will check if the QSPI flash is formatted with an ArduinoCloud
21+
* compatible partitioning. Otherwise, it will format the QSPI flash with the
22+
* default scheme.
23+
*
24+
* If you want to keep the content of the QSPI flash, do not run this sketch.
25+
*
26+
* ArduinoCloud compatible partitioning consist of:
27+
* - 1st partition: WiFi firmware and certificates
28+
* - 2nd partition: OTA data. Minimum size 5MB.
29+
* - 3rd partition: Key Value Store data. Minimum size 1MB.
30+
*/
31+
32+
Serial.println("\nWARNING! Running this sketch all the content of the QSPI flash may be erased.");
33+
Serial.println("Do you want to proceed? Y/[n]");
34+
35+
if (true == waitResponse()) {
36+
if(!flashFormatter.checkandFormatPartition()){
37+
Serial.println("Failed to format partition");
38+
} else {
39+
Serial.println("Partition formatted successfully");
40+
}
2341
}
42+
else {
43+
Serial.println("Operation cancelled");
44+
}
45+
46+
Serial.println("It's now safe to reboot or disconnect your board.");
2447
}
2548

2649
void loop() { }
50+
51+
bool waitResponse() {
52+
bool confirmation = false;
53+
while (confirmation == false) {
54+
if (Serial.available()) {
55+
char choice = Serial.read();
56+
switch (choice) {
57+
case 'y':
58+
case 'Y':
59+
confirmation = true;
60+
return true;
61+
break;
62+
case 'n':
63+
case 'N':
64+
confirmation = true;
65+
return false;
66+
break;
67+
default:
68+
continue;
69+
}
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)