1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

vfs: select VFS params to accommodate all enabled file systems

This commit is contained in:
Benjamin Valentin 2020-05-18 00:55:43 +02:00
parent 3068dad305
commit adbf9ef3ac
4 changed files with 75 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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