@@ -103,14 +103,29 @@ void setup() {
103103 // use space from 15.5MB to 16 MB for another fw, memory mapped
104104 }
105105
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)) {
108116 Serial.println (" Error formatting WiFi partition" );
109117 return ;
110118 }
111119
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)) {
114129 Serial.println (" Error formatting OTA partition" );
115130 return ;
116131 }
@@ -127,8 +142,15 @@ void setup() {
127142 user_data_fs = new mbed::FATFileSystem (" user" );
128143 }
129144
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)) {
132154 Serial.println (" Error formatting user partition" );
133155 return ;
134156 }
0 commit comments