From 0263243ee12b716d76e77897cea00ec16c1a2e57 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 15 Apr 2020 00:18:13 +0200 Subject: [PATCH 1/8] examples/filesystem: don't set VFS params by the application --- examples/filesystem/Makefile | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/examples/filesystem/Makefile b/examples/filesystem/Makefile index 17dba14a91..0704f759a6 100644 --- a/examples/filesystem/Makefile +++ b/examples/filesystem/Makefile @@ -38,14 +38,4 @@ USEMODULE += littlefs USEMODULE += constfs # USEMODULE += devfs -# Set file systems specific variables -ifneq (,$(filter littlefs, $(USEMODULE))) - CFLAGS += -DVFS_FILE_BUFFER_SIZE=56 -DVFS_DIR_BUFFER_SIZE=44 -else ifneq (,$(filter spiffs, $(USEMODULE))) - SPIFFS_NB_FD ?= 8 - CFLAGS += '-DSPIFFS_FS_FD_SPACE_SIZE=(32 * $(SPIFFS_NB_FD))' -else ifneq (,$(filter fatfs_vfs, $(USEMODULE))) - CFLAGS += -DVFS_FILE_BUFFER_SIZE=72 -DVFS_DIR_BUFFER_SIZE=44 -endif - include $(RIOTBASE)/Makefile.include From e89d9c05c32e1740651f310c605a7eeb794c79f6 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 15 Apr 2020 00:18:32 +0200 Subject: [PATCH 2/8] tests: don't set VFS params by the application --- tests/pkg_fatfs_vfs/Makefile | 2 -- tests/pkg_littlefs/Makefile | 5 ----- tests/pkg_littlefs2/Makefile | 5 ----- 3 files changed, 12 deletions(-) diff --git a/tests/pkg_fatfs_vfs/Makefile b/tests/pkg_fatfs_vfs/Makefile index 52ae1a2dc9..e420b54668 100644 --- a/tests/pkg_fatfs_vfs/Makefile +++ b/tests/pkg_fatfs_vfs/Makefile @@ -3,8 +3,6 @@ include ../Makefile.tests_common USEMODULE += fatfs_vfs FEATURES_OPTIONAL += periph_rtc -CFLAGS += -DVFS_FILE_BUFFER_SIZE=72 -DVFS_DIR_BUFFER_SIZE=44 - FATFS_IMAGE_FILE_SIZE_MIB ?= 128 ifeq ($(BOARD),native) diff --git a/tests/pkg_littlefs/Makefile b/tests/pkg_littlefs/Makefile index f840cdfd59..72841457a9 100644 --- a/tests/pkg_littlefs/Makefile +++ b/tests/pkg_littlefs/Makefile @@ -8,11 +8,6 @@ BOARD_BLACKLIST := chronos \ wsn430-v1_4 \ z1 \ -# Set vfs file and dir buffer sizes -CFLAGS += -DVFS_FILE_BUFFER_SIZE=56 -DVFS_DIR_BUFFER_SIZE=44 -# Reduce LFS_NAME_MAX to 31 (as VFS_NAME_MAX default) -CFLAGS += -DLFS_NAME_MAX=31 - USEMODULE += littlefs USEMODULE += embunit diff --git a/tests/pkg_littlefs2/Makefile b/tests/pkg_littlefs2/Makefile index 54838f5621..07eef1db2c 100644 --- a/tests/pkg_littlefs2/Makefile +++ b/tests/pkg_littlefs2/Makefile @@ -1,10 +1,5 @@ include ../Makefile.tests_common -# Set vfs file and dir buffer sizes -CFLAGS += -DVFS_FILE_BUFFER_SIZE=84 -DVFS_DIR_BUFFER_SIZE=52 -# Reduce LFS_NAME_MAX to 31 (as VFS_NAME_MAX default) -CFLAGS += -DLFS_NAME_MAX=31 - USEPKG += littlefs2 USEMODULE += embunit From eae9e3cf67f9c904603de954cfc687068ae545b3 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 15 Apr 2020 00:20:07 +0200 Subject: [PATCH 3/8] pkg/fatfs: set VFS params --- pkg/fatfs/Makefile.include | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/fatfs/Makefile.include b/pkg/fatfs/Makefile.include index 61e4b7bd7e..0cbc7995b4 100644 --- a/pkg/fatfs/Makefile.include +++ b/pkg/fatfs/Makefile.include @@ -3,7 +3,6 @@ INCLUDES += -I$(RIOTPKG)/fatfs/fatfs_diskio/mtd/include DIRS += $(RIOTBASE)/pkg/fatfs/fatfs_diskio/mtd - ifneq (,$(filter fatfs_vfs,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/fatfs/fatfs_vfs endif @@ -18,3 +17,6 @@ endif ifeq ($(OS),Darwin) CFLAGS += -Wno-empty-body endif + +# Set vfs file and dir buffer sizes +CFLAGS += -DVFS_FILE_BUFFER_SIZE=72 -DVFS_DIR_BUFFER_SIZE=44 From 17236a12e946daec30031e6ae2bedac5381d7ebf Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 15 Apr 2020 00:20:28 +0200 Subject: [PATCH 4/8] pkg/littlefs: set VFS params --- pkg/littlefs/Makefile.include | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/littlefs/Makefile.include b/pkg/littlefs/Makefile.include index a5467e8f04..4793d99324 100644 --- a/pkg/littlefs/Makefile.include +++ b/pkg/littlefs/Makefile.include @@ -3,3 +3,8 @@ INCLUDES += -I$(PKGDIRBASE)/littlefs ifneq (,$(filter littlefs_fs,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/littlefs/fs endif + +# Set vfs file and dir buffer sizes +CFLAGS += -DVFS_FILE_BUFFER_SIZE=56 -DVFS_DIR_BUFFER_SIZE=44 +# Reduce LFS_NAME_MAX to 31 (as VFS_NAME_MAX default) +CFLAGS += -DLFS_NAME_MAX=31 From 67d68b2bd3431b8ec6cb2e4abecc7afa2f101f5e Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 15 Apr 2020 00:20:58 +0200 Subject: [PATCH 5/8] pkg/littlefs2: set VFS params --- pkg/littlefs2/Makefile.include | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/littlefs2/Makefile.include b/pkg/littlefs2/Makefile.include index de108138da..84c63eb4fb 100644 --- a/pkg/littlefs2/Makefile.include +++ b/pkg/littlefs2/Makefile.include @@ -1,3 +1,8 @@ INCLUDES += -I$(PKGDIRBASE)/littlefs2 DIRS += $(RIOTBASE)/pkg/littlefs2/fs + +# Set vfs file and dir buffer sizes +CFLAGS += -DVFS_FILE_BUFFER_SIZE=84 -DVFS_DIR_BUFFER_SIZE=52 +# Reduce LFS_NAME_MAX to 31 (as VFS_NAME_MAX default) +CFLAGS += -DLFS_NAME_MAX=31 From 3068dad305a5c2e54d2665b6389bfbc8fa68d9a5 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Wed, 15 Apr 2020 00:21:10 +0200 Subject: [PATCH 6/8] pkg/spiffs: set VFS params --- pkg/spiffs/Makefile.include | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/spiffs/Makefile.include b/pkg/spiffs/Makefile.include index 4e77c3a5e2..6d3c0b57b6 100644 --- a/pkg/spiffs/Makefile.include +++ b/pkg/spiffs/Makefile.include @@ -4,3 +4,6 @@ INCLUDES += -I$(PKGDIRBASE)/spiffs/src/ ifneq (,$(filter spiffs_fs,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/spiffs/fs endif + +SPIFFS_NB_FD ?= 8 +CFLAGS += '-DSPIFFS_FS_FD_SPACE_SIZE=(32 * $(SPIFFS_NB_FD))' From adbf9ef3ac3c89fadcdefce72ed2c3b5d17e9160 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 18 May 2020 00:55:43 +0200 Subject: [PATCH 7/8] vfs: select VFS params to accommodate all enabled file systems --- pkg/fatfs/Makefile.include | 4 +- pkg/littlefs/Makefile.include | 2 - pkg/littlefs2/Makefile.include | 2 - sys/include/vfs.h | 76 +++++++++++++++++++++++++++++++++- 4 files changed, 75 insertions(+), 9 deletions(-) diff --git a/pkg/fatfs/Makefile.include b/pkg/fatfs/Makefile.include index 0cbc7995b4..61e4b7bd7e 100644 --- a/pkg/fatfs/Makefile.include +++ b/pkg/fatfs/Makefile.include @@ -3,6 +3,7 @@ INCLUDES += -I$(RIOTPKG)/fatfs/fatfs_diskio/mtd/include DIRS += $(RIOTBASE)/pkg/fatfs/fatfs_diskio/mtd + ifneq (,$(filter fatfs_vfs,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/fatfs/fatfs_vfs endif @@ -17,6 +18,3 @@ endif ifeq ($(OS),Darwin) CFLAGS += -Wno-empty-body endif - -# Set vfs file and dir buffer sizes -CFLAGS += -DVFS_FILE_BUFFER_SIZE=72 -DVFS_DIR_BUFFER_SIZE=44 diff --git a/pkg/littlefs/Makefile.include b/pkg/littlefs/Makefile.include index 4793d99324..129be58296 100644 --- a/pkg/littlefs/Makefile.include +++ b/pkg/littlefs/Makefile.include @@ -4,7 +4,5 @@ ifneq (,$(filter littlefs_fs,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/littlefs/fs endif -# Set vfs file and dir buffer sizes -CFLAGS += -DVFS_FILE_BUFFER_SIZE=56 -DVFS_DIR_BUFFER_SIZE=44 # Reduce LFS_NAME_MAX to 31 (as VFS_NAME_MAX default) CFLAGS += -DLFS_NAME_MAX=31 diff --git a/pkg/littlefs2/Makefile.include b/pkg/littlefs2/Makefile.include index 84c63eb4fb..aca2d10be6 100644 --- a/pkg/littlefs2/Makefile.include +++ b/pkg/littlefs2/Makefile.include @@ -2,7 +2,5 @@ INCLUDES += -I$(PKGDIRBASE)/littlefs2 DIRS += $(RIOTBASE)/pkg/littlefs2/fs -# Set vfs file and dir buffer sizes -CFLAGS += -DVFS_FILE_BUFFER_SIZE=84 -DVFS_DIR_BUFFER_SIZE=52 # Reduce LFS_NAME_MAX to 31 (as VFS_NAME_MAX default) CFLAGS += -DLFS_NAME_MAX=31 diff --git a/sys/include/vfs.h b/sys/include/vfs.h index 2b547822e0..8c45e99124 100644 --- a/sys/include/vfs.h +++ b/sys/include/vfs.h @@ -79,6 +79,70 @@ extern "C" { /* #define restrict */ #endif +/** + * @brief MAX functions for internal use + * @{ + */ +#ifndef _MAX +#define _MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef MAX4 +#define MAX4(a, b, c, d) _MAX(_MAX((a), (b)), _MAX((c),(d))) +#endif +/** @} */ + +/** + * @brief VFS parameters for FAT + * @{ + */ +#ifdef MODULE_FATFS_VFS +#define FATFS_VFS_DIR_BUFFER_SIZE (44) +#define FATFS_VFS_FILE_BUFFER_SIZE (72) +#else +#define FATFS_VFS_DIR_BUFFER_SIZE (1) +#define FATFS_VFS_FILE_BUFFER_SIZE (1) +#endif +/** @} */ + +/** + * @brief VFS parameters for littlefs + * @{ + */ +#ifdef MODULE_LITTLEFS +#define LITTLEFS_VFS_DIR_BUFFER_SIZE (44) +#define LITTLEFS_VFS_FILE_BUFFER_SIZE (56) +#else +#define LITTLEFS_VFS_DIR_BUFFER_SIZE (1) +#define LITTLEFS_VFS_FILE_BUFFER_SIZE (1) +#endif +/** @} */ + +/** + * @brief VFS parameters for littlefs2 + * @{ + */ +#ifdef MODULE_LITTLEFS2 +#define LITTLEFS2_VFS_DIR_BUFFER_SIZE (52) +#define LITTLEFS2_VFS_FILE_BUFFER_SIZE (84) +#else +#define LITTLEFS2_VFS_DIR_BUFFER_SIZE (1) +#define LITTLEFS2_VFS_FILE_BUFFER_SIZE (1) +#endif +/** @} */ + +/** + * @brief VFS parameters for spiffs + * @{ + */ +#ifdef MODULE_SPIFFS +#define SPIFFS_VFS_DIR_BUFFER_SIZE (12) +#define SPIFFS_VFS_FILE_BUFFER_SIZE (1) +#else +#define SPIFFS_VFS_DIR_BUFFER_SIZE (1) +#define SPIFFS_VFS_FILE_BUFFER_SIZE (1) +#endif +/** @} */ + #ifndef VFS_MAX_OPEN_FILES /** * @brief Maximum number of simultaneous open files @@ -114,7 +178,11 @@ extern "C" { * @attention Put the check in the public header file (.h), do not put the check in the * implementation (.c) file. */ -#define VFS_DIR_BUFFER_SIZE (12) +#define VFS_DIR_BUFFER_SIZE MAX4(FATFS_VFS_DIR_BUFFER_SIZE, \ + LITTLEFS_VFS_DIR_BUFFER_SIZE, \ + LITTLEFS2_VFS_DIR_BUFFER_SIZE, \ + SPIFFS_VFS_DIR_BUFFER_SIZE \ + ) #endif #ifndef VFS_FILE_BUFFER_SIZE @@ -137,7 +205,11 @@ extern "C" { * @attention Put the check in the public header file (.h), do not put the check in the * implementation (.c) file. */ -#define VFS_FILE_BUFFER_SIZE (1) +#define VFS_FILE_BUFFER_SIZE MAX4(FATFS_VFS_FILE_BUFFER_SIZE, \ + LITTLEFS_VFS_FILE_BUFFER_SIZE, \ + LITTLEFS2_VFS_FILE_BUFFER_SIZE,\ + SPIFFS_VFS_FILE_BUFFER_SIZE \ + ) #endif #ifndef VFS_NAME_MAX From a91cbea59acf86d589775b1015cdfc6728dc4eac Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 30 Jun 2020 17:42:28 +0200 Subject: [PATCH 8/8] tests/pkg_spiffs: increase test timeout to 90s test takes 66s to run on esp8266-esp-12x, bump the timeout to 90s to be safe. --- tests/pkg_spiffs/tests/01-run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pkg_spiffs/tests/01-run.py b/tests/pkg_spiffs/tests/01-run.py index 8b4e23f2e7..9ef7302834 100755 --- a/tests/pkg_spiffs/tests/01-run.py +++ b/tests/pkg_spiffs/tests/01-run.py @@ -11,4 +11,4 @@ from testrunner import run_check_unittests if __name__ == "__main__": - sys.exit(run_check_unittests()) + sys.exit(run_check_unittests(timeout=90))