Skip to content

Commit 33b588f

Browse files
committed
FlashFormatter: add warning about sketch execution
1 parent 00c1d01 commit 33b588f

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

examples/flashFormatter/flashFormatter.ino

+52-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,59 @@ 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 check / format flash");
38+
} else {
39+
Serial.println("Flash checked / formatted successfully");
40+
}
2341
}
42+
else {
43+
Serial.println("Operation canceled");
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+
bool proceed = false;
54+
while (confirmation == false) {
55+
if (Serial.available()) {
56+
char choice = Serial.read();
57+
switch (choice) {
58+
case 'y':
59+
case 'Y':
60+
confirmation = true;
61+
proceed = true;
62+
break;
63+
case 'n':
64+
case 'N':
65+
confirmation = true;
66+
proceed = false;
67+
break;
68+
default:
69+
continue;
70+
}
71+
}
72+
}
73+
return proceed;
74+
}

0 commit comments

Comments
 (0)