@@ -67,14 +67,29 @@ void setup() {
67
67
MBRBlockDevice::partition (root, 4 , 0x0B , 7 * 1024 * 1024 , 14 * 1024 * 1024 );
68
68
// use space from 15.5MB to 16 MB for another fw, memory mapped
69
69
70
- int err = wifi_data_fs.reformat (&wifi_data);
71
- if (err) {
70
+ bool reformat = true ;
71
+
72
+ if (!wifi_data_fs.mount (&wifi_data)) {
73
+ Serial.println (" \n Partition 1 already contains a filesystem, do you want to reformat it? Y/[n]" );
74
+ wifi_data_fs.unmount ();
75
+
76
+ reformat = waitResponse ();
77
+ }
78
+
79
+ if (reformat && wifi_data_fs.reformat (&wifi_data)) {
72
80
Serial.println (" Error formatting WiFi partition" );
73
81
return ;
74
82
}
75
83
76
- err = ota_data_fs.reformat (&ota_data);
77
- if (err) {
84
+ reformat = true ;
85
+ if (!ota_data_fs.mount (&ota_data)) {
86
+ Serial.println (" \n Partition 2 already contains a filesystem, do you want to reformat it? Y/[n]" );
87
+ ota_data_fs.unmount ();
88
+
89
+ reformat = waitResponse ();
90
+ }
91
+
92
+ if (reformat && ota_data_fs.reformat (&ota_data)) {
78
93
Serial.println (" Error formatting OTA partition" );
79
94
return ;
80
95
}
@@ -90,11 +105,19 @@ void setup() {
90
105
user_data_fs = new mbed::FATFileSystem (" user" );
91
106
}
92
107
93
- err = user_data_fs->reformat (&user_data);
94
- if (err) {
108
+ reformat = true ;
109
+ if (!user_data_fs->mount (&user_data)) {
110
+ Serial.println (" \n Partition 4 already contains a filesystem, do you want to reformat it? Y/[n]" );
111
+ user_data_fs->unmount ();
112
+
113
+ reformat = waitResponse ();
114
+ }
115
+
116
+ if (reformat && user_data_fs->reformat (&user_data)) {
95
117
Serial.println (" Error formatting user partition" );
96
118
return ;
97
119
}
120
+
98
121
Serial.println (" \n QSPI Flash formatted!" );
99
122
}
100
123
0 commit comments