@@ -131,13 +131,32 @@ mp_obj_t storage_getmount(const mp_obj_t mnt_in) {
131131}
132132MP_DEFINE_CONST_FUN_OBJ_1 (storage_getmount_obj , storage_getmount );
133133
134+ //| .. function:: erase_filesystem()
135+ //|
136+ //| Erase and re-create the ``CIRCUITPY`` filesystem. Then call
137+ //| `microcontroller.reset()` to restart CircuitPython and have the
138+ //| host computer remount CIRCUITPY.
139+ //|
140+ //| This function can be called from the REPL when ``CIRCUITPY``
141+ //| has become corrupted.
142+ //|
143+ //| .. warning:: All the data on ``CIRCUITPY`` will be lost, and
144+ //| CircuitPython will restart.
145+
146+ mp_obj_t storage_erase_filesystem (void ) {
147+ common_hal_storage_erase_filesystem ();
148+ return mp_const_none ;
149+ }
150+ MP_DEFINE_CONST_FUN_OBJ_0 (storage_erase_filesystem_obj , storage_erase_filesystem );
151+
134152STATIC const mp_rom_map_elem_t storage_module_globals_table [] = {
135153 { MP_ROM_QSTR (MP_QSTR___name__ ), MP_ROM_QSTR (MP_QSTR_storage ) },
136154
137155 { MP_ROM_QSTR (MP_QSTR_mount ), MP_ROM_PTR (& storage_mount_obj ) },
138156 { MP_ROM_QSTR (MP_QSTR_umount ), MP_ROM_PTR (& storage_umount_obj ) },
139157 { MP_ROM_QSTR (MP_QSTR_remount ), MP_ROM_PTR (& storage_remount_obj ) },
140158 { MP_ROM_QSTR (MP_QSTR_getmount ), MP_ROM_PTR (& storage_getmount_obj ) },
159+ { MP_ROM_QSTR (MP_QSTR_erase_filesystem ), MP_ROM_PTR (& storage_erase_filesystem_obj ) },
141160
142161 //| .. class:: VfsFat(block_device)
143162 //|
0 commit comments