diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-05-04 10:03:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-04 10:03:20 -0700 |
| commit | 3814e9701016a4ce0815b187f885fbcb15dfd065 (patch) | |
| tree | c6c1b0c1fb1e049f22df48467506891023781aaa /shared-bindings | |
| parent | ffc66e9892328a68d7f7f9ca4ad6cd7a67c16892 (diff) | |
| parent | 74a6edff4de212de11a435be12d19b5817ab8d2d (diff) | |
Merge pull request #802 from dhalbert/2.x-filesystem-work2.3.0
2.x: handle bad power on reset better
Diffstat (limited to 'shared-bindings')
| -rw-r--r-- | shared-bindings/storage/__init__.c | 20 | ||||
| -rw-r--r-- | shared-bindings/storage/__init__.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index ccf8ff511..b5086e352 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -115,12 +115,32 @@ mp_obj_t storage_remount(mp_obj_t mount_path, mp_obj_t readonly) { } MP_DEFINE_CONST_FUN_OBJ_2(storage_remount_obj, storage_remount); +//| .. function:: erase_filesystem() +//| +//| Erase and re-create the ``CIRCUITPY`` filesystem. Then call +//| `microcontroller.reset()` to restart CircuitPython and have the +//| host computer remount CIRCUITPY. +//| +//| This function can be called from the REPL when ``CIRCUITPY`` +//| has become corrupted. +//| +//| .. warning:: All the data on ``CIRCUITPY`` will be lost, and +//| CircuitPython will restart. + +mp_obj_t storage_erase_filesystem(void) { + common_hal_storage_erase_filesystem(); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(storage_erase_filesystem_obj, storage_erase_filesystem); + + STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_storage) }, { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) }, { MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) }, { MP_ROM_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) }, + { MP_ROM_QSTR(MP_QSTR_erase_filesystem), MP_ROM_PTR(&storage_erase_filesystem_obj) }, //| .. class:: VfsFat(block_device) //| diff --git a/shared-bindings/storage/__init__.h b/shared-bindings/storage/__init__.h index 574b5ff8d..fe78696a6 100644 --- a/shared-bindings/storage/__init__.h +++ b/shared-bindings/storage/__init__.h @@ -34,5 +34,6 @@ void common_hal_storage_mount(mp_obj_t vfs_obj, const char* path, bool readonly) void common_hal_storage_umount_path(const char* path); void common_hal_storage_umount_object(mp_obj_t vfs_obj); void common_hal_storage_remount(const char* path, bool readonly); +void common_hal_storage_erase_filesystem(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H |
