diff --git a/src/FlashErase.cpp b/src/FlashErase.cpp index 0141f3d..54b5d17 100644 --- a/src/FlashErase.cpp +++ b/src/FlashErase.cpp @@ -10,8 +10,6 @@ // function to erase the flash void doErase(mbed::BlockDevice &bd, mbed::FileSystem &fs) { - // Try to unmount the filesystem - unmountFilesystem(bd, fs); printf("Initializing the block device... "); fflush(stdout); int err = bd.init(); diff --git a/src/MyUSBMSD.cpp b/src/MyUSBMSD.cpp index 6ad0aec..51e026a 100644 --- a/src/MyUSBMSD.cpp +++ b/src/MyUSBMSD.cpp @@ -27,8 +27,6 @@ } void doUSBMSD(mbed::BlockDevice &bd, mbed::FileSystem &fs) { - // Try to unmount the filesystem - unmountFilesystem(bd, fs); printf("Switching to the usb mass storage mode...\n"); MyUSBMSD usb(&bd, true, 0x1209, 0x10); @@ -40,7 +38,6 @@ "device...\n"); usb.disconnect(); printf("Switched usb mass storage mode off.\n"); - mountFilesystem(bd, fs); break; } } diff --git a/src/main.cpp b/src/main.cpp index 2c834bb..0645e07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,8 @@ while (true) { int presses = waitForPresses(600s); + unmountFilesystem(mainBD, mainFS); + if (presses == 1) { doUSBMSD(mainBD, mainFS); } @@ -29,6 +31,8 @@ if (presses == 2) { doErase(mainBD, mainFS); } + + mountFilesystem(mainBD, mainFS); } buttonThread.terminate();