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)
193193 _lfs_cfg.lookahead = 128 ;
194194
195195 _begun = false ;
196+ _mounted = false ;
196197}
197198
198199LittleFS::~LittleFS ()
@@ -212,6 +213,8 @@ bool LittleFS::begin (void)
212213 {
213214 LOG_LV1 (" IFLASH" , " Format internal file system" );
214215 this ->format (false );
216+ } else {
217+ _mounted = true ;
215218 }
216219
217220 return true ;
@@ -226,10 +229,14 @@ bool LittleFS::format (bool eraseall)
226229 flash_nrf5x_erase (addr);
227230 }
228231 }
229-
232+ if (_mounted) {
233+ VERIFY_LFS (lfs_unmount (&_lfs), false );
234+ }
230235 VERIFY_LFS (lfs_format (&_lfs, &_lfs_cfg), false );
231236 VERIFY_LFS (lfs_mount (&_lfs, &_lfs_cfg), false );
232237
238+ _mounted = true ;
239+
233240 return true ;
234241}
235242
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ class LittleFS: public BluefruitFS::FileSystemClass
7474 struct lfs_config _lfs_cfg;
7575 lfs_t _lfs;
7676 bool _begun;
77+ bool _mounted;
7778
7879 BluefruitFS::File _open_file (char const *filepath, uint8_t mode);
7980 BluefruitFS::File _open_dir (char const *filepath);
You can’t perform that action at this time.
0 commit comments