FreeRTOSFATConfigDefaults.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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. /* The error numbers defined in this file will be moved to the core FreeRTOS
  28. * code in future versions of FreeRTOS - at which time the following header file
  29. * will be removed. */
  30. #include "FreeRTOS_errno_FAT.h"
  31. #if !defined( ffconfigBYTE_ORDER )
  32. /* Must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN,
  33. * depending on the endian of the architecture on which FreeRTOS is running. */
  34. #error Invalid FreeRTOSFATConfig.h file: ffconfigBYTE_ORDER must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN
  35. #endif
  36. #if ( ffconfigBYTE_ORDER != pdFREERTOS_LITTLE_ENDIAN ) && ( ffconfigBYTE_ORDER != pdFREERTOS_BIG_ENDIAN )
  37. #error Invalid FreeRTOSFATConfig.h file: ffconfigBYTE_ORDER must be set to either pdFREERTOS_LITTLE_ENDIAN or pdFREERTOS_BIG_ENDIAN
  38. #endif
  39. #if ( pdFREERTOS_LITTLE_ENDIAN != 0 ) || ( pdFREERTOS_BIG_ENDIAN != 1 )
  40. #error Invalid projdefs.h or FreeRTOS_errno_FAT.h file
  41. #endif
  42. #if !defined( ffconfigHAS_CWD )
  43. /* Set to 1 to maintain a current working directory (CWD) for each task that
  44. * accesses the file system, allowing relative paths to be used.
  45. *
  46. * Set to 0 not to use a CWD, in which case full paths must be used for each
  47. * file access. */
  48. #define ffconfigHAS_CWD 0
  49. #if !defined( ffconfigCWD_THREAD_LOCAL_INDEX )
  50. #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.
  51. #endif
  52. #endif
  53. #if !defined( ffconfigLFN_SUPPORT )
  54. /* Set to 1 to include long file name support. Set to 0 to exclude long
  55. * file name support.
  56. *
  57. * If long file name support is excluded then only 8.3 file names can be used.
  58. * Long file names will be recognised but ignored.
  59. *
  60. * Users should familiarise themselves with any patent issues that may
  61. * potentially exist around the use of long file names in FAT file systems
  62. * before enabling long file name support. */
  63. #define ffconfigLFN_SUPPORT 0
  64. #endif
  65. #if !defined( ffconfigINCLUDE_SHORT_NAME )
  66. /* Only used when ffconfigLFN_SUPPORT is set to 1.
  67. *
  68. * Set to 1 to include a file's short name when listing a directory, i.e. when
  69. * calling findfirst()/findnext(). The short name will be stored in the
  70. * 'pcShortName' field of FF_DirEnt_t.
  71. *
  72. * Set to 0 to only include a file's long name. */
  73. #define ffconfigINCLUDE_SHORT_NAME 0
  74. #endif
  75. #if !defined( ffconfigSHORTNAME_CASE )
  76. /* Set to 1 to recognise and apply the case bits used by Windows XP+ when
  77. * using short file names - storing file names such as "readme.TXT" or
  78. * "SETUP.exe" in a short-name entry. This is the recommended setting for
  79. * maximum compatibility.
  80. *
  81. * Set to 0 to ignore the case bits. */
  82. #define ffconfigSHORTNAME_CASE 0
  83. #endif
  84. #if !defined( ipconfigQUICK_SHORT_FILENAME_CREATION )
  85. /* This method saves a lot of time when creating directories with
  86. * many similar file names: when the short name version of a LFN already
  87. * exists, try at most 3 entries with a tilde:
  88. * README~1.TXT
  89. * README~2.TXT
  90. * README~3.TXT
  91. * After that create entries with pseudo-random 4-digit hex digits:
  92. * REA~E7BB.TXT
  93. * REA~BA32.TXT
  94. * REA~D394.TXT
  95. */
  96. #define ipconfigQUICK_SHORT_FILENAME_CREATION 1
  97. #endif
  98. /* ASCII versus UNICODE, UTF-16 versus UTF-8 :
  99. * FAT directories, when using Long File Names, always store file and directory
  100. * names UTF-16 encoded.
  101. * The user can select how these names must be represented internally:
  102. * - ASCII (default)
  103. * - UTF-8 (ffconfigUNICODE_UTF8_SUPPORT = 1)
  104. * - UTF-16 (ffconfigUNICODE_UTF16_SUPPORT = 1)
  105. */
  106. #if ( ffconfigUNICODE_UTF16_SUPPORT == 0 )
  107. /* Only used when ffconfigLFN_SUPPORT is set to 1.
  108. *
  109. * Set to 1 to use UTF-16 (wide-characters) for file and directory names.
  110. *
  111. * Set to 0 to use either 8-bit ASCII or UTF-8 for file and directory names
  112. * (see the ffconfigUNICODE_UTF8_SUPPORT). */
  113. #define ffconfigUNICODE_UTF16_SUPPORT 0
  114. #endif
  115. #if !defined( ffconfigUNICODE_UTF8_SUPPORT )
  116. /* Only used when ffconfigLFN_SUPPORT is set to 1.
  117. *
  118. * Set to 1 to use UTF-8 encoding for file and directory names.
  119. *
  120. * Set to 0 to use either 8-bit ASCII or UTF-16 for file and directory
  121. * names (see the ffconfig_UTF_16_SUPPORT setting). */
  122. #define ffconfigUNICODE_UTF8_SUPPORT 0
  123. #endif
  124. #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) && ( ffconfigUNICODE_UTF8_SUPPORT != 0 )
  125. #error Can not use both UTF-16 and UTF-8
  126. #endif
  127. #if !defined( ffconfigFAT12_SUPPORT )
  128. /* Set to 1 to include FAT12 support.
  129. *
  130. * Set to 0 to exclude FAT12 support.
  131. *
  132. * FAT16 and FAT32 are always enabled. */
  133. #define ffconfigFAT12_SUPPORT 0
  134. #endif
  135. #if !defined( ffconfigOPTIMISE_UNALIGNED_ACCESS )
  136. /* When writing and reading data, i/o becomes less efficient if sizes other
  137. * than the sector size (usually 512 bytes) are being used. When set to 1, each file handle will
  138. * allocate a one sector size character buffer to facilitate "unaligned access". */
  139. #define ffconfigOPTIMISE_UNALIGNED_ACCESS 0
  140. #endif
  141. #if !defined( ffconfigCACHE_WRITE_THROUGH )
  142. /* Input and output to a disk uses buffers that are only flushed at the
  143. * following times:
  144. *
  145. * - When a new buffer is needed and no other buffers are available.
  146. * - When opening a buffer in READ mode for a sector that has just been changed.
  147. * - After creating, removing or closing a file or a directory.
  148. *
  149. * Normally this is quick enough and it is efficient. If
  150. * ffconfigCACHE_WRITE_THROUGH is set to 1 then buffers will also be flushed each
  151. * time a buffer is released - which is less efficient but more secure. */
  152. #define ffconfigCACHE_WRITE_THROUGH 0
  153. #endif
  154. #if !defined( ffconfigWRITE_BOTH_FATS )
  155. /* In most cases, the FAT table has two identical copies on the disk,
  156. * allowing the second copy to be used in the case of a read error. If
  157. *
  158. * Set to 1 to use both FATs - this is less efficient but more secure.
  159. *
  160. * Set to 0 to use only one FAT - the second FAT will never be written to. */
  161. #define ffconfigWRITE_BOTH_FATS 0
  162. #endif
  163. #if !defined( ffconfigWRITE_FREE_COUNT )
  164. /* Set to 1 to have the number of free clusters and the first free cluster
  165. * to be written to the FS info sector each time one of those values changes.
  166. *
  167. * Set to 0 not to store these values in the FS info sector, making booting
  168. * slower, but making changes faster. */
  169. #define ffconfigWRITE_FREE_COUNT 0
  170. #endif
  171. #if !defined( ffconfigTIME_SUPPORT )
  172. /* Set to 1 to maintain file and directory time stamps for creation, modify
  173. * and last access.
  174. *
  175. * Set to 0 to exclude time stamps.
  176. *
  177. * If time support is used, the following function must be supplied:
  178. *
  179. * time_t FreeRTOS_time( time_t *pxTime );
  180. *
  181. * FreeRTOS_time has the same semantics as the standard time() function. */
  182. #define ffconfigTIME_SUPPORT 0
  183. #endif
  184. #if !defined( ffconfigREMOVABLE_MEDIA )
  185. /* Set to 1 if the media is removable (such as a memory card).
  186. *
  187. * Set to 0 if the media is not removable.
  188. *
  189. * When set to 1 all file handles will be "invalidated" if the media is
  190. * extracted. If set to 0 then file handles will not be invalidated.
  191. * In that case the user will have to confirm that the media is still present
  192. * before every access. */
  193. #define ffconfigREMOVABLE_MEDIA 0
  194. #endif
  195. #if !defined( ffconfigMOUNT_FIND_FREE )
  196. /* Set to 1 to determine the disk's free space and the disk's first free
  197. * cluster when a disk is mounted.
  198. *
  199. * Set to 0 to find these two values when they are first needed. Determining
  200. * the values can take some time. */
  201. #define ffconfigMOUNT_FIND_FREE 0
  202. #endif
  203. #if !defined( ffconfigFSINFO_TRUSTED )
  204. /* Set to 1 to 'trust' the contents of the 'ulLastFreeCluster' and
  205. * ulFreeClusterCount fields.
  206. *
  207. * Set to 0 not to 'trust' these fields.*/
  208. #define ffconfigFSINFO_TRUSTED 0
  209. #endif
  210. #if !defined( ffconfigFINDAPI_ALLOW_WILDCARDS )
  211. /* For now must be set to 0. */
  212. #define ffconfigFINDAPI_ALLOW_WILDCARDS 0
  213. #endif
  214. #if !defined( ffconfigWILDCARD_CASE_INSENSITIVE )
  215. /* For now must be set to 0. */
  216. #define ffconfigWILDCARD_CASE_INSENSITIVE 0
  217. #endif
  218. #if !defined( ffconfigPATH_CACHE )
  219. /* Set to 1 to store recent paths in a cache, enabling much faster access
  220. * when the path is deep within a directory structure at the expense of
  221. * additional RAM usage.
  222. *
  223. * Set to 0 to not use a path cache. */
  224. #define ffconfigPATH_CACHE 0
  225. #endif
  226. #if !defined( ffconfigPATH_CACHE_DEPTH )
  227. /* Only used if ffconfigPATH_CACHE is 1.
  228. *
  229. * Sets the maximum number of paths that can exist in the patch cache at any
  230. * one time. */
  231. #define ffconfigPATH_CACHE_DEPTH 5
  232. #endif
  233. #if !defined( ffconfigHASH_CACHE )
  234. /* Set to 1 to calculate a HASH value for each existing short file name.
  235. * Use of HASH values can improve performance when working with large
  236. * directories, or with files that have a similar name.
  237. *
  238. * Set to 0 not to calculate a HASH value. */
  239. #define ffconfigHASH_CACHE 0
  240. #endif
  241. #if ( ffconfigHASH_CACHE != 0 )
  242. #if !defined( ffconfigHASH_FUNCTION )
  243. /* Only used if ffconfigHASH_CACHE is set to 1
  244. *
  245. * Set to CRC8 or CRC16 to use 8-bit or 16-bit HASH values respectively. */
  246. #define ffconfigHASH_FUNCTION CRC16
  247. #endif
  248. #if ffconfigHASH_FUNCTION == CRC16
  249. #define ffconfigHASH_TABLE_SIZE 8192
  250. #elif ffconfigHASH_FUNCTION == CRC8
  251. #define ffconfigHASH_TABLE_SIZE 32
  252. #else
  253. #error Invalid Hashing function selected. CRC16 or CRC8. See your FreeRTOSFATConfig.h.
  254. #endif
  255. #endif /* ffconfigHASH_CACHE != 0 */
  256. #if !defined( ffconfigMKDIR_RECURSIVE )
  257. /* Set to 1 to add a parameter to ff_mkdir() that allows an entire directory
  258. * tree to be created in one go, rather than having to create one directory in
  259. * the tree at a time. For example mkdir( "/etc/settings/network", pdTRUE );.
  260. *
  261. * Set to 0 to use the normal mkdir() semantics (without the additional
  262. * parameter). */
  263. #define ffconfigMKDIR_RECURSIVE 0
  264. #endif
  265. #if !defined( ffconfigMALLOC )
  266. /* Set to a function that will be used for all dynamic memory allocations.
  267. * Setting to pvPortMalloc() will use the same memory allocator as FreeRTOS. */
  268. #define ffconfigMALLOC( size ) pvPortMalloc( size )
  269. #endif
  270. #if !defined( ffconfigFREE )
  271. /* Set to a function that matches the above allocator defined with
  272. * ffconfigMALLOC. Setting to vPortFree() will use the same memory free
  273. * function as FreeRTOS. */
  274. #define ffconfigFREE( ptr ) vPortFree( ptr )
  275. #endif
  276. #if !defined( ffconfig64_NUM_SUPPORT )
  277. /* Set to 1 to calculate the free size and volume size as a 64-bit number.
  278. *
  279. * Set to 0 to calculate these values as a 32-bit number. */
  280. #define ffconfig64_NUM_SUPPORT 0
  281. #endif
  282. #if !defined( ffconfigMAX_PARTITIONS )
  283. /* Defines the maximum number of partitions (and also logical partitions)
  284. * that can be recognised. */
  285. #define ffconfigMAX_PARTITIONS 4
  286. #endif
  287. #if !defined( ffconfigMAX_FILE_SYS )
  288. /* Defines how many drives can be combined in total. Should be set to at
  289. * least 2. */
  290. #define ffconfigMAX_FILE_SYS 4
  291. #endif
  292. #if !defined( ffconfigDRIVER_BUSY_SLEEP_MS )
  293. /* In case the low-level driver returns an error 'FF_ERR_DRIVER_BUSY',
  294. * the library will pause for a number of ms, defined in
  295. * ffconfigDRIVER_BUSY_SLEEP_MS before re-trying. */
  296. #define ffconfigDRIVER_BUSY_SLEEP_MS 20
  297. #endif
  298. #if !defined( ffconfigFPRINTF_SUPPORT )
  299. /* Set to 1 to include the ff_fprintf() function.
  300. *
  301. * Set to 0 to exclude the ff_fprintf() function.
  302. *
  303. * ff_fprintf() is quite a heavy function because it allocates RAM and
  304. * brings in a lot of string and variable argument handling code. If
  305. * ff_fprintf() is not being used then the code size can be reduced by setting
  306. * ffconfigFPRINTF_SUPPORT to 0. */
  307. #define ffconfigFPRINTF_SUPPORT 0
  308. #endif
  309. #if !defined( ffconfigFPRINTF_BUFFER_LENGTH )
  310. /* ff_fprintf() will allocate a buffer of this size in which it will create
  311. * its formatted string. The buffer will be freed before the function
  312. * exits. */
  313. #define ffconfigFPRINTF_BUFFER_LENGTH 128
  314. #endif
  315. #if !defined( ffconfigDEBUG )
  316. #define ffconfigDEBUG 0
  317. #endif
  318. #if !defined( ffconfigLONG_ERR_MSG )
  319. #define ffconfigLONG_ERR_MSG 0
  320. #endif
  321. #if ( ffconfigDEBUG != 0 )
  322. #if !defined( ffconfigHAS_FUNCTION_TAB )
  323. #define ffconfigHAS_FUNCTION_TAB 1
  324. #endif
  325. #endif
  326. #if !defined( ffconfigINLINE_MEMORY_ACCESS )
  327. /* Set to 1 to inline some internal memory access functions.
  328. *
  329. * Set to 0 to not inline the memory access functions. */
  330. #define ffconfigINLINE_MEMORY_ACCESS 0
  331. #endif
  332. #if !defined( ffconfigMIRROR_FATS_UMOUNT )
  333. /*_RB_ not sure. */
  334. #define ffconfigMIRROR_FATS_UMOUNT 0
  335. #endif
  336. #if !defined( ffconfigFAT_CHECK )
  337. /* Officially the only criteria to determine the FAT type (12, 16, or 32
  338. * bits) is the total number of clusters:
  339. * if( ulNumberOfClusters < 4085 ) : Volume is FAT12
  340. * if( ulNumberOfClusters < 65525 ) : Volume is FAT16
  341. * if( ulNumberOfClusters >= 65525 ) : Volume is FAT32
  342. * Not every formatted device follows the above rule.
  343. *
  344. * Set to 1 to perform additional checks over and above inspecting the
  345. * number of clusters on a disk to determine the FAT type.
  346. *
  347. * Set to 0 to only look at the number of clusters on a disk to determine the
  348. * FAT type. */
  349. #define ffconfigFAT_CHECK 0
  350. #endif
  351. #if !defined( ffconfigMAX_FILENAME )
  352. /* Sets the maximum length for file names, including the path.
  353. * Note that the value of this define is directly related to the maximum stack
  354. * use of the +FAT library. In some API's, a character buffer of size
  355. * 'ffconfigMAX_FILENAME' will be declared on stack. */
  356. #define ffconfigMAX_FILENAME 129
  357. #endif
  358. #if !defined( ffconfigUSE_DELTREE )
  359. /* By default, do not include the recursive function ff_deltree() as
  360. * recursion breaches the coding standard - USE WITH CARE. */
  361. #define ffconfigUSE_DELTREE 0
  362. #endif
  363. #if !defined( ffconfigFILE_EXTEND_FLUSHES_BUFFERS )
  364. /* When writing large files, the contents of the FAT entries will be flushed
  365. * after every call to FF_Write(). This flushing can be inhibited, by defining
  366. * ffconfigFILE_EXTEND_FLUSHES_BUFFERS as 0. */
  367. #define ffconfigFILE_EXTEND_FLUSHES_BUFFERS 1
  368. #endif
  369. #if !defined( FF_PRINTF )
  370. #define FF_PRINTF FF_PRINTF
  371. static portINLINE void FF_PRINTF( const char * pcFormat,
  372. ... )
  373. {
  374. ( void ) pcFormat;
  375. }
  376. #endif
  377. #endif /* ifndef FF_DEFAULTCONFIG_H */