diff options
Diffstat (limited to 'ports/zephyr/main.c')
-rw-r--r-- | ports/zephyr/main.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/ports/zephyr/main.c b/ports/zephyr/main.c index 45af7b0c72..eaef34a786 100644 --- a/ports/zephyr/main.c +++ b/ports/zephyr/main.c @@ -99,6 +99,7 @@ static void vfs_init(void) { mp_obj_t bdev = NULL; mp_obj_t mount_point; const char *mount_point_str = NULL; + qstr path_lib_qstr = MP_QSTRnull; int ret = 0; #ifdef CONFIG_DISK_DRIVER_SDMMC @@ -109,15 +110,18 @@ static void vfs_init(void) { #endif bdev = MP_OBJ_TYPE_GET_SLOT(&zephyr_disk_access_type, make_new)(&zephyr_disk_access_type, ARRAY_SIZE(args), 0, args); mount_point_str = "/sd"; + path_lib_qstr = MP_QSTR__slash_sd_slash_lib; #elif defined(CONFIG_FLASH_MAP) && FIXED_PARTITION_EXISTS(storage_partition) mp_obj_t args[] = { MP_OBJ_NEW_SMALL_INT(FIXED_PARTITION_ID(storage_partition)), MP_OBJ_NEW_SMALL_INT(4096) }; bdev = MP_OBJ_TYPE_GET_SLOT(&zephyr_flash_area_type, make_new)(&zephyr_flash_area_type, ARRAY_SIZE(args), 0, args); mount_point_str = "/flash"; + path_lib_qstr = MP_QSTR__slash_flash_slash_lib; #endif if ((bdev != NULL)) { mount_point = mp_obj_new_str_from_cstr(mount_point_str); ret = mp_vfs_mount_and_chdir_protected(bdev, mount_point); + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(path_lib_qstr)); // TODO: if this failed, make a new file system and try to mount again } } @@ -156,7 +160,17 @@ soft_reset: #endif #if MICROPY_MODULE_FROZEN || MICROPY_VFS - pyexec_file_if_exists("main.py"); + // Execute user scripts. + int ret = pyexec_file_if_exists("boot.py"); + if (ret & PYEXEC_FORCED_EXIT) { + goto soft_reset_exit; + } + if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL && ret != 0) { + ret = pyexec_file_if_exists("main.py"); + if (ret & PYEXEC_FORCED_EXIT) { + goto soft_reset_exit; + } + } #endif for (;;) { @@ -171,7 +185,11 @@ soft_reset: } } - printf("soft reboot\n"); + #if MICROPY_MODULE_FROZEN || MICROPY_VFS +soft_reset_exit: + #endif + + mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n"); #if MICROPY_PY_BLUETOOTH mp_bluetooth_deinit(); |