Merge pull request #238 from jeremypoulter/littlefs_format_fix

Unmount the FS before formatting
This commit is contained in:
hathach authored and GitHub committed 2019-03-11 19:52:54 -07:00
commit 4bd0913073
2 files changed
+9 -1

No files matched your search

+8 -1
View File
@@ -193,6 +193,7 @@ LittleFS::LittleFS (void)
_lfs_cfg.lookahead = 128;
_begun = false;
_mounted = false;
}
LittleFS::~LittleFS ()
@@ -212,6 +213,8 @@ bool LittleFS::begin (void)
{
LOG_LV1("IFLASH", "Format internal file system");
this->format(false);
} else {
_mounted = true;
}
return true;
@@ -226,10 +229,14 @@ bool LittleFS::format (bool eraseall)
flash_nrf5x_erase(addr);
}
}
if(_mounted) {
VERIFY_LFS(lfs_unmount(&_lfs), false);
}
VERIFY_LFS(lfs_format(&_lfs, &_lfs_cfg), false);
VERIFY_LFS(lfs_mount(&_lfs, &_lfs_cfg), false);
_mounted = true;
return true;
}
+1
View File
@@ -74,6 +74,7 @@ class LittleFS: public BluefruitFS::FileSystemClass
struct lfs_config _lfs_cfg;
lfs_t _lfs;
bool _begun;
bool _mounted;
BluefruitFS::File _open_file (char const *filepath, uint8_t mode);
BluefruitFS::File _open_dir (char const *filepath);