ports/nrf: Add compile switch to disable VFS.
This saves about 17kB.
This commit is contained in:
parent
61b6faed15
commit
f57be619fc
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the MicroPython project, http://micropython.org/
|
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, 2014 Damien P. George
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "py/runtime.h"
|
|
||||||
#include "extmod/vfs_fat_file.h"
|
|
||||||
|
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, fatfs_builtin_open);
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "py/nlr.h"
|
#include "py/nlr.h"
|
||||||
|
#include "py/mperrno.h"
|
||||||
#include "py/lexer.h"
|
#include "py/lexer.h"
|
||||||
#include "py/parse.h"
|
#include "py/parse.h"
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
|
@ -213,6 +214,21 @@ pin_init0();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !MICROPY_VFS
|
||||||
|
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
|
||||||
|
mp_raise_OSError(MP_ENOENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
mp_import_stat_t mp_import_stat(const char *path) {
|
||||||
|
return MP_IMPORT_STAT_NO_EXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
|
||||||
|
mp_raise_OSError(MP_EPERM);
|
||||||
|
}
|
||||||
|
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
|
||||||
|
#endif
|
||||||
|
|
||||||
void HardFault_Handler(void)
|
void HardFault_Handler(void)
|
||||||
{
|
{
|
||||||
#if NRF52
|
#if NRF52
|
||||||
|
|
|
@ -79,6 +79,7 @@ STATIC mp_obj_t os_uname(void) {
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
|
||||||
|
|
||||||
|
#if MICROPY_VFS
|
||||||
/// \function sync()
|
/// \function sync()
|
||||||
/// Sync all filesystems.
|
/// Sync all filesystems.
|
||||||
STATIC mp_obj_t os_sync(void) {
|
STATIC mp_obj_t os_sync(void) {
|
||||||
|
@ -89,6 +90,7 @@ STATIC mp_obj_t os_sync(void) {
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
MP_DEFINE_CONST_FUN_OBJ_0(mod_os_sync_obj, os_sync);
|
MP_DEFINE_CONST_FUN_OBJ_0(mod_os_sync_obj, os_sync);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_ENABLE_RNG
|
#if MICROPY_HW_ENABLE_RNG
|
||||||
/// \function urandom(n)
|
/// \function urandom(n)
|
||||||
|
@ -133,6 +135,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&os_uname_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&os_uname_obj) },
|
||||||
|
|
||||||
|
#if MICROPY_VFS
|
||||||
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&mp_vfs_chdir_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&mp_vfs_chdir_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&mp_vfs_getcwd_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&mp_vfs_getcwd_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
|
||||||
|
@ -145,6 +148,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
|
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mod_os_sync_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&mod_os_sync_obj) },
|
||||||
|
#endif
|
||||||
|
|
||||||
/// \constant sep - separation character used in paths
|
/// \constant sep - separation character used in paths
|
||||||
{ MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) },
|
{ MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) },
|
||||||
|
@ -155,9 +159,11 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||||
|
|
||||||
// these are MicroPython extensions
|
// these are MicroPython extensions
|
||||||
{ MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&mod_os_dupterm_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&mod_os_dupterm_obj) },
|
||||||
|
#if MICROPY_VFS
|
||||||
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&mp_vfs_umount_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&mp_vfs_umount_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
|
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
|
STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
|
||||||
|
|
|
@ -30,13 +30,17 @@
|
||||||
#include <mpconfigboard.h>
|
#include <mpconfigboard.h>
|
||||||
|
|
||||||
// options to control how MicroPython is built
|
// options to control how MicroPython is built
|
||||||
|
#ifndef MICROPY_VFS
|
||||||
|
#define MICROPY_VFS (1)
|
||||||
|
#endif
|
||||||
|
#define MICROPY_VFS_FAT (MICROPY_VFS)
|
||||||
#define MICROPY_ALLOC_PATH_MAX (512)
|
#define MICROPY_ALLOC_PATH_MAX (512)
|
||||||
#define MICROPY_PERSISTENT_CODE_LOAD (0)
|
#define MICROPY_PERSISTENT_CODE_LOAD (0)
|
||||||
#define MICROPY_EMIT_THUMB (0)
|
#define MICROPY_EMIT_THUMB (0)
|
||||||
#define MICROPY_EMIT_INLINE_THUMB (0)
|
#define MICROPY_EMIT_INLINE_THUMB (0)
|
||||||
#define MICROPY_COMP_MODULE_CONST (0)
|
#define MICROPY_COMP_MODULE_CONST (0)
|
||||||
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
|
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
|
||||||
#define MICROPY_READER_VFS (1)
|
#define MICROPY_READER_VFS (MICROPY_VFS)
|
||||||
#define MICROPY_ENABLE_GC (1)
|
#define MICROPY_ENABLE_GC (1)
|
||||||
#define MICROPY_ENABLE_FINALISER (1)
|
#define MICROPY_ENABLE_FINALISER (1)
|
||||||
#define MICROPY_STACK_CHECK (0)
|
#define MICROPY_STACK_CHECK (0)
|
||||||
|
@ -54,8 +58,6 @@
|
||||||
#define MICROPY_OPT_COMPUTED_GOTO (0)
|
#define MICROPY_OPT_COMPUTED_GOTO (0)
|
||||||
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
|
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
|
||||||
#define MICROPY_OPT_MPZ_BITWISE (0)
|
#define MICROPY_OPT_MPZ_BITWISE (0)
|
||||||
#define MICROPY_VFS (1)
|
|
||||||
#define MICROPY_VFS_FAT (1)
|
|
||||||
|
|
||||||
// fatfs configuration used in ffconf.h
|
// fatfs configuration used in ffconf.h
|
||||||
#define MICROPY_FATFS_ENABLE_LFN (1)
|
#define MICROPY_FATFS_ENABLE_LFN (1)
|
||||||
|
@ -69,9 +71,11 @@
|
||||||
#define mp_type_textio fatfs_type_textio
|
#define mp_type_textio fatfs_type_textio
|
||||||
|
|
||||||
// use vfs's functions for import stat and builtin open
|
// use vfs's functions for import stat and builtin open
|
||||||
|
#if MICROPY_VFS
|
||||||
#define mp_import_stat mp_vfs_import_stat
|
#define mp_import_stat mp_vfs_import_stat
|
||||||
#define mp_builtin_open mp_vfs_open
|
#define mp_builtin_open mp_vfs_open
|
||||||
#define mp_builtin_open_obj mp_vfs_open_obj
|
#define mp_builtin_open_obj mp_vfs_open_obj
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MICROPY_STREAMS_NON_BLOCK (1)
|
#define MICROPY_STREAMS_NON_BLOCK (1)
|
||||||
#define MICROPY_MODULE_WEAK_LINKS (1)
|
#define MICROPY_MODULE_WEAK_LINKS (1)
|
||||||
|
|
Loading…
Reference in New Issue