diff --git a/esp8266/main.c b/esp8266/main.c index fe5fc81b6d..908a2c61a6 100644 --- a/esp8266/main.c +++ b/esp8266/main.c @@ -48,7 +48,9 @@ STATIC void mp_reset(void) { mp_init(); mp_obj_list_init(mp_sys_path, 0); mp_obj_list_init(mp_sys_argv, 0); + #if MICROPY_VFS_FAT memset(MP_STATE_PORT(fs_user_mount), 0, sizeof(MP_STATE_PORT(fs_user_mount))); + #endif MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt); #if MICROPY_MODULE_FROZEN pyexec_frozen_module("boot"); @@ -77,11 +79,21 @@ mp_lexer_t *fat_vfs_lexer_new_from_file(const char *filename); mp_import_stat_t fat_vfs_import_stat(const char *path); mp_lexer_t *mp_lexer_new_from_file(const char *filename) { + #if MICROPY_VFS_FAT return fat_vfs_lexer_new_from_file(filename); + #else + (void)filename; + return NULL; + #endif } mp_import_stat_t mp_import_stat(const char *path) { + #if MICROPY_VFS_FAT return fat_vfs_import_stat(path); + #else + (void)path; + return MP_IMPORT_STAT_NO_EXIST; + #endif } mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) { diff --git a/esp8266/moduos.c b/esp8266/moduos.c index b70c5b9067..bef7cddc32 100644 --- a/esp8266/moduos.c +++ b/esp8266/moduos.c @@ -69,6 +69,7 @@ STATIC mp_obj_t os_uname(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname); +#if MICROPY_VFS_FAT STATIC mp_obj_t vfs_proxy_call(qstr method_name, mp_uint_t n_args, const mp_obj_t *args) { if (MP_STATE_PORT(fs_user_mount)[0] == NULL) { nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(ENODEV))); @@ -89,14 +90,15 @@ STATIC mp_obj_t os_remove(mp_obj_t path_in) { return vfs_proxy_call(MP_QSTR_remove, 1, &path_in); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_remove_obj, os_remove); +#endif STATIC const mp_rom_map_elem_t os_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) }, { MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&os_uname_obj) }, - { MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&os_listdir_obj) }, - { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&os_remove_obj) }, #if MICROPY_VFS_FAT { MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) }, + { MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&os_listdir_obj) }, + { MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&os_remove_obj) }, #endif };