FreeRTOSFATConfig.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. * FreeRTOS+FAT V2.3.3
  3. * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * https://www.FreeRTOS.org
  23. * https://github.com/FreeRTOS
  24. *
  25. */
  26. #ifndef FF_DEFAULTCONFIG_H
  27. #define FF_DEFAULTCONFIG_H
  28. /* The error numbers defined in this file will be moved to the core FreeRTOS
  29. * code in future versions of FreeRTOS - at which time the following header file
  30. * will be removed. */
  31. #include "FreeRTOS_errno_FAT.h"
  32. #define FF_PRINTF printf
  33. #define ffconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
  34. #define ffconfigCWD_THREAD_LOCAL_INDEX 0
  35. #if !defined( ffconfigBYTE_ORDER )
  36. /* Must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN,
  37. * depending on the endian of the architecture on which FreeRTOS is running. */
  38. #error Invalid FreeRTOSFATConfig.h file: ffconfigBYTE_ORDER must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN
  39. #endif
  40. #if ( ffconfigBYTE_ORDER != pdFREERTOS_LITTLE_ENDIAN ) && ( ffconfigBYTE_ORDER != pdFREERTOS_BIG_ENDIAN )
  41. #error Invalid FreeRTOSFATConfig.h file: ffconfigBYTE_ORDER must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN
  42. #endif
  43. #if ( pdFREERTOS_LITTLE_ENDIAN != 0 ) || ( pdFREERTOS_BIG_ENDIAN != 1 )
  44. #error Invalid projdefs.h or FreeRTOS_errno_FAT.h file
  45. #endif
  46. #if !defined( ffconfigHAS_CWD )
  47. /* Set to 1 to maintain a current working directory (CWD) for each task that
  48. * accesses the file system, allowing relative paths to be used.
  49. *
  50. * Set to 0 not to use a CWD, in which case full paths must be used for each
  51. * file access. */
  52. #define ffconfigHAS_CWD 0
  53. #if !defined( ffconfigCWD_THREAD_LOCAL_INDEX )
  54. #error ffconfigCWD_THREAD_LOCAL_INDEX must be set to a free position within FreeRTOSs thread local storage pointer array for storage of a pointer to the CWD structure.
  55. #endif
  56. #endif
  57. #if !defined( ffconfigLFN_SUPPORT )
  58. /* Set to 1 to include long file name support. Set to 0 to exclude long
  59. * file name support.
  60. *
  61. * If long file name support is excluded then only 8.3 file names can be used.
  62. * Long file names will be recognised but ignored.
  63. *
  64. * Users should familiarise themselves with any patent issues that may
  65. * potentially exist around the use of long file names in FAT file systems
  66. * before enabling long file name support. */
  67. #define ffconfigLFN_SUPPORT 0
  68. #endif
  69. #if !defined( ffconfigINCLUDE_SHORT_NAME )
  70. /* Only used when ffconfigLFN_SUPPORT is set to 1.
  71. *
  72. * Set to 1 to include a file's short name when listing a directory, i.e. when
  73. * calling findfirst()/findnext(). The short name will be stored in the
  74. * 'pcShortName' field of FF_DirEnt_t.
  75. *
  76. * Set to 0 to only include a file's long name. */
  77. #define ffconfigINCLUDE_SHORT_NAME 0
  78. #endif
  79. #if !defined( ffconfigSHORTNAME_CASE )
  80. /* Set to 1 to recognise and apply the case bits used by Windows XP+ when
  81. * using short file names - storing file names such as "readme.TXT" or
  82. * "SETUP.exe" in a short-name entry. This is the recommended setting for
  83. * maximum compatibility.
  84. *
  85. * Set to 0 to ignore the case bits. */
  86. #define ffconfigSHORTNAME_CASE 0
  87. #endif
  88. #if !defined( ipconfigQUICK_SHORT_FILENAME_CREATION )
  89. /* This method saves a lot of time when creating directories with
  90. * many similar file names: when the short name version of a LFN already
  91. * exists, try at most 3 entries with a tilde:
  92. * README~1.TXT
  93. * README~2.TXT
  94. * README~3.TXT
  95. * After that create entries with pseudo-random 4-digit hex digits:
  96. * REA~E7BB.TXT
  97. * REA~BA32.TXT
  98. * REA~D394.TXT
  99. */
  100. #define ipconfigQUICK_SHORT_FILENAME_CREATION 1
  101. #endif
  102. /* ASCII versus UNICODE, UTF-16 versus UTF-8 :
  103. * FAT directories, when using Long File Names, always store file and directory
  104. * names UTF-16 encoded.
  105. * The user can select how these names must be represented internally:
  106. * - ASCII (default)
  107. * - UTF-8 (ffconfigUNICODE_UTF8_SUPPORT = 1)
  108. * - UTF-16 (ffconfigUNICODE_UTF16_SUPPORT = 1)
  109. */
  110. #if !defined( ffconfigUNICODE_UTF16_SUPPORT )
  111. /* Only used when ffconfigLFN_SUPPORT is set to 1.
  112. *
  113. * Set to 1 to use UTF-16 (wide-characters) for file and directory names.
  114. *
  115. * Set to 0 to use either 8-bit ASCII or UTF-8 for file and directory names
  116. * (see the ffconfigUNICODE_UTF8_SUPPORT). */
  117. #define ffconfigUNICODE_UTF16_SUPPORT 0
  118. #endif
  119. #if !defined( ffconfigUNICODE_UTF8_SUPPORT )
  120. /* Only used when ffconfigLFN_SUPPORT is set to 1.
  121. *
  122. * Set to 1 to use UTF-8 encoding for file and directory names.
  123. *
  124. * Set to 0 to use either 8-bit ASCII or UTF-16 for file and directory
  125. * names (see the ffconfig_UTF_16_SUPPORT setting). */
  126. #define ffconfigUNICODE_UTF8_SUPPORT 0
  127. #endif
  128. #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) && ( ffconfigUNICODE_UTF8_SUPPORT != 0 )
  129. #error Can not use both UTF-16 and UTF-8
  130. #endif
  131. #if !defined( ffconfigFAT12_SUPPORT )
  132. /* Set to 1 to include FAT12 support.
  133. *
  134. * Set to 0 to exclude FAT12 support.
  135. *
  136. * FAT16 and FAT32 are always enabled. */
  137. #define ffconfigFAT12_SUPPORT 0
  138. #endif
  139. #if !defined( ffconfigOPTIMISE_UNALIGNED_ACCESS )
  140. /* When writing and reading data, i/o becomes less efficient if sizes other
  141. * than the sector size (usually 512 bytes) are being used. When set to 1, each file handle will
  142. * allocate a one sector size character buffer to facilitate "unaligned access". */
  143. #define ffconfigOPTIMISE_UNALIGNED_ACCESS 0
  144. #endif
  145. #if !defined( ffconfigCACHE_WRITE_THROUGH )
  146. /* Input and output to a disk uses buffers that are only flushed at the
  147. * following times:
  148. *
  149. * - When a new buffer is needed and no other buffers are available.
  150. * - When opening a buffer in READ mode for a sector that has just been changed.
  151. * - After creating, removing or closing a file or a directory.
  152. *
  153. * Normally this is quick enough and it is efficient. If
  154. * ffconfigCACHE_WRITE_THROUGH is set to 1 then buffers will also be flushed each
  155. * time a buffer is released - which is less efficient but more secure. */
  156. #define ffconfigCACHE_WRITE_THROUGH 0
  157. #endif
  158. #if !defined( ffconfigWRITE_BOTH_FATS )
  159. /* In most cases, the FAT table has two identical copies on the disk,
  160. * allowing the second copy to be used in the case of a read error. If
  161. *
  162. * Set to 1 to use both FATs - this is less efficient but more secure.
  163. *
  164. * Set to 0 to use only one FAT - the second FAT will never be written to. */
  165. #define ffconfigWRITE_BOTH_FATS 0
  166. #endif
  167. #if !defined( ffconfigWRITE_FREE_COUNT )
  168. /* Set to 1 to have the number of free clusters and the first free cluster
  169. * to be written to the FS info sector each time one of those values changes.
  170. *
  171. * Set to 0 not to store these values in the FS info sector, making booting
  172. * slower, but making changes faster. */
  173. #define ffconfigWRITE_FREE_COUNT 0
  174. #endif
  175. #if !defined( ffconfigTIME_SUPPORT )
  176. /* Set to 1 to maintain file and directory time stamps for creation, modify
  177. * and last access.
  178. *
  179. * Set to 0 to exclude time stamps.
  180. *
  181. * If time support is used, the following function must be supplied:
  182. *
  183. * time_t FreeRTOS_time( time_t *pxTime );
  184. *
  185. * FreeRTOS_time has the same semantics as the standard time() function. */
  186. #define ffconfigTIME_SUPPORT 0
  187. #endif
  188. #if !defined( ffconfigREMOVABLE_MEDIA )
  189. /* Set to 1 if the media is removable (such as a memory card).
  190. *
  191. * Set to 0 if the media is not removable.
  192. *
  193. * When set to 1 all file handles will be "invalidated" if the media is
  194. * extracted. If set to 0 then file handles will not be invalidated.
  195. * In that case the user will have to confirm that the media is still present
  196. * before every access. */
  197. #define ffconfigREMOVABLE_MEDIA 0
  198. #endif
  199. #if !defined( ffconfigMOUNT_FIND_FREE )
  200. /* Set to 1 to determine the disk's free space and the disk's first free
  201. * cluster when a disk is mounted.
  202. *
  203. * Set to 0 to find these two values when they are first needed. Determining
  204. * the values can take some time. */
  205. #define ffconfigMOUNT_FIND_FREE 0
  206. #endif
  207. #if !defined( ffconfigFSINFO_TRUSTED )
  208. /* Set to 1 to 'trust' the contents of the 'ulLastFreeCluster' and
  209. * ulFreeClusterCount fields.
  210. *
  211. * Set to 0 not to 'trust' these fields.*/
  212. #define ffconfigFSINFO_TRUSTED 0
  213. #endif
  214. #if !defined( ffconfigFINDAPI_ALLOW_WILDCARDS )
  215. /* For now must be set to 0. */
  216. #define ffconfigFINDAPI_ALLOW_WILDCARDS 0
  217. #endif
  218. #if !defined( ffconfigWILDCARD_CASE_INSENSITIVE )
  219. /* For now must be set to 0. */
  220. #define ffconfigWILDCARD_CASE_INSENSITIVE 0
  221. #endif
  222. #if !defined( ffconfigPATH_CACHE )
  223. /* Set to 1 to store recent paths in a cache, enabling much faster access
  224. * when the path is deep within a directory structure at the expense of
  225. * additional RAM usage.
  226. *
  227. * Set to 0 to not use a path cache. */
  228. #define ffconfigPATH_CACHE 0
  229. #endif
  230. #if !defined( ffconfigPATH_CACHE_DEPTH )
  231. /* Only used if ffconfigPATH_CACHE is 1.
  232. *
  233. * Sets the maximum number of paths that can exist in the patch cache at any
  234. * one time. */
  235. #define ffconfigPATH_CACHE_DEPTH 5
  236. #endif
  237. #if !defined( ffconfigHASH_CACHE )
  238. /* Set to 1 to calculate a HASH value for each existing short file name.
  239. * Use of HASH values can improve performance when working with large
  240. * directories, or with files that have a similar name.
  241. *
  242. * Set to 0 not to calculate a HASH value. */
  243. #define ffconfigHASH_CACHE 0
  244. #endif
  245. #if ( ffconfigHASH_CACHE != 0 )
  246. #if !defined( ffconfigHASH_FUNCTION )
  247. /* Only used if ffconfigHASH_CACHE is set to 1
  248. *
  249. * Set to CRC8 or CRC16 to use 8-bit or 16-bit HASH values respectively. */
  250. #define ffconfigHASH_FUNCTION CRC16
  251. #endif
  252. #if ffconfigHASH_FUNCTION == CRC16
  253. #define ffconfigHASH_TABLE_SIZE 8192
  254. #elif ffconfigHASH_FUNCTION == CRC8
  255. #define ffconfigHASH_TABLE_SIZE 32
  256. #else
  257. #error Invalid Hashing function selected. CRC16 or CRC8. See your FreeRTOSFATConfig.h.
  258. #endif
  259. #endif /* ffconfigHASH_CACHE != 0 */
  260. #if !defined( ffconfigMKDIR_RECURSIVE )
  261. /* Set to 1 to add a parameter to ff_mkdir() that allows an entire directory
  262. * tree to be created in one go, rather than having to create one directory in
  263. * the tree at a time. For example mkdir( "/etc/settings/network", pdTRUE );.
  264. *
  265. * Set to 0 to use the normal mkdir() semantics (without the additional
  266. * parameter). */
  267. #define ffconfigMKDIR_RECURSIVE 0
  268. #endif
  269. #if !defined( ffconfigMALLOC )
  270. /* Set to a function that will be used for all dynamic memory allocations.
  271. * Setting to pvPortMalloc() will use the same memory allocator as FreeRTOS. */
  272. #define ffconfigMALLOC( size ) pvPortMalloc( size )
  273. #endif
  274. #if !defined( ffconfigFREE )
  275. /* Set to a function that matches the above allocator defined with
  276. * ffconfigMALLOC. Setting to vPortFree() will use the same memory free
  277. * function as FreeRTOS. */
  278. #define ffconfigFREE( ptr ) vPortFree( ptr )
  279. #endif
  280. #if !defined( ffconfig64_NUM_SUPPORT )
  281. /* Set to 1 to calculate the free size and volume size as a 64-bit number.
  282. *
  283. * Set to 0 to calculate these values as a 32-bit number. */
  284. #define ffconfig64_NUM_SUPPORT 0
  285. #endif
  286. #if !defined( ffconfigMAX_PARTITIONS )
  287. /* Defines the maximum number of partitions (and also logical partitions)
  288. * that can be recognised. */
  289. #define ffconfigMAX_PARTITIONS 4
  290. #endif
  291. #if ( ffconfigMAX_PARTITIONS < 1 ) || ( ffconfigMAX_PARTITIONS > 8 )
  292. #error ffconfigMAX_PARTITIONS must be between 1 and 8
  293. #endif
  294. #if !defined( ffconfigMAX_FILE_SYS )
  295. /* Defines how many drives can be combined in total. Should be set to at
  296. * least 2. */
  297. #define ffconfigMAX_FILE_SYS 4
  298. #endif
  299. #if !defined( ffconfigDRIVER_BUSY_SLEEP_MS )
  300. /* In case the low-level driver returns an error 'FF_ERR_DRIVER_BUSY',
  301. * the library will pause for a number of ms, defined in
  302. * ffconfigDRIVER_BUSY_SLEEP_MS before re-trying. */
  303. #define ffconfigDRIVER_BUSY_SLEEP_MS 20
  304. #endif
  305. #if !defined( ffconfigFPRINTF_SUPPORT )
  306. /* Set to 1 to include the ff_fprintf() function.
  307. *
  308. * Set to 0 to exclude the ff_fprintf() function.
  309. *
  310. * ff_fprintf() is quite a heavy function because it allocates RAM and
  311. * brings in a lot of string and variable argument handling code. If
  312. * ff_fprintf() is not being used then the code size can be reduced by setting
  313. * ffconfigFPRINTF_SUPPORT to 0. */
  314. #define ffconfigFPRINTF_SUPPORT 0
  315. #endif
  316. #if !defined( ffconfigFPRINTF_BUFFER_LENGTH )
  317. /* ff_fprintf() will allocate a buffer of this size in which it will create
  318. * its formatted string. The buffer will be freed before the function
  319. * exits. */
  320. #define ffconfigFPRINTF_BUFFER_LENGTH 128
  321. #endif
  322. #if !defined( ffconfigDEBUG )
  323. #define ffconfigDEBUG 0
  324. #endif
  325. #if !defined( ffconfigLONG_ERR_MSG )
  326. #define ffconfigLONG_ERR_MSG 0
  327. #endif
  328. #if ( ffconfigDEBUG != 0 )
  329. #if !defined( ffconfigHAS_FUNCTION_TAB )
  330. #define ffconfigHAS_FUNCTION_TAB 1
  331. #endif
  332. #endif
  333. #if !defined( ffconfigINLINE_MEMORY_ACCESS )
  334. /* Set to 1 to inline some internal memory access functions.
  335. *
  336. * Set to 0 to not inline the memory access functions. */
  337. #define ffconfigINLINE_MEMORY_ACCESS 0
  338. #endif
  339. #if !defined( ffconfigMIRROR_FATS_UMOUNT )
  340. /*_RB_ not sure. */
  341. #define ffconfigMIRROR_FATS_UMOUNT 0
  342. #endif
  343. #if !defined( ffconfigFAT_CHECK )
  344. /* Officially the only criteria to determine the FAT type (12, 16, or 32
  345. * bits) is the total number of clusters:
  346. * if( ulNumberOfClusters < 4085 ) : Volume is FAT12
  347. * if( ulNumberOfClusters < 65525 ) : Volume is FAT16
  348. * if( ulNumberOfClusters >= 65525 ) : Volume is FAT32
  349. * Not every formatted device follows the above rule.
  350. *
  351. * Set to 1 to perform additional checks over and above inspecting the
  352. * number of clusters on a disk to determine the FAT type.
  353. *
  354. * Set to 0 to only look at the number of clusters on a disk to determine the
  355. * FAT type. */
  356. #define ffconfigFAT_CHECK 0
  357. #endif
  358. #if !defined( ffconfigMAX_FILENAME )
  359. /* Sets the maximum length for file names, including the path.
  360. * Note that the value of this define is directly related to the maximum stack
  361. * use of the +FAT library. In some API's, a character buffer of size
  362. * 'ffconfigMAX_FILENAME' will be declared on stack. As such, this value should
  363. * include space for the null byte. */
  364. #define ffconfigMAX_FILENAME 129
  365. #endif
  366. #if !defined( ffconfigUSE_DELTREE )
  367. /* By default, do not include the recursive function ff_deltree() as
  368. * recursion breaches the coding standard - USE WITH CARE. */
  369. #define ffconfigUSE_DELTREE 0
  370. #endif
  371. #if !defined( ffconfigFILE_EXTEND_FLUSHES_BUFFERS )
  372. /* When writing large files, the contents of the FAT entries will be flushed
  373. * after every call to FF_Write(). This flushing can be inhibited, by defining
  374. * ffconfigFILE_EXTEND_FLUSHES_BUFFERS as 0. */
  375. #define ffconfigFILE_EXTEND_FLUSHES_BUFFERS 1
  376. #endif
  377. #if !defined( FF_PRINTF )
  378. #define FF_PRINTF FF_PRINTF
  379. static portINLINE void FF_PRINTF( const char * pcFormat,
  380. ... )
  381. {
  382. ( void ) pcFormat;
  383. }
  384. #endif
  385. #ifndef ffconfigFAT_USES_STAT
  386. /* When enabled, the library keeps statistics about the use of cache
  387. * buffers. This can be useful while configuring or optimising the
  388. * cache size. */
  389. #define ffconfigFAT_USES_STAT 0
  390. #endif
  391. #ifndef ffconfigUSE_NOTIFY
  392. /* When defined, the driver will call a user hook "callFileEvents()"
  393. * for certain events: creation, change, and deletion of a file or
  394. * directory.
  395. * For instance: it can be useful to get an event as soon as a set-up
  396. * file has changed, or when a lock-file has been placed or removed.
  397. */
  398. #define ffconfigUSE_NOTIFY 0
  399. #endif
  400. #ifndef ffconfigDEV_SUPPORT
  401. /* A rarely used feature of FreeRTOS+FAT which lets files behave
  402. * as 'devices'. */
  403. #define ffconfigDEV_SUPPORT 0
  404. #endif
  405. #ifndef USE_SOFT_WDT
  406. /* When true. a user-provided function `clearWDT()` will be called
  407. * during a long action. */
  408. #define USE_SOFT_WDT 0
  409. #endif
  410. #ifndef ffconfigNOT_USED_FOR_NOW
  411. /* This macro was once used for debugging.
  412. * When defined as 1, the function 'FF_Utf16ctoUtf32c()'
  413. * will be compiled */
  414. #define ffconfigNOT_USED_FOR_NOW 0
  415. #endif
  416. #ifndef FF_NOSTRCASECMP
  417. /* When zero, the function 'strcasecmp()' will be defined. */
  418. #define FF_NOSTRCASECMP 0
  419. #endif
  420. /* Allow backword compatibility if desired */
  421. #ifndef ffconfigENABLE_BACKWARD_COMPATIBILITY
  422. #define ffconfigENABLE_BACKWARD_COMPATIBILITY 1
  423. #endif
  424. #if ffconfigENABLE_BACKWARD_COMPATIBILITY == 1
  425. #define FF_CreateIOManger FF_CreateIOManager
  426. #endif /* ffconfigENABLE_BACKWARD_COMPATIBILITY */
  427. #endif /* ifndef FF_DEFAULTCONFIG_H */