@@ -174,18 +174,18 @@ bool FileSystemSPIFFS::start()
174174
175175#ifdef ESP_PLATFORM
176176 esp_vfs_spiffs_conf_t conf = {
177- .base_path = _basepath,
178- .partition_label = " storage" ,
179- .max_files = 10 , // from SPIFFS.h
180- .format_if_mount_failed = false
177+ .base_path = _basepath,
178+ .partition_label = " storage" ,
179+ .max_files = 10 , // from SPIFFS.h
180+ .format_if_mount_failed = false
181181 };
182182
183183 esp_err_t e = esp_vfs_spiffs_register (&conf);
184184
185185 if (e != ESP_OK)
186186 {
187187 Debug_printf (" Failed to mount SPIFFS partition, err = %d\r\n " , e);
188- _started = false ;
188+ // _started = false;
189189 }
190190 else
191191#endif // ESP_PLATFORM
@@ -204,4 +204,33 @@ bool FileSystemSPIFFS::start()
204204 return _started;
205205}
206206
207+ bool FileSystemSPIFFS::stop ()
208+ {
209+ if (!_started)
210+ return true ;
211+
212+ #ifdef ESP_PLATFORM
213+ esp_err_t e = esp_vfs_spiffs_unregister (" storage" );
214+
215+ if (e != ESP_OK)
216+ {
217+ Debug_printf (" Failed to unmount SPIFFS partition, err = %d\r\n " , e);
218+ }
219+ else
220+ #endif // ESP_PLATFORM
221+ {
222+ _started = false ;
223+ Debug_println (" SPIFFS unmounted." );
224+ #ifdef DEBUG
225+ /*
226+ size_t total = 0, used = 0;
227+ esp_spiffs_info(NULL, &total, &used);
228+ Debug_printf(" partition size: %u, used: %u, free: %u\r\n", total, used, total-used);
229+ */
230+ #endif
231+ }
232+
233+ return !_started;
234+ }
235+
207236#endif // FLASH_SPIFFS
0 commit comments