1# Copyright (c) 2016 Intel Corporation
2# Copyright (c) 2020 Nordic Semiconductor ASA
3# Copyright (c) 2023 Husqvarna AB
4# SPDX-License-Identifier: Apache-2.0
5
6config FAT_FILESYSTEM_ELM
7	bool "ELM FAT file system support"
8	depends on FILE_SYSTEM
9	select DISK_ACCESS
10	help
11	  Use the ELM FAT File system implementation.
12
13if FAT_FILESYSTEM_ELM
14
15menu "ELM FAT file system settings"
16	visible if FAT_FILESYSTEM_ELM
17
18config FS_FATFS_READ_ONLY
19	bool "Read-only support for all volumes"
20	help
21	  Excludes write code from ELM FAT file system driver.
22	  Select this when using FAT for read-only access to slightly
23	  reduce code size.
24	  This option affects FF_FS_READONLY defined in ffconf.h, inside
25	  ELM FAT module.
26
27config FS_FATFS_MKFS
28	bool
29	help
30	  Adds code for creating disks with FAT file system.
31	  This option affects FF_USE_MKFS defined in ffconf.h, inside
32	  ELM FAT module.
33
34config FS_FATFS_MOUNT_MKFS
35	bool "Allow formatting volume when mounting fails"
36	default y
37	select FS_FATFS_MKFS
38	help
39	  This option adds code that allows fs_mount to attempt to format
40	  a volume if no file system is found.
41	  If formatting is not needed, disabling this flag will slightly
42	  reduce application size.
43	  Note: This option is destructive to data and will automatically
44	  destroy your disk, if mount attempt fails. In case when your
45	  disk can be detached from a device and recovered using other
46	  system, it may be worth disabling this option.
47	  When this option is disabled, disk needs to be FAT formatted
48	  prior to connecting to a device, otherwise it will not be
49	  mountable.
50
51if FS_FATFS_MOUNT_MKFS
52
53config FS_FATFS_MAX_ROOT_ENTRIES
54	int "Max number of entries in FAT FS root directory"
55	default 512
56	range 1 32768
57	help
58	  Sets how many root directory entries will be allocated when
59	  formatting new FAT system to a device.
60	  Note that this should be multiply of FS_FATFS_MAX_SS / 32.
61
62endif # FS_FATFS_MOUNT_MKFS
63
64config FS_FATFS_EXFAT
65	bool "ExFAT support"
66	select FS_FATFS_LFN
67	help
68	  Enable the exFAT format support for FatFs.
69
70config FS_FATFS_NUM_FILES
71	int "Maximum number of opened files"
72	default 4
73	help
74	  Affects how many file objects area available for parallel
75	  use by FAT driver. Each object is of size sizeof(FIL), where
76	  FIL is defined in ff.h of ELM FAT driver, and is pre-allocated
77	  at compile-time.
78	  This affects use of fs_open on FAT type mounted file systems.
79
80config FS_FATFS_NUM_DIRS
81	int "Maximum number of opened directories"
82	default 4
83	help
84	  Affects how many directory objects area available for parallel
85	  use by FAT driver. Each object is of size sizeof(DIR), where
86	  DIR is defined in ff.h of ELM FAT driver, and is pre-allocated
87	  at compile-time.
88	  This affects use of fs_opendir on FAT type mounted file systems.
89
90config FS_FATFS_LFN
91	bool "Long filenames (LFN)"
92	help
93	  Without long filenames enabled, file names are limited to 8.3 format.
94	  This option increases working buffer size.
95
96if FS_FATFS_LFN
97
98choice FS_FATFS_LFN_MODE
99	prompt "LFN memory mode"
100	default FS_FATFS_LFN_MODE_BSS
101
102config FS_FATFS_LFN_MODE_BSS
103	bool "Static buffer"
104	help
105	  Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
106	  This option affects FF_USE_LFN defined in ffconf.h, inside
107	  ELM FAT module, by setting its value to 1.
108
109config FS_FATFS_LFN_MODE_STACK
110	bool "Stack buffer"
111	help
112	  Enable LFN with dynamic working buffer on the STACK.
113	  This option affects FF_USE_LFN defined in ffconf.h, inside
114	  ELM FAT module, by setting its value to 2.
115
116config FS_FATFS_LFN_MODE_HEAP
117	bool "Heap buffer"
118	depends on HEAP_MEM_POOL_SIZE > 0
119	help
120	  Enable LFN with dynamic working buffer on the HEAP.
121	  This option affects FF_USE_LFN defined in ffconf.h, inside
122	  ELM FAT module, by setting its value to 3.
123
124endchoice
125
126config FS_FATFS_FF_USE_LFN
127	int
128	default 1 if FS_FATFS_LFN_MODE_BSS
129	default 2 if FS_FATFS_LFN_MODE_STACK
130	default 3 if FS_FATFS_LFN_MODE_HEAP
131	help
132	  Translates FS_FATFS_LFN_MODE selection to FF_USE_LFN, defined in ffconf.h,
133	  inside ELM FAT module.
134
135config FS_FATFS_MAX_LFN
136	int "Max filename length"
137	range 12 255
138	default 255
139	help
140	  The working buffer occupies (FS_FATFS_MAX_LFN + 1) * 2 bytes and
141	  additional 608 bytes at exFAT enabled.
142	  It should be set 255 to support full featured LFN operations.
143
144endif # FS_FATFS_LFN
145
146config FS_FATFS_CODEPAGE
147	int "FatFS code page (character set)"
148	default 437
149	help
150	  Valid code page values:
151	   437 - U.S.
152	   720 - Arabic
153	   737 - Greek
154	   771 - KBL
155	   775 - Baltic
156	   850 - Latin 1
157	   852 - Latin 2
158	   855 - Cyrillic
159	   857 - Turkish
160	   860 - Portuguese
161	   861 - Icelandic
162	   862 - Hebrew
163	   863 - Canadian French
164	   864 - Arabic
165	   865 - Nordic
166	   866 - Russian
167	   869 - Greek 2
168	   932 - Japanese (DBCS)
169	   936 - Simplified Chinese (DBCS)
170	   949 - Korean (DBCS)
171	   950 - Traditional Chinese (DBCS)
172	   0 - Include all supported code pages
173	  This option affects FF_CODE_PAGE defined in ffconf.h, inside
174	  ELM FAT module.
175
176config FS_FATFS_MAX_SS
177	int "Maximum supported sector size"
178	range 512 4096
179	default 512
180	help
181	  Value set here will be used as maximum supported read/write
182	  sector size, with 512 being minimum value.
183	  Option affects write/read granularity and will increase
184	  size of buffers used by FAT driver, which in practice affects
185	  how much RAM each FATFS object, used with FAT mount point,
186	  requires, which is this value plus some constant amount,
187	  independent from this setting.
188	  This will affect your compile time RAM allocation, when
189	  mount point is defined as static/global life time variable,
190	  or stack.
191	  When this value is set to 512, all mount points will use
192	  512 as sector size, all other values will cause FAT driver
193	  to query device for sector size on mount.
194	  This option affects FF_MAX_SS defined in ffconf.h, inside
195	  ELM FAT module.
196
197config FS_FATFS_MIN_SS
198	int "Minimum expected sector size"
199	range 512 FS_FATFS_MAX_SS
200	default 512
201	help
202	  Specifies minimum sector size the FAT FS driver is expected to
203	  support. Set this to FS_FATFS_MAX_FS when you have single
204	  device with FAT FS or all connected devices use the same
205	  sector size, to have slight reduction in code in FAT FS driver.
206	  The reduction comes from the fact that FAT FS does not have to
207	  query every connected device for sector size.
208	  This option affects FF_MIN_SS defined in ffconf.h, inside
209	  ELM FAT module.
210
211config FS_FATFS_WINDOW_ALIGNMENT
212	int "Memory alignment for the member \"win\" in FATFS"
213	default 1
214	help
215	  Specifies alignment, in bytes of FAT FS window buffer that is
216	  used for device's read/write operations. MMC controllers may
217	  require read/write buffer to start at memory address with
218	  specific alignment, for example 16 or 512 bytes, the value
219	  provided here is used as such alignment. Note that the window
220	  buffer is internal element of FATFS structure, which means
221	  that, in worst scenario, value provided here may cause FATFS
222	  structure to have size of twice the value.
223
224config FS_FATFS_REENTRANT
225	bool "FatFs reentrant"
226	depends on !FS_FATFS_LFN_MODE_BSS
227	help
228	  Enable the FatFs re-entrancy (thread safe) option for file/directory
229	  access for each volume. Will create a zephyr mutex object for each
230	  FatFs volume and a FatFs system mutex.
231
232endmenu
233
234endif # FAT_FILESYSTEM_ELM
235