@@ -103,14 +103,29 @@ void setup() {
103
103
// use space from 15.5MB to 16 MB for another fw, memory mapped
104
104
}
105
105
106
- int err = wifi_data_fs.reformat (&wifi_data);
107
- if (err) {
106
+ bool reformat = true ;
107
+
108
+ if (!wifi_data_fs.mount (&wifi_data)) {
109
+ Serial.println (" \n Partition 1 already contains a filesystem, do you want to reformat it? Y/[n]" );
110
+ wifi_data_fs.unmount ();
111
+
112
+ reformat = waitResponse ();
113
+ }
114
+
115
+ if (reformat && wifi_data_fs.reformat (&wifi_data)) {
108
116
Serial.println (" Error formatting WiFi partition" );
109
117
return ;
110
118
}
111
119
112
- err = ota_data_fs.reformat (&ota_data);
113
- if (err) {
120
+ reformat = true ;
121
+ if (!ota_data_fs.mount (&ota_data)) {
122
+ Serial.println (" \n Partition 2 already contains a filesystem, do you want to reformat it? Y/[n]" );
123
+ ota_data_fs.unmount ();
124
+
125
+ reformat = waitResponse ();
126
+ }
127
+
128
+ if (reformat && ota_data_fs.reformat (&ota_data)) {
114
129
Serial.println (" Error formatting OTA partition" );
115
130
return ;
116
131
}
@@ -127,8 +142,15 @@ void setup() {
127
142
user_data_fs = new mbed::FATFileSystem (" user" );
128
143
}
129
144
130
- err = user_data_fs->reformat (&user_data);
131
- if (err) {
145
+ reformat = true ;
146
+ if (!user_data_fs->mount (&user_data)) {
147
+ Serial.println (" \n Partition 3 already contains a filesystem, do you want to reformat it? Y/[n]" );
148
+ user_data_fs->unmount ();
149
+
150
+ reformat = waitResponse ();
151
+ }
152
+
153
+ if (reformat && user_data_fs->reformat (&user_data)) {
132
154
Serial.println (" Error formatting user partition" );
133
155
return ;
134
156
}
0 commit comments