Create fresh filesystem contents for Nano RP2040.

This commit is contained in:
iabdalkader 2022-01-03 18:45:54 +02:00
parent 165d3ac712
commit a0504eda90

View File

@ -68,6 +68,12 @@
#include "py_audio.h"
#endif
#if MICROPY_VFS_FAT && MICROPY_HW_USB_MSC
#include "extmod/vfs.h"
#include "extmod/vfs_fat.h"
#include "common/factoryreset.h"
#endif
extern uint8_t __StackTop, __StackBottom;
static char OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(gc_heap[OMV_HEAP_SIZE], 4), ".heap");
@ -128,7 +134,6 @@ void exec_boot_script(const char *path, bool interruptible)
}
}
int main(int argc, char **argv) {
bool first_soft_reset = true;
@ -204,9 +209,17 @@ soft_reset:
}
#endif
// Execute _boot.py to set up the filesystem.
#if MICROPY_VFS_FAT && MICROPY_HW_USB_MSC
pyexec_frozen_module("_boot_fat.py", false);
// Mount or create a fresh filesystem.
mp_obj_t mount_point = MP_OBJ_NEW_QSTR(MP_QSTR__slash_);
mp_obj_t bdev = rp2_flash_type.make_new(&rp2_flash_type, 0, 0, NULL);
if (mp_vfs_mount_and_chdir_protected(bdev, mount_point) == -MP_ENODEV) {
// Create a fresh filesystem.
fs_user_mount_t *vfs = mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &bdev);
if (factoryreset_create_filesystem(vfs) == 0) {
mp_vfs_mount_and_chdir_protected(bdev, mount_point);
}
}
#else
pyexec_frozen_module("_boot.py", false);
#endif