Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aggressive reinit of filesystem #523

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/provisioning/tinyusb/Wippersnapper_FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Wippersnapper_FS::Wippersnapper_FS() {

// If a filesystem does not already exist - attempt to initialize a new
// filesystem
if (!initFilesystem()) {
if (!initFilesystem() && !initFilesystem(true)) {
WS_DEBUG_PRINTLN("ERROR Initializing Filesystem");
setStatusLEDColor(RED);
while (1)
Expand Down Expand Up @@ -123,13 +123,13 @@ Wippersnapper_FS::~Wippersnapper_FS() {}
@return True if filesystem initialized correctly, false otherwise.
*/
/**************************************************************************/
bool Wippersnapper_FS::initFilesystem() {
bool Wippersnapper_FS::initFilesystem(bool force_format) {
// Init. flash library
if (!flash.begin())
return false;

// Check if FS exists
if (!wipperFatFs.begin(&flash)) {
if (force_format || !wipperFatFs.begin(&flash)) {
// No filesystem exists - create a new FS
// NOTE: THIS WILL ERASE ALL DATA ON THE FLASH
if (!makeFilesystem())
Expand Down Expand Up @@ -589,4 +589,4 @@ DRESULT disk_ioctl(BYTE pdrv, /* Physical drive nmuber (0..) */
}
}

#endif // USE_TINYUSB
#endif // USE_TINYUSB
2 changes: 1 addition & 1 deletion src/provisioning/tinyusb/Wippersnapper_FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Wippersnapper_FS {
Wippersnapper_FS();
~Wippersnapper_FS();

bool initFilesystem();
bool initFilesystem(bool force_format = false);
void initUSBMSC();

void eraseCPFS();
Expand Down
Loading