Skip to content

add storage.erase_filesystem() to erase and reformat CIRCUITPY #747

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

Merged
merged 10 commits into from
Apr 10, 2018
Merged
Prev Previous commit
Next Next commit
esp8266 and nrf: raise NotImplementedError
  • Loading branch information
dhalbert committed Apr 10, 2018
commit 5f98953ed89f5e89b92f500788ae4ff0806886c8
8 changes: 8 additions & 0 deletions ports/atmel-samd/common-hal/storage/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
#include "flash_api.h"
#include "py/mperrno.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/storage/__init__.h"
#include "supervisor/filesystem.h"
#include "usb.h"

extern volatile bool mp_msc_enabled;
Expand All @@ -47,3 +49,9 @@ void common_hal_storage_remount(const char* mount_path, bool readonly) {

flash_set_usb_writable(readonly);
}

void common_hal_storage_erase_filesystem(void) {
filesystem_init(false, true); // Force a re-format.
common_hal_mcu_reset();
// We won't actually get here, since we're resetting.
}
7 changes: 7 additions & 0 deletions ports/esp8266/common-hal/storage/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@

#include <string.h>

#include "lib/oofatfs/ff.h"
#include "lib/oofatfs/diskio.h"
#include "py/mperrno.h"
#include "py/runtime.h"
#include "shared-bindings/storage/__init__.h"

void common_hal_storage_remount(const char* mount_path, bool readonly) {
mp_raise_NotImplementedError("");
}

void common_hal_storage_erase_filesystem() {
mp_raise_NotImplementedError("Use esptool to erase flash and re-upload Python instead");
}
4 changes: 4 additions & 0 deletions ports/nrf/common-hal/storage/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ void common_hal_storage_remount(const char* mount_path, bool readonly) {
mp_raise_OSError(MP_EINVAL);
}
}

void common_hal_storage_erase_filesystem() {
mp_raise_NotImplementedError("");
}
8 changes: 5 additions & 3 deletions shared-bindings/storage/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,17 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount);

//| .. function:: erase_filesystem()
//|
//| Erase and re-create the ``CIRCUITPY`` filesystem. Then call
//| `microcontroller.reset()` to restart CircuitPython and have the
//| Erase and re-create the ``CIRCUITPY`` filesystem.
//|
//| On boards that present USB-visible ``CIRCUITPY`` drive (e.g., SAMD21 and SAMD51),
//| 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.
//| CircuitPython will restart on certain boards.

mp_obj_t storage_erase_filesystem(void) {
common_hal_storage_erase_filesystem();
Expand Down
6 changes: 0 additions & 6 deletions shared-module/storage/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,3 @@ void common_hal_storage_umount_path(const char* mount_path) {
mp_obj_t common_hal_storage_getmount(const char *mount_path) {
return storage_object_from_path(mount_path);
}

void common_hal_storage_erase_filesystem(void) {
filesystem_init(false, true); // Force a re-format.
common_hal_mcu_reset();
// We won't actually get here, since we're resetting.
}
2 changes: 1 addition & 1 deletion supervisor/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <stdbool.h>

void filesystem_init(bool create_allowed, bool create_force);
void filesystem_init(bool create_allowed, bool force_create);
void filesystem_flush(void);
void filesystem_writable_by_python(bool writable);
bool filesystem_present(void);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy