extmod: Consolidate FAT FS config to MICROPY_VFS_FAT across all ports.

This commit removes the Makefile-level MICROPY_FATFS config and moves the
MICROPY_VFS_FAT config to the Makefile level to replace it.  It also moves
the include of the oofatfs source files in the build from each port to a
central place in extmod/extmod.mk.

For a port to enabled VFS FAT support it should now set MICROPY_VFS_FAT=1
at the level of the Makefile.  This will include the relevant oofatfs files
in the build and set MICROPY_VFS_FAT=1 at the C (preprocessor) level.
pull/1/head
Damien George 2019-11-07 18:27:51 +11:00
parent 1266ba9754
commit 799b6d1e0c
24 changed files with 39 additions and 46 deletions

View File

@ -1,7 +1,20 @@
# This makefile fragment provides rules to build 3rd-party components for extmod modules
################################################################################
# VFS FAT FS
OOFATFS_DIR = lib/oofatfs
# this sets the config file for FatFs
CFLAGS_MOD += -DFFCONF_H=\"lib/oofatfs/ffconf.h\"
CFLAGS_MOD += -DFFCONF_H=\"$(OOFATFS_DIR)/ffconf.h\"
ifeq ($(MICROPY_VFS_FAT),1)
CFLAGS_MOD += -DMICROPY_VFS_FAT=1
SRC_MOD += $(addprefix $(OOFATFS_DIR)/,\
ff.c \
ffunicode.c \
)
endif
################################################################################
# VFS littlefs

View File

@ -29,8 +29,8 @@ QSTR_GLOBAL_REQUIREMENTS = $(SDKCONFIG_H)
MICROPY_PY_USSL = 0
MICROPY_SSL_AXTLS = 0
MICROPY_FATFS = 1
MICROPY_PY_BTREE = 1
MICROPY_VFS_FAT = 1
MICROPY_VFS_LFS2 = 1
FROZEN_MANIFEST ?= boards/manifest.py
@ -348,12 +348,6 @@ LIB_SRC_C = $(addprefix lib/,\
utils/sys_stdio_mphal.c \
)
ifeq ($(MICROPY_FATFS), 1)
LIB_SRC_C += \
lib/oofatfs/ff.c \
lib/oofatfs/ffunicode.c
endif
DRIVERS_SRC_C = $(addprefix drivers/,\
bus/softspi.c \
dht/dht.c \

View File

@ -61,7 +61,6 @@ void *esp_native_code_commit(void*, size_t);
#define MICROPY_ENABLE_SCHEDULER (1)
#define MICROPY_SCHEDULER_DEPTH (8)
#define MICROPY_VFS (1)
#define MICROPY_VFS_FAT (1)
// control over Python builtins
#define MICROPY_PY_FUNCTION_ATTRS (1)

View File

@ -22,7 +22,6 @@ QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h
MICROPY_PY_USSL = 1
MICROPY_SSL_AXTLS = 1
AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096
MICROPY_FATFS ?= 1
MICROPY_PY_BTREE ?= 1
BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3
@ -147,12 +146,6 @@ LIB_SRC_C = $(addprefix lib/,\
utils/sys_stdio_mphal.c \
)
ifeq ($(MICROPY_FATFS), 1)
LIB_SRC_C += \
lib/oofatfs/ff.c \
lib/oofatfs/ffunicode.c
endif
DRIVERS_SRC_C = $(addprefix drivers/,\
bus/softspi.c \
dht/dht.c \

View File

@ -10,7 +10,6 @@
#define MICROPY_READER_VFS (MICROPY_VFS)
#define MICROPY_VFS (1)
#define MICROPY_VFS_FAT (1)
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)

View File

@ -0,0 +1 @@
MICROPY_VFS_FAT = 1

View File

@ -1,3 +1,3 @@
MICROPY_FATFS = 0
MICROPY_PY_BTREE = 0
MICROPY_VFS_FAT = 0
LD_FILES = boards/esp8266_512k.ld

View File

@ -43,8 +43,7 @@ include ../../py/py.mk
GIT_SUBMODULES = lib/nrfx lib/tinyusb
MICROPY_FATFS ?= 0
FATFS_DIR = lib/oofatfs
MICROPY_VFS_FAT ?= 0
MPY_CROSS = ../../mpy-cross/mpy-cross
MPY_TOOL = ../../tools/mpy-tool.py
@ -318,7 +317,7 @@ OBJ += $(addprefix $(BUILD)/, $(SYSTEM_C_SRC:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_LIB:.c=.o))
OBJ += $(BUILD)/pins_gen.o
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
$(BUILD)/$(OOFATFS_DIR)/ff.o: COPT += -Os
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
.PHONY: all flash deploy sd binary hex

View File

@ -107,12 +107,12 @@ To use frozen modules, put them in a directory (e.g. `freeze/`) and supply
make BOARD=pca10040 FROZEN_MPY_DIR=freeze
## Enable MICROPY_FATFS
As the `oofatfs` module is not having header guards that can exclude the implementation compile time, this port provides a flag to enable it explicitly. The MICROPY_FATFS is by default set to 0 and has to be set to 1 if `oofatfs` files should be compiled. This will be in addition of setting `MICROPY_VFS` and `MICROPY_VFS_FAT` in mpconfigport.h.
## Enable MICROPY_VFS_FAT
As the `oofatfs` module is not having header guards that can exclude the implementation compile time, this port provides a flag to enable it explicitly. The MICROPY_VFS_FAT is by default set to 0 and has to be set to 1 if `oofatfs` files should be compiled. This will be in addition of setting `MICROPY_VFS` in mpconfigport.h.
For example:
make BOARD=pca10040 MICROPY_FATFS=1
make BOARD=pca10040 MICROPY_VFS_FAT=1
## Target Boards and Make Flags

View File

@ -33,7 +33,6 @@
#ifndef MICROPY_VFS
#define MICROPY_VFS (0)
#endif
#define MICROPY_VFS_FAT (MICROPY_VFS)
#define MICROPY_ALLOC_PATH_MAX (512)
#define MICROPY_PERSISTENT_CODE_LOAD (0)
#define MICROPY_EMIT_THUMB (0)

View File

@ -34,7 +34,6 @@ CMSIS_DIR=$(TOP)/lib/stm32lib/CMSIS/STM32$(MCU_SERIES_UPPER)xx/Include
HAL_DIR=lib/stm32lib/STM32$(MCU_SERIES_UPPER)xx_HAL_Driver
USBDEV_DIR=usbdev
#USBHOST_DIR=usbhost
FATFS_DIR=lib/oofatfs
DFU=$(TOP)/tools/dfu.py
# may need to prefix dfu-util with sudo
USE_PYDFU ?= 1
@ -128,8 +127,6 @@ MPY_CROSS_FLAGS += -march=armv7m
SRC_LIB = $(addprefix lib/,\
libc/string0.c \
oofatfs/ff.c \
oofatfs/ffunicode.c \
mp-readline/readline.c \
netutils/netutils.c \
netutils/trace.c \
@ -480,7 +477,7 @@ $(BUILD)/lib/libc/string0.o: COPT += -O2
# If we compile these using -O0 then it won't fit. So if you really want these
# to be compiled with -O0, then edit boards/common.ld (in the .isr_vector section)
# and comment out the following lines.
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
$(BUILD)/$(OOFATFS_DIR)/ff.o: COPT += -Os
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
$(PY_BUILD)/formatfloat.o: COPT += -Os
$(PY_BUILD)/parsenum.o: COPT += -Os

View File

@ -14,7 +14,6 @@
#define MICROPY_PY_NETWORK (0)
#define MICROPY_PY_STM (0)
#define MICROPY_PY_PYB_LEGACY (0)
#define MICROPY_VFS_FAT (0)
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
#define MICROPY_HW_ENABLE_RTC (1)

View File

@ -4,5 +4,8 @@ MICROPY_FLOAT_IMPL = none
AF_FILE = boards/stm32l072_af.csv
LD_FILES = boards/stm32l072xz.ld boards/common_basic.ld
# MicroPython settings
MICROPY_VFS_FAT = 0
# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

View File

@ -7,7 +7,6 @@
#define MICROPY_PY_NETWORK (0)
#define MICROPY_PY_STM (0)
#define MICROPY_PY_PYB_LEGACY (0)
#define MICROPY_VFS_FAT (0)
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
#define MICROPY_HW_ENABLE_RTC (1)

View File

@ -3,5 +3,8 @@ CMSIS_MCU = STM32F091xC
AF_FILE = boards/stm32f091_af.csv
LD_FILES = boards/stm32f091xc.ld boards/common_basic.ld
# MicroPython settings
MICROPY_VFS_FAT = 0
# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

View File

@ -14,7 +14,6 @@
#define MICROPY_PY_NETWORK (0)
#define MICROPY_PY_STM (0)
#define MICROPY_PY_PYB_LEGACY (0)
#define MICROPY_VFS_FAT (0)
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
#define MICROPY_HW_ENABLE_RTC (1)

View File

@ -3,5 +3,8 @@ CMSIS_MCU = STM32L073xx
AF_FILE = boards/stm32l072_af.csv
LD_FILES = boards/stm32l072xz.ld boards/common_basic.ld
# MicroPython settings
MICROPY_VFS_FAT = 0
# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

View File

@ -8,7 +8,6 @@
#define MICROPY_PY_NETWORK (0)
#define MICROPY_PY_STM (0)
#define MICROPY_PY_PYB_LEGACY (0)
#define MICROPY_VFS_FAT (0)
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
#define MICROPY_HW_ENABLE_RTC (1)

View File

@ -4,5 +4,8 @@ AF_FILE = boards/stm32l432_af.csv
LD_FILES = boards/stm32l432.ld boards/common_basic.ld
OPENOCD_CONFIG = boards/openocd_stm32l4.cfg
# MicroPython settings
MICROPY_VFS_FAT = 0
# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

View File

@ -84,9 +84,6 @@
#define MICROPY_ENABLE_SCHEDULER (1)
#define MICROPY_SCHEDULER_DEPTH (8)
#define MICROPY_VFS (1)
#ifndef MICROPY_VFS_FAT
#define MICROPY_VFS_FAT (1)
#endif
// control over Python builtins
#define MICROPY_PY_FUNCTION_ATTRS (1)

View File

@ -8,3 +8,6 @@ MICROPY_PY_WIZNET5K ?= 0
# cc3k module for wifi support
MICROPY_PY_CC3K ?= 0
# VFS FAT FS support
MICROPY_VFS_FAT ?= 1

View File

@ -163,12 +163,6 @@ LIB_SRC_C = $(addprefix lib/,\
timeutils/timeutils.c \
)
# FatFS VFS support
LIB_SRC_C += $(addprefix lib/,\
oofatfs/ff.c \
oofatfs/ffunicode.c \
)
OBJ = $(PY_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
@ -257,7 +251,7 @@ coverage:
-Wold-style-definition -Wpointer-arith -Wshadow -Wuninitialized -Wunused-parameter \
-DMICROPY_UNIX_COVERAGE' \
LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' \
MICROPY_VFS_LFS1=1 MICROPY_VFS_LFS2=1 \
MICROPY_VFS_FAT=1 MICROPY_VFS_LFS1=1 MICROPY_VFS_LFS2=1 \
FROZEN_MANIFEST=manifest_coverage.py \
BUILD=build-coverage PROG=micropython_coverage

View File

@ -152,7 +152,6 @@
#define MICROPY_FATFS_RPATH (2)
#define MICROPY_FATFS_MAX_SS (4096)
#define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
#define MICROPY_VFS_FAT (0)
// Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc.
// names in exception messages (may require more RAM).

View File

@ -55,8 +55,6 @@
#define MICROPY_PY_URE_MATCH_SPAN_START_END (1)
#define MICROPY_PY_URE_SUB (1)
#define MICROPY_VFS_POSIX (1)
#undef MICROPY_VFS_FAT
#define MICROPY_VFS_FAT (1)
#define MICROPY_PY_FRAMEBUF (1)
#define MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT (1)
#define MICROPY_PY_UCRYPTOLIB (1)