storage.erase_filesystem(): unmount and wait 1 second before resetting
This commit is contained in:
parent
8abf8c2c50
commit
65c22aa434
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "extmod/vfs.h"
|
||||
#include "py/mperrno.h"
|
||||
#include "py/mphal.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
|
@ -159,6 +160,8 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa
|
|||
}
|
||||
|
||||
void common_hal_storage_erase_filesystem(void) {
|
||||
usb_disconnect();
|
||||
mp_hal_delay_ms(1000);
|
||||
filesystem_init(false, true); // Force a re-format.
|
||||
common_hal_mcu_reset();
|
||||
// We won't actually get here, since we're resetting.
|
||||
|
|
|
@ -73,6 +73,10 @@ void usb_init(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void usb_disconnect(void) {
|
||||
tud_disconnect();
|
||||
}
|
||||
|
||||
void usb_background(void) {
|
||||
if (usb_enabled()) {
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
|
|
|
@ -40,6 +40,7 @@ void init_usb_hardware(void);
|
|||
// Shared implementation.
|
||||
bool usb_enabled(void);
|
||||
void usb_init(void);
|
||||
void usb_disconnect(void);
|
||||
|
||||
// Propagate plug/unplug events to the MSC logic.
|
||||
void usb_msc_mount(void);
|
||||
|
|
Loading…
Reference in New Issue