Skip to content

Commit

Permalink
Merge pull request #17631 from benpicco/pkg/fatfs-non_tiny
Browse files Browse the repository at this point in the history
pkg/fatfs_vfs: support FF_FS_TINY=0
  • Loading branch information
benpicco authored Feb 25, 2022
2 parents 039e993 + 6a54a39 commit 51e47e7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/fatfs/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
INCLUDES += -I$(PKGDIRBASE)
INCLUDES += -I$(RIOTPKG)/fatfs/fatfs_diskio/mtd/include
INCLUDES += -I$(RIOTPKG)/fatfs/vendor/include
# native overwrites all INCLUDES
NATIVEINCLUDES += -I$(RIOTPKG)/fatfs/vendor/include

DIRS += $(RIOTBASE)/pkg/fatfs/fatfs_diskio/mtd

Expand Down
17 changes: 16 additions & 1 deletion pkg/fatfs/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@
* @ingroup sys_fs
* @brief Provides FAT file system support
* @see http://elm-chan.org/fsw/ff/00index_e.html
*/
*/

# Compile-Time options

- `FATFS_FFCONF_OPT_FS_READONLY`: This option switches read-only configuration.
Read-only configuration removes writing API functions.

- `FATFS_FFCONF_OPT_USE_FASTSEEK`: Enables faster seek at the cost of some per-fd RAM.

- `FATFS_FFCONF_OPT_FS_TINY`: Memory optimisations. Disabling this will increase FS performance
at the cost of higher per-FD RAM usage (+512 byte/fd) as well as
increased stack usage.

- `FATFS_FFCONF_OPT_FS_EXFAT`: enables support for exFAT

- `FATFS_FFCONF_OPT_USE_LFN`: enables support for long file names
5 changes: 5 additions & 0 deletions pkg/fatfs/fatfs_vfs/fatfs_vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ static int _format(vfs_mount_t *mountp)
}
#endif

/* make sure the volume has been initialized */
if (_init(mountp)) {
return -EINVAL;
}

const MKFS_PARM param = {
.fmt = CONFIG_FATFS_FORMAT_TYPE,
};
Expand Down
16 changes: 15 additions & 1 deletion sys/include/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,22 @@ extern "C" {
* @{
*/
#ifdef MODULE_FATFS_VFS
#include "ffconf.h"

#if FF_FS_TINY
#define _FATFS_FILE_CACHE (0)
#else
#define _FATFS_FILE_CACHE FF_MAX_SS
#endif

#if FF_USE_FASTSEEK
#define _FATFS_FILE_SEEK_PTR (4)
#else
#define _FATFS_FILE_SEEK_PTR (0)
#endif

#define FATFS_VFS_DIR_BUFFER_SIZE (44)
#define FATFS_VFS_FILE_BUFFER_SIZE (72)
#define FATFS_VFS_FILE_BUFFER_SIZE (72 + _FATFS_FILE_CACHE + _FATFS_FILE_SEEK_PTR)
#else
#define FATFS_VFS_DIR_BUFFER_SIZE (1)
#define FATFS_VFS_FILE_BUFFER_SIZE (1)
Expand Down

0 comments on commit 51e47e7

Please sign in to comment.