Originally the file cache used a mem_pool, but that data structure has been deprecated and replaced by a heap that includes metadata in the heap area. As a result attempts to allocate all blocks will fail because some of the reservation intended for cache data is now holding metadata instead. It's not immediately clear how to adjust the required heap size to support this metadata as it depends on heap chunk units and data structures that are not visible to the application. Experimentally a value of 24 bytes works, while smaller values do not. Further the previous Kconfig API to configure the allocation pool is completely inappropriate with the new heap data structure which has such different behavior. So: Deprecate the old Kconfig API. Add a new Kconfig option to directly control the cache size. Infer a default cache size that works with the old mem_pool parameters assuming a per-block overhead. But to avoid wasted memory use the heap allocation only when the application customizes the size, and use a slab in other cases. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
155 lines
5.2 KiB
Plaintext
155 lines
5.2 KiB
Plaintext
# Copyright (c) 2019 Bolt Innovation Management, LLC
|
|
# Copyright (c) 2019 Peter Bigot Consulting, LLC
|
|
# Copyright (c) 2020 Nordic Semiconductor ASA
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
config FILE_SYSTEM_LITTLEFS
|
|
bool "LittleFS support"
|
|
depends on FILE_SYSTEM
|
|
depends on FLASH_MAP
|
|
depends on FLASH_PAGE_LAYOUT
|
|
help
|
|
Enables LittleFS file system support.
|
|
|
|
if FILE_SYSTEM_LITTLEFS
|
|
|
|
menu "LittleFS Settings"
|
|
visible if FILE_SYSTEM_LITTLEFS
|
|
|
|
config FS_LITTLEFS_NUM_FILES
|
|
int "Maximum number of opened files"
|
|
default 4
|
|
help
|
|
This is a global maximum across all mounted littlefs filesystems.
|
|
|
|
config FS_LITTLEFS_NUM_DIRS
|
|
int "Maximum number of opened directories"
|
|
default 4
|
|
help
|
|
This is a global maximum across all mounted littlefs filesystems.
|
|
|
|
config FS_LITTLEFS_READ_SIZE
|
|
int "Minimum size of a block read"
|
|
default 16
|
|
help
|
|
All read operations will be a multiple of this value.
|
|
|
|
config FS_LITTLEFS_PROG_SIZE
|
|
int "Minimum size of a block program"
|
|
default 16
|
|
help
|
|
All program operations will be a multiple of this value.
|
|
|
|
config FS_LITTLEFS_CACHE_SIZE
|
|
int "Size of block caches in bytes"
|
|
default 64
|
|
help
|
|
Each cache buffers a portion of a block in RAM. The littlefs
|
|
needs a read cache, a program cache, and one additional cache
|
|
per file. Larger caches can improve performance by storing
|
|
more data and reducing the number of disk accesses. Must be a
|
|
multiple of the read and program sizes of the underlying flash
|
|
device, and a factor of the block size.
|
|
|
|
config FS_LITTLEFS_LOOKAHEAD_SIZE
|
|
int "Size of lookahead buffer in bytes"
|
|
default 32
|
|
help
|
|
A larger lookahead buffer increases the number of blocks found
|
|
during an allocation pass. The lookahead buffer is stored as a
|
|
compact bitmap, so each byte of RAM can track 8 blocks. Must
|
|
be a multiple of 8.
|
|
|
|
config FS_LITTLEFS_BLOCK_CYCLES
|
|
int "Number of erase cycles before moving data to another block"
|
|
default 512
|
|
help
|
|
For dynamic wear leveling, the number of erase cycles before data
|
|
is moved to another block. Set to a non-positive value to
|
|
disable leveling.
|
|
|
|
menuconfig FS_LITTLEFS_FC_MEM_POOL
|
|
bool "Enable flexible file cache sizes for littlefs (DEPRECATED)"
|
|
help
|
|
littlefs requires a per-file buffer to cache data. For
|
|
applications that use the default configuration parameters a
|
|
memory slab is reserved to support up to
|
|
FS_LITTLE_FS_NUM_FILES blocks of FS_LITTLEFS_CACHE_SIZE bytes.
|
|
|
|
When applications customize littlefs configurations and
|
|
support different cache sizes for different partitions this
|
|
preallocation is inadequate.
|
|
|
|
This API is no longer approprate as the underlying storage solution
|
|
has been deprecated. Instead use FS_LITTLEFS_FC_HEAP_SIZE to
|
|
configure the size of a heap used to allocate caches for open files.
|
|
|
|
# This option deprecated in 2.5.0
|
|
if FS_LITTLEFS_FC_MEM_POOL
|
|
|
|
config FS_LITTLEFS_FC_MEM_POOL_MIN_SIZE
|
|
int "(DEPRECATED)"
|
|
default 16
|
|
help
|
|
This API is no longer approprate as the underlying storage
|
|
solution has been deprecated. Instead use
|
|
FS_LITTLEFS_FC_HEAP to configure the size of a heap used to
|
|
allocate caches for open files.
|
|
|
|
config FS_LITTLEFS_FC_MEM_POOL_MAX_SIZE
|
|
int "Block size for littlefs file cache heap (DEPRECATED)"
|
|
default 1024
|
|
help
|
|
A heap for file cache data is sized so that
|
|
FS_LITTLEFS_FC_MEM_POOL_NUM_BLOCKS allocations of size
|
|
FS_LITTLEFS_MEM_POOL_MAX_SIZE can be active simultaneously.
|
|
|
|
This option configures the size.
|
|
|
|
This API is no longer approprate as the underlying storage solution
|
|
has been deprecated. Instead use FS_LITTLEFS_FC_HEAP to configure
|
|
the size of a heap used to allocate caches for open files.
|
|
|
|
config FS_LITTLEFS_FC_MEM_POOL_NUM_BLOCKS
|
|
int "Number of maximum sized blocks in littlefs file cache heap (DEPRECATED)"
|
|
default 2
|
|
help
|
|
A heap for file cache data is sized so that
|
|
FS_LITTLEFS_FC_MEM_POOL_NUM_BLOCKS allocations of size
|
|
FS_LITTLEFS_MEM_POOL_MAX_SIZE can be active simultaneously.
|
|
|
|
This option configures the total heap size based on the
|
|
block size.
|
|
|
|
This API is no longer approprate as the underlying storage solution
|
|
has been deprecated. Instead use FS_LITTLEFS_FC_HEAP to configure
|
|
the size of a heap used to allocate caches for open files.
|
|
|
|
endif # FS_LITTLEFS_FC_MEM_POOL
|
|
|
|
endmenu # FS_LITTLEFS_FC_MEM_POOL
|
|
|
|
config FS_LITTLEFS_FC_HEAP_SIZE
|
|
int "Enable flexible file cache sizes for littlefs"
|
|
default 0
|
|
help
|
|
littlefs requires a per-file buffer to cache data.
|
|
|
|
When applications customize littlefs configurations and support
|
|
different cache sizes for different partitions this preallocation is
|
|
inadequate as an application might require a small number of files
|
|
using a large cache size and a larger number of files using a
|
|
smaller cache size. In that case application should provide a
|
|
positive value for the heap size. Be aware that there is a
|
|
per-allocation overhead that affects how much usable space is
|
|
present in the heap.
|
|
|
|
If this option is set to a non-positive value the heap is sized to
|
|
support up to FS_LITTLE_FS_NUM_FILES blocks of
|
|
FS_LITTLEFS_CACHE_SIZE bytes. Until FS_LITTLEFS_FC_MEM_POOL is
|
|
removed presence of that option changes the default to support
|
|
FS_LITTLEFS_FC_MEM_POOL_NUM_BLOCKS allocations of size
|
|
FS_LITTLEFS_MEM_POOL_MAX_SIZE
|
|
|
|
endif # FILE_SYSTEM_LITTLEFS
|