go into safe mode if not CIRCUITPY available
This commit is contained in:
parent
ea638c0401
commit
41d494df0b
|
@ -659,6 +659,10 @@ msgstr ""
|
|||
msgid "CBC blocks must be multiples of 16 bytes"
|
||||
msgstr ""
|
||||
|
||||
#: supervisor/shared/safe_mode.c
|
||||
msgid "CIRCUITPY drive could not be found or created."
|
||||
msgstr ""
|
||||
|
||||
#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c
|
||||
msgid "CRC or checksum was invalid"
|
||||
msgstr ""
|
||||
|
|
6
main.c
6
main.c
|
@ -811,7 +811,11 @@ int __attribute__((used)) main(void) {
|
|||
// Create a new filesystem only if we're not in a safe mode.
|
||||
// A power brownout here could make it appear as if there's
|
||||
// no SPI flash filesystem, and we might erase the existing one.
|
||||
filesystem_init(safe_mode == NO_SAFE_MODE, false);
|
||||
|
||||
// Check whether CIRCUITPY is available. Don't check if it already hasn't been found.
|
||||
if (safe_mode != NO_CIRCUITPY && !filesystem_init(safe_mode == NO_SAFE_MODE, false)) {
|
||||
reset_into_safe_mode(NO_CIRCUITPY);
|
||||
}
|
||||
|
||||
// displays init after filesystem, since they could share the flash SPI
|
||||
board_init();
|
||||
|
|
|
@ -271,7 +271,7 @@ void common_hal_storage_erase_filesystem(void) {
|
|||
usb_disconnect();
|
||||
#endif
|
||||
mp_hal_delay_ms(1000);
|
||||
filesystem_init(false, true); // Force a re-format.
|
||||
(void)filesystem_init(false, true); // Force a re-format. Ignore failure.
|
||||
common_hal_mcu_reset();
|
||||
// We won't actually get here, since we're resetting.
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ extern volatile bool filesystem_flush_requested;
|
|||
|
||||
void filesystem_background(void);
|
||||
void filesystem_tick(void);
|
||||
void filesystem_init(bool create_allowed, bool force_create);
|
||||
bool filesystem_init(bool create_allowed, bool force_create);
|
||||
void filesystem_flush(void);
|
||||
bool filesystem_present(void);
|
||||
void filesystem_set_internal_writable_by_usb(bool usb_writable);
|
||||
|
|
|
@ -86,7 +86,7 @@ static void make_sample_code_file(FATFS *fatfs) {
|
|||
|
||||
// we don't make this function static because it needs a lot of stack and we
|
||||
// want it to be executed without using stack within main() function
|
||||
void filesystem_init(bool create_allowed, bool force_create) {
|
||||
bool filesystem_init(bool create_allowed, bool force_create) {
|
||||
// init the vfs object
|
||||
fs_user_mount_t *vfs_fat = &_internal_vfs;
|
||||
vfs_fat->blockdev.flags = 0;
|
||||
|
@ -102,11 +102,11 @@ void filesystem_init(bool create_allowed, bool force_create) {
|
|||
formats |= FM_EXFAT | FM_FAT32;
|
||||
#endif
|
||||
res = f_mkfs(&vfs_fat->fatfs, formats, 0, working_buf, sizeof(working_buf));
|
||||
if (res != FR_OK) {
|
||||
return false;
|
||||
}
|
||||
// Flush the new file system to make sure it's repaired immediately.
|
||||
supervisor_flash_flush();
|
||||
if (res != FR_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set label
|
||||
#ifdef CIRCUITPY_DRIVE_LABEL
|
||||
|
@ -115,13 +115,13 @@ void filesystem_init(bool create_allowed, bool force_create) {
|
|||
res = f_setlabel(&vfs_fat->fatfs, "CIRCUITPY");
|
||||
#endif
|
||||
if (res != FR_OK) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// inhibit file indexing on MacOS
|
||||
res = f_mkdir(&vfs_fat->fatfs, "/.fseventsd");
|
||||
if (res != FR_OK) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
make_empty_file(&vfs_fat->fatfs, "/.metadata_never_index");
|
||||
make_empty_file(&vfs_fat->fatfs, "/.Trashes");
|
||||
|
@ -132,13 +132,13 @@ void filesystem_init(bool create_allowed, bool force_create) {
|
|||
// create empty lib directory
|
||||
res = f_mkdir(&vfs_fat->fatfs, "/lib");
|
||||
if (res != FR_OK) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// and ensure everything is flushed
|
||||
supervisor_flash_flush();
|
||||
} else if (res != FR_OK) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
mp_vfs_mount_t *vfs = &_mp_vfs;
|
||||
vfs->str = "/";
|
||||
|
@ -150,6 +150,8 @@ void filesystem_init(bool create_allowed, bool force_create) {
|
|||
// The current directory is used as the boot up directory.
|
||||
// It is set to the internal flash filesystem by default.
|
||||
MP_STATE_PORT(vfs_cur) = vfs;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void filesystem_flush(void) {
|
||||
|
|
|
@ -175,6 +175,8 @@ void print_safe_mode_message(safe_mode_t reason) {
|
|||
case WATCHDOG_RESET:
|
||||
message = translate("Watchdog timer expired.");
|
||||
break;
|
||||
case NO_CIRCUITPY:
|
||||
message = translate("CIRCUITPY drive could not be found or created.");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ typedef enum {
|
|||
USB_TOO_MANY_INTERFACE_NAMES,
|
||||
USB_BOOT_DEVICE_NOT_INTERFACE_ZERO,
|
||||
NO_HEAP,
|
||||
NO_CIRCUITPY,
|
||||
} safe_mode_t;
|
||||
|
||||
safe_mode_t wait_for_safe_mode_reset(void);
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
|
||||
#include "supervisor/filesystem.h"
|
||||
|
||||
void filesystem_init(bool create_allowed, bool force_create) {
|
||||
bool filesystem_init(bool create_allowed, bool force_create) {
|
||||
(void)create_allowed;
|
||||
(void)force_create;
|
||||
return true;
|
||||
}
|
||||
|
||||
void filesystem_flush(void) {
|
||||
|
|
Loading…
Reference in New Issue