1 /*
2  * This file is part of the MicroPython project, http://micropython.org/
3  *
4  * Original file from:
5  * FatFs - FAT file system module configuration file R0.13c (C)ChaN, 2018
6  *
7  * The MIT License (MIT)
8  *
9  * Copyright (c) 2013-2019 Damien P. George
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights
14  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  * copies of the Software, and to permit persons to whom the Software is
16  * furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27  * THE SOFTWARE.
28  */
29 
30 #include "py/mpconfig.h"
31 
32 /*---------------------------------------------------------------------------/
33 /  FatFs Functional Configurations
34 /---------------------------------------------------------------------------*/
35 
36 #define FFCONF_DEF  86604   /* Revision ID */
37 
38 /*---------------------------------------------------------------------------/
39 / Function Configurations
40 /---------------------------------------------------------------------------*/
41 
42 #define FF_FS_READONLY  0
43 /* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
44 /  Read-only configuration removes writing API functions, f_write(), f_sync(),
45 /  f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
46 /  and optional writing functions as well. */
47 
48 
49 #define FF_FS_MINIMIZE  0
50 /* This option defines minimization level to remove some basic API functions.
51 /
52 /   0: Basic functions are fully enabled.
53 /   1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
54 /      are removed.
55 /   2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
56 /   3: f_lseek() function is removed in addition to 2. */
57 
58 
59 #define FF_USE_STRFUNC  0
60 /* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
61 /
62 /  0: Disable string functions.
63 /  1: Enable without LF-CRLF conversion.
64 /  2: Enable with LF-CRLF conversion. */
65 
66 
67 #define FF_USE_FIND     0
68 /* This option switches filtered directory read functions, f_findfirst() and
69 /  f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
70 
71 
72 #define FF_USE_MKFS     1
73 /* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
74 
75 
76 #define FF_USE_FASTSEEK 0
77 /* This option switches fast seek function. (0:Disable or 1:Enable) */
78 
79 
80 #define FF_USE_EXPAND   0
81 /* This option switches f_expand function. (0:Disable or 1:Enable) */
82 
83 
84 #define FF_USE_CHMOD    1
85 /* This option switches attribute manipulation functions, f_chmod() and f_utime().
86 /  (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
87 
88 
89 #ifdef MICROPY_FATFS_USE_LABEL
90 #define FF_USE_LABEL    (MICROPY_FATFS_USE_LABEL)
91 #else
92 #define FF_USE_LABEL    0
93 #endif
94 /* This option switches volume label functions, f_getlabel() and f_setlabel().
95 /  (0:Disable or 1:Enable) */
96 
97 
98 #define FF_USE_FORWARD  0
99 /* This option switches f_forward() function. (0:Disable or 1:Enable) */
100 
101 
102 /*---------------------------------------------------------------------------/
103 / Locale and Namespace Configurations
104 /---------------------------------------------------------------------------*/
105 
106 #ifdef MICROPY_FATFS_LFN_CODE_PAGE
107 #define FF_CODE_PAGE MICROPY_FATFS_LFN_CODE_PAGE
108 #else
109 #define FF_CODE_PAGE 437
110 #endif
111 /* This option specifies the OEM code page to be used on the target system.
112 /  Incorrect code page setting can cause a file open failure.
113 /
114 /   437 - U.S.
115 /   720 - Arabic
116 /   737 - Greek
117 /   771 - KBL
118 /   775 - Baltic
119 /   850 - Latin 1
120 /   852 - Latin 2
121 /   855 - Cyrillic
122 /   857 - Turkish
123 /   860 - Portuguese
124 /   861 - Icelandic
125 /   862 - Hebrew
126 /   863 - Canadian French
127 /   864 - Arabic
128 /   865 - Nordic
129 /   866 - Russian
130 /   869 - Greek 2
131 /   932 - Japanese (DBCS)
132 /   936 - Simplified Chinese (DBCS)
133 /   949 - Korean (DBCS)
134 /   950 - Traditional Chinese (DBCS)
135 /     0 - Include all code pages above and configured by f_setcp()
136 */
137 
138 
139 #ifdef MICROPY_FATFS_ENABLE_LFN
140 #define FF_USE_LFN  (MICROPY_FATFS_ENABLE_LFN)
141 #else
142 #define FF_USE_LFN  0
143 #endif
144 #ifdef MICROPY_FATFS_MAX_LFN
145 #define FF_MAX_LFN  (MICROPY_FATFS_MAX_LFN)
146 #else
147 #define FF_MAX_LFN  255
148 #endif
149 /* The FF_USE_LFN switches the support for LFN (long file name).
150 /
151 /   0: Disable LFN. FF_MAX_LFN has no effect.
152 /   1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
153 /   2: Enable LFN with dynamic working buffer on the STACK.
154 /   3: Enable LFN with dynamic working buffer on the HEAP.
155 /
156 /  To enable the LFN, ffunicode.c needs to be added to the project. The LFN function
157 /  requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
158 /  additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
159 /  The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
160 /  be in range of 12 to 255. It is recommended to be set 255 to fully support LFN
161 /  specification.
162 /  When use stack for the working buffer, take care on stack overflow. When use heap
163 /  memory for the working buffer, memory management functions, ff_memalloc() and
164 /  ff_memfree() in ffsystem.c, need to be added to the project. */
165 
166 
167 #define FF_LFN_UNICODE  0
168 /* This option switches the character encoding on the API when LFN is enabled.
169 /
170 /   0: ANSI/OEM in current CP (TCHAR = char)
171 /   1: Unicode in UTF-16 (TCHAR = WCHAR)
172 /   2: Unicode in UTF-8 (TCHAR = char)
173 /   3: Unicode in UTF-32 (TCHAR = DWORD)
174 /
175 /  Also behavior of string I/O functions will be affected by this option.
176 /  When LFN is not enabled, this option has no effect. */
177 
178 
179 #define FF_LFN_BUF      255
180 #define FF_SFN_BUF      12
181 /* This set of options defines size of file name members in the FILINFO structure
182 /  which is used to read out directory items. These values should be suffcient for
183 /  the file names to read. The maximum possible length of the read file name depends
184 /  on character encoding. When LFN is not enabled, these options have no effect. */
185 
186 
187 #define FF_STRF_ENCODE  3
188 /* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(),
189 /  f_putc(), f_puts and f_printf() convert the character encoding in it.
190 /  This option selects assumption of character encoding ON THE FILE to be
191 /  read/written via those functions.
192 /
193 /   0: ANSI/OEM in current CP
194 /   1: Unicode in UTF-16LE
195 /   2: Unicode in UTF-16BE
196 /   3: Unicode in UTF-8
197 */
198 
199 
200 #ifdef MICROPY_FATFS_RPATH
201 #define FF_FS_RPATH (MICROPY_FATFS_RPATH)
202 #else
203 #define FF_FS_RPATH 0
204 #endif
205 /* This option configures support for relative path.
206 /
207 /   0: Disable relative path and remove related functions.
208 /   1: Enable relative path. f_chdir() and f_chdrive() are available.
209 /   2: f_getcwd() function is available in addition to 1.
210 */
211 
212 
213 /*---------------------------------------------------------------------------/
214 / Drive/Volume Configurations
215 /---------------------------------------------------------------------------*/
216 
217 #define FF_VOLUMES      1
218 /* Number of volumes (logical drives) to be used. (1-10) */
219 
220 
221 #define FF_STR_VOLUME_ID    0
222 #define FF_VOLUME_STRS      "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
223 /* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
224 /  When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
225 /  number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
226 /  logical drives. Number of items must not be less than FF_VOLUMES. Valid
227 /  characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
228 /  compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
229 /  not defined, a user defined volume string table needs to be defined as:
230 /
231 /  const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
232 */
233 
234 
235 #ifdef MICROPY_FATFS_MULTI_PARTITION
236 #define FF_MULTI_PARTITION  (MICROPY_FATFS_MULTI_PARTITION)
237 #else
238 #define FF_MULTI_PARTITION  0
239 #endif
240 /* This option switches support for multiple volumes on the physical drive.
241 /  By default (0), each logical drive number is bound to the same physical drive
242 /  number and only an FAT volume found on the physical drive will be mounted.
243 /  When this function is enabled (1), each logical drive number can be bound to
244 /  arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
245 /  funciton will be available. */
246 
247 
248 #define FF_MIN_SS   512
249 #ifdef MICROPY_FATFS_MAX_SS
250 #define FF_MAX_SS   (MICROPY_FATFS_MAX_SS)
251 #else
252 #define FF_MAX_SS   512
253 #endif
254 /* This set of options configures the range of sector size to be supported. (512,
255 /  1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
256 /  harddisk. But a larger value may be required for on-board flash memory and some
257 /  type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
258 /  for variable sector size mode and disk_ioctl() function needs to implement
259 /  GET_SECTOR_SIZE command. */
260 
261 
262 #define FF_USE_TRIM     0
263 /* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
264 /  To enable Trim function, also CTRL_TRIM command should be implemented to the
265 /  disk_ioctl() function. */
266 
267 
268 #define FF_FS_NOFSINFO  0
269 /* If you need to know correct free space on the FAT32 volume, set bit 0 of this
270 /  option, and f_getfree() function at first time after volume mount will force
271 /  a full FAT scan. Bit 1 controls the use of last allocated cluster number.
272 /
273 /  bit0=0: Use free cluster count in the FSINFO if available.
274 /  bit0=1: Do not trust free cluster count in the FSINFO.
275 /  bit1=0: Use last allocated cluster number in the FSINFO if available.
276 /  bit1=1: Do not trust last allocated cluster number in the FSINFO.
277 */
278 
279 
280 
281 /*---------------------------------------------------------------------------/
282 / System Configurations
283 /---------------------------------------------------------------------------*/
284 
285 #define FF_FS_TINY      1
286 /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
287 /  At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
288 /  Instead of private sector buffer eliminated from the file object, common sector
289 /  buffer in the filesystem object (FATFS) is used for the file data transfer. */
290 
291 
292 #ifdef MICROPY_FATFS_EXFAT
293 #define FF_FS_EXFAT (MICROPY_FATFS_EXFAT)
294 #else
295 #define FF_FS_EXFAT 0
296 #endif
297 /* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
298 /  To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
299 /  Note that enabling exFAT discards ANSI C (C89) compatibility. */
300 
301 
302 #ifdef MICROPY_FATFS_NORTC
303 #define FF_FS_NORTC (MICROPY_FATFS_NORTC)
304 #else
305 #define FF_FS_NORTC 0
306 #endif
307 #define FF_NORTC_MON    1
308 #define FF_NORTC_MDAY   1
309 #define FF_NORTC_YEAR   2018
310 /* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
311 /  any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
312 /  the timestamp function. Every object modified by FatFs will have a fixed timestamp
313 /  defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
314 /  To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
315 /  added to the project to read current time form real-time clock. FF_NORTC_MON,
316 /  FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
317 /  These options have no effect at read-only configuration (FF_FS_READONLY = 1). */
318 
319 
320 #define FF_FS_LOCK      0
321 /* The option FF_FS_LOCK switches file lock function to control duplicated file open
322 /  and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
323 /  is 1.
324 /
325 /  0:  Disable file lock function. To avoid volume corruption, application program
326 /      should avoid illegal open, remove and rename to the open objects.
327 /  >0: Enable file lock function. The value defines how many files/sub-directories
328 /      can be opened simultaneously under file lock control. Note that the file
329 /      lock control is independent of re-entrancy. */
330 
331 
332 #ifdef MICROPY_FATFS_REENTRANT
333 #define FF_FS_REENTRANT (MICROPY_FATFS_REENTRANT)
334 #else
335 #define FF_FS_REENTRANT 0
336 #endif
337 
338 // milliseconds
339 #ifdef MICROPY_FATFS_TIMEOUT
340 #define FF_FS_TIMEOUT   (MICROPY_FATFS_TIMEOUT)
341 #else
342 #define FF_FS_TIMEOUT   1000
343 #endif
344 
345 #ifdef MICROPY_FATFS_SYNC_T
346 #define FF_SYNC_t       MICROPY_FATFS_SYNC_T
347 #else
348 #define FF_SYNC_t       HANDLE
349 #endif
350 /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
351 /  module itself. Note that regardless of this option, file access to different
352 /  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
353 /  and f_fdisk() function, are always not re-entrant. Only file/directory access
354 /  to the same volume is under control of this function.
355 /
356 /   0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
357 /   1: Enable re-entrancy. Also user provided synchronization handlers,
358 /      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
359 /      function, must be added to the project. Samples are available in
360 /      option/syscall.c.
361 /
362 /  The FF_FS_TIMEOUT defines timeout period in unit of time tick.
363 /  The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
364 /  SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
365 /  included somewhere in the scope of ff.h. */
366 
367 
368 
369 /*--- End of configuration options ---*/
370