@@ -83,14 +83,29 @@ void setup() {
83
83
// use space from 15.5MB to 16 MB for another fw, memory mapped
84
84
}
85
85
86
- int err = wifi_data_fs.reformat (&wifi_data);
87
- if (err) {
86
+ bool reformat = true ;
87
+
88
+ if (!wifi_data_fs.mount (&wifi_data)) {
89
+ Serial.println (" \n Partition 1 already contains a filesystem, do you want to reformat it? Y/[n]" );
90
+ wifi_data_fs.unmount ();
91
+
92
+ reformat = waitResponse ();
93
+ }
94
+
95
+ if (reformat && wifi_data_fs.reformat (&wifi_data)) {
88
96
Serial.println (" Error formatting WiFi partition" );
89
97
return ;
90
98
}
91
99
92
- err = ota_data_fs.reformat (&ota_data);
93
- if (err) {
100
+ reformat = true ;
101
+ if (!ota_data_fs.mount (&ota_data)) {
102
+ Serial.println (" \n Partition 2 already contains a filesystem, do you want to reformat it? Y/[n]" );
103
+ ota_data_fs.unmount ();
104
+
105
+ reformat = waitResponse ();
106
+ }
107
+
108
+ if (reformat && ota_data_fs.reformat (&ota_data)) {
94
109
Serial.println (" Error formatting OTA partition" );
95
110
return ;
96
111
}
@@ -107,8 +122,15 @@ void setup() {
107
122
user_data_fs = new mbed::FATFileSystem (" user" );
108
123
}
109
124
110
- err = user_data_fs->reformat (&user_data);
111
- if (err) {
125
+ reformat = true ;
126
+ if (!user_data_fs->mount (&user_data)) {
127
+ Serial.println (" \n Partition 3 already contains a filesystem, do you want to reformat it? Y/[n]" );
128
+ user_data_fs->unmount ();
129
+
130
+ reformat = waitResponse ();
131
+ }
132
+
133
+ if (reformat && user_data_fs->reformat (&user_data)) {
112
134
Serial.println (" Error formatting user partition" );
113
135
return ;
114
136
}
0 commit comments