File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,7 @@ LittleFS::LittleFS (void)
193
193
_lfs_cfg.lookahead = 128 ;
194
194
195
195
_begun = false ;
196
+ _mounted = false ;
196
197
}
197
198
198
199
LittleFS::~LittleFS ()
@@ -212,6 +213,8 @@ bool LittleFS::begin (void)
212
213
{
213
214
LOG_LV1 (" IFLASH" , " Format internal file system" );
214
215
this ->format (false );
216
+ } else {
217
+ _mounted = true ;
215
218
}
216
219
217
220
return true ;
@@ -226,10 +229,14 @@ bool LittleFS::format (bool eraseall)
226
229
flash_nrf5x_erase (addr);
227
230
}
228
231
}
229
-
232
+ if (_mounted) {
233
+ VERIFY_LFS (lfs_unmount (&_lfs), false );
234
+ }
230
235
VERIFY_LFS (lfs_format (&_lfs, &_lfs_cfg), false );
231
236
VERIFY_LFS (lfs_mount (&_lfs, &_lfs_cfg), false );
232
237
238
+ _mounted = true ;
239
+
233
240
return true ;
234
241
}
235
242
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ class LittleFS: public BluefruitFS::FileSystemClass
74
74
struct lfs_config _lfs_cfg;
75
75
lfs_t _lfs;
76
76
bool _begun;
77
+ bool _mounted;
77
78
78
79
BluefruitFS::File _open_file (char const *filepath, uint8_t mode);
79
80
BluefruitFS::File _open_dir (char const *filepath);
You can’t perform that action at this time.
0 commit comments