@@ -83,14 +83,29 @@ void setup() {
8383 // use space from 15.5MB to 16 MB for another fw, memory mapped
8484 }
8585
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)) {
8896 Serial.println (" Error formatting WiFi partition" );
8997 return ;
9098 }
9199
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)) {
94109 Serial.println (" Error formatting OTA partition" );
95110 return ;
96111 }
@@ -107,8 +122,15 @@ void setup() {
107122 user_data_fs = new mbed::FATFileSystem (" user" );
108123 }
109124
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)) {
112134 Serial.println (" Error formatting user partition" );
113135 return ;
114136 }
0 commit comments