1# Copyright (c) 2019 Bolt Innovation Management, LLC
2# Copyright (c) 2019 Peter Bigot Consulting, LLC
3# Copyright (c) 2020 Nordic Semiconductor ASA
4# SPDX-License-Identifier: Apache-2.0
5
6config FILE_SYSTEM_LITTLEFS
7	bool "LittleFS support"
8	depends on FILE_SYSTEM_LIB_LINK
9	depends on ZEPHYR_LITTLEFS_MODULE
10	help
11	  Enables LittleFS file system support.
12
13if FILE_SYSTEM_LITTLEFS
14
15menu "LittleFS Settings"
16	visible if FILE_SYSTEM_LITTLEFS
17
18config FS_LITTLEFS_NUM_FILES
19	int "Maximum number of opened files"
20	default 4
21	help
22	  This is a global maximum across all mounted littlefs filesystems.
23
24config FS_LITTLEFS_NUM_DIRS
25	int "Maximum number of opened directories"
26	default 4
27	help
28	  This is a global maximum across all mounted littlefs filesystems.
29
30config FS_LITTLEFS_READ_SIZE
31	int "Minimum size of a block read"
32	default 16
33	help
34	  All read operations will be a multiple of this value.
35
36config FS_LITTLEFS_PROG_SIZE
37	int "Minimum size of a block program"
38	default 16
39	help
40	  All program operations will be a multiple of this value.
41
42config FS_LITTLEFS_CACHE_SIZE
43	int "Size of block caches in bytes"
44	default 64
45	help
46	  Each cache buffers a portion of a block in RAM.  The littlefs
47	  needs a read cache, a program cache, and one additional cache
48	  per file. Larger caches can improve performance by storing
49	  more data and reducing the number of disk accesses. Must be a
50	  multiple of the read and program sizes of the underlying flash
51	  device, and a factor of the block size.
52
53config FS_LITTLEFS_LOOKAHEAD_SIZE
54	int "Size of lookahead buffer in bytes"
55	default 32
56	help
57	  A larger lookahead buffer increases the number of blocks found
58	  during an allocation pass. The lookahead buffer is stored as a
59	  compact bitmap, so each byte of RAM can track 8 blocks.
60
61config FS_LITTLEFS_BLOCK_CYCLES
62	int "Number of erase cycles before moving data to another block"
63	default 512
64	help
65	  For dynamic wear leveling, the number of erase cycles before data
66	  is moved to another block.  Set to a non-positive value to
67	  disable leveling.
68
69endmenu
70
71config FS_LITTLEFS_FC_HEAP_SIZE
72	int "Enable flexible file cache sizes for littlefs"
73	default 0
74	help
75	  littlefs requires a per-file buffer to cache data.
76
77	  When applications customize littlefs configurations and support
78	  different cache sizes for different partitions this preallocation is
79	  inadequate as an application might require a small number of files
80	  using a large cache size and a larger number of files using a
81	  smaller cache size.  In that case application should provide a
82	  positive value for the heap size.  Be aware that there is a
83	  per-allocation overhead that affects how much usable space is
84	  present in the heap.
85
86	  If this option is set to a non-positive value the heap is sized to
87	  support up to FS_LITTLE_FS_NUM_FILES blocks of
88	  FS_LITTLEFS_CACHE_SIZE bytes.
89
90if FS_LITTLEFS_FC_HEAP_SIZE <= 0
91
92config FS_LITTLEFS_HEAP_PER_ALLOC_OVERHEAD_SIZE
93	int "Size of per-allocation overhead for littleFS heap in bytes"
94	default 32
95	help
96	  In case when total size of littleFS heap is automatically calculated
97	  we need to take into account overhead caused per block allocation.
98	  For the purpose of heap size calculation the size of each cache block
99	  will be increased by this value.
100	  NOTE: when your app fails to open pre-defined number of files, as set
101	  by FS_LITTLEFS_NUM_FILES, try to increase the value.
102
103endif # FS_LITTLEFS_FC_HEAP_SIZE <= 0
104
105config FS_LITTLEFS_FMP_DEV
106	bool "Support for littlefs on flash devices"
107	depends on FLASH_MAP
108	depends on FLASH_PAGE_LAYOUT || !FLASH_HAS_EXPLICIT_ERASE
109	default y
110	help
111	  Enable this option to provide support for littlefs on flash devices
112	  (using the flash_map API).
113
114config FS_LITTLEFS_BLK_DEV
115	bool "Support for littlefs on block devices"
116	help
117	  Enable this option to provide support for littlefs on the block
118	  devices (like for example SD card).
119
120config FS_LITTLEFS_DISK_VERSION
121	bool "Support for selecting littlefs disk version"
122	default y if $(dt_compat_any_has_prop,$(DT_COMPAT_ZEPHYR_FSTAB_LITTLEFS),disk-version)
123	help
124	  Enable this option to provide support for selecting littlefs disk version
125	  to maintain backward compatibility with existing littlefs
126	  with the same major disk version.
127
128endif # FILE_SYSTEM_LITTLEFS
129