config.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta http-equiv="Content-Style-Type" content="text/css">
  6. <link rel="up" title="FatFs" href="../00index_e.html">
  7. <link rel="alternate" hreflang="ja" title="Japanese" href="../ja/config.html">
  8. <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
  9. <title>FatFs - Configuration Options</title>
  10. </head>
  11. <body>
  12. <h1>Configuration Options</h1>
  13. <p>There are many options to configure the functions of FatFs for each project. The configuration options are defined in the <tt>ffconf.h</tt>.</p>
  14. <div class="para doc" id="func">
  15. <h3>Function Configurations</h3>
  16. <h4 id="fs_readonly">_FS_READONLY</h4>
  17. <p>Read/Write (0) or Read-only (1). Read-only configuration removes writing API functions, <tt>f_write</tt>, <tt>f_sync</tt>, <tt>f_unlink</tt>, <tt>f_mkdir</tt>, <tt>f_chmod</tt>, <tt>f_rename</tt>, <tt>f_truncate</tt>, <tt>f_getfree</tt> and optional writing functions as well.</p>
  18. <h4 id="fs_minimize">_FS_MINIMIZE</h4>
  19. <p>This option defines minimization level to remove some basic API functions as follows:</p>
  20. <table class="lst1">
  21. <tr><th>Value</th><th>Description</th></tr>
  22. <tr><td>0</td><td>All basic API functions are available.</td></tr>
  23. <tr><td>1</td><td><tt>f_stat</tt>, <tt>f_getfree</tt>, <tt>f_unlink</tt>, <tt>f_mkdir</tt>, <tt>f_chmod</tt>, <tt>f_utime</tt>, <tt>f_truncate</tt> and <tt>f_rename</tt> function are removed.</td></tr>
  24. <tr><td>2</td><td><tt>f_opendir</tt>, <tt>f_readdir</tt> and <tt>f_closedir</tt> function are removed in addition to 1.</td></tr>
  25. <tr><td>3</td><td><tt>f_lseek</tt> function is removed in addition to 2.</td></tr>
  26. </table>
  27. <h4 id="use_strfunc">_USE_STRFUNC</h4>
  28. <p>This option switches string functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>.</p>
  29. <table class="lst1">
  30. <tr><th>Value</th><th>Description</th></tr>
  31. <tr><td>0</td><td>Disable string functions.</td></tr>
  32. <tr><td>1</td><td>Enable string functions without LF-CRLF conversion.</td></tr>
  33. <tr><td>2</td><td>Enable string functions with LF-CRLF conversion.</td></tr>
  34. </table>
  35. <h4 id="use_find">_USE_FIND</h4>
  36. <p>Disable (0) or Enable (1) filtered directory read functions, <tt>f_findfirst</tt> and <tt>f_findnext</tt>. Also <tt>_FS_MINIMIZE</tt> needs to be 0 or 1.</p>
  37. <h4 id="use_mkfs">_USE_MKFS</h4>
  38. <p>Disable (0) or Enable (1) <tt>f_mkfs</tt> function.</p>
  39. <h4 id="use_fastseek">_USE_FASTSEEK</h4>
  40. <p>Disable (0) or Enable (1) fast seek function to enable accelerated mode for <tt>f_lseek</tt>, <tt>f_read</tt> and <tt>f_write</tt> function. For more information, read <a href="lseek.html">here</a>.</p>
  41. <h4 id="use_expand">_USE_EXPAND</h4>
  42. <p>Disable (0) or Enable (1) , <tt>f_enpand</tt> function. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
  43. <h4 id="use_chmod">_USE_CHMOD</h4>
  44. <p>Disable (0) or Enable (1) metadata control functions, <tt>f_chmod</tt> and <tt>f_utime</tt>. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
  45. <h4 id="use_label">_USE_LABEL</h4>
  46. <p>Disable (0) or Enable (1) API functions for volume label, <tt>f_getlabel</tt> and <tt>f_setlabel</tt>.</p>
  47. <h4 id="use_forward">_USE_FORWARD</h4>
  48. <p>Disable (0) or Enable (1) <tt>f_forward</tt> function.</p>
  49. </div>
  50. <div class="para doc" id="name">
  51. <h3>Namespace and Locale Configurations</h3>
  52. <h4 id="code_page">_CODE_PAGE</h4>
  53. <p>This option specifies the OEM code page to be used on the target system. Incorrect setting of the code page can cause a file open failure. If any extended character is not used at all, there is no difference between any code pages.</p>
  54. <table class="lst1">
  55. <tr><th>Value</th><th>Description</th></tr>
  56. <tr><td>1</td><td>ASCII (valid at non-LFN cfg.)</td></tr>
  57. <tr><td>437</td><td>U.S.</td></tr>
  58. <tr><td>720</td><td>Arabic</td></tr>
  59. <tr><td>737</td><td>Greek</td></tr>
  60. <tr><td>771</td><td>KBL</td></tr>
  61. <tr><td>775</td><td>Baltic</td></tr>
  62. <tr><td>850</td><td>Latin 1</td></tr>
  63. <tr><td>852</td><td>Latin 2</td></tr>
  64. <tr><td>855</td><td>Cyrillic</td></tr>
  65. <tr><td>857</td><td>Turkish</td></tr>
  66. <tr><td>860</td><td>Portuguese</td></tr>
  67. <tr><td>861</td><td>Icelandic</td></tr>
  68. <tr><td>862</td><td>Hebrew</td></tr>
  69. <tr><td>863</td><td>Canadian French</td></tr>
  70. <tr><td>864</td><td>Arabic</td></tr>
  71. <tr><td>865</td><td>Nordic</td></tr>
  72. <tr><td>866</td><td>Russian</td></tr>
  73. <tr><td>869</td><td>Greek 2</td></tr>
  74. <tr><td>932</td><td>Japanese (DBCS)</td></tr>
  75. <tr><td>936</td><td>Simplified Chinese (DBCS)</td></tr>
  76. <tr><td>949</td><td>Korean (DBCS)</td></tr>
  77. <tr><td>950</td><td>Traditional Chinese (DBCS)</td></tr>
  78. </table>
  79. <h4 id="use_lfn">_USE_LFN</h4>
  80. <p>This option switches the support for long file name (LFN). When enable the LFN, Unicode support functions <tt>option/unicode.c</tt> need to be added to the project. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes and additional 608 bytes when exFAT enabled. When use stack for the working buffer, take care on stack overflow. When use heap memory for the working buffer, memory management functions, <tt>ff_memalloc</tt> and <tt>ff_memfree</tt>, need to be added to the project.</p>
  81. <table class="lst1">
  82. <tr><th>Value</th><th>Description</th></tr>
  83. <tr><td>0</td><td>Disable LFN. Only 8.3 format can be used.</td></tr>
  84. <tr><td>1</td><td>Enable LFN with static working buffer on the BSS. Always NOT thread-safe.</td></tr>
  85. <tr><td>2</td><td>Enable LFN with dynamic working buffer on the STACK.</td></tr>
  86. <tr><td>3</td><td>Enable LFN with dynamic working buffer on the HEAP.</td></tr>
  87. </table>
  88. <h4 id="max_lfn">_MAX_LFN</h4>
  89. <p>This option defines the size of LFN working buffer from 12 to 255 in unit of character. This option has no effect when LFN is disabled.</p>
  90. <h4 id="lfn_unicode">_LFN_UNICODE</h4>
  91. <p>ANSI/OEM (0) or Unicode (1). This option switches character encoding on the API. To use Unicode (UTF16) string for the path name, enable LFN and set this option to 1. This option also affects behavior of string I/O functions. When LFN is disabled, this option must be 0. For more information, read <a href="filename.html#uni">here</a>.</p>
  92. <h4 id="strf_encode">_STRF_ENCODE</h4>
  93. <p>When Unicode API is selected by setting <tt>_LFN_UNICODE</tt> 1, this option defines the assumption of character encoding on the file to be read/written via string I/O functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>. This option has no effect when <tt>_LFN_UNICODE = 0</tt>.</p>
  94. <table class="lst1">
  95. <tr><th>Value</th><th>Description</th></tr>
  96. <tr><td>0</td><td>ANSI/OEM</td></tr>
  97. <tr><td>1</td><td>UTF-16LE</td></tr>
  98. <tr><td>2</td><td>UTF-16BE</td></tr>
  99. <tr><td>3</td><td>UTF-8</td></tr>
  100. </table>
  101. <h4 id="fs_rpath">_FS_RPATH</h4>
  102. <p>This option configures relative path function. For more information, read <a href="filename.html#nam">here</a>.</p>
  103. <table class="lst1">
  104. <tr><th>Value</th><th>Description</th></tr>
  105. <tr><td>0</td><td>Disable relative path function and remove related functions.</td></tr>
  106. <tr><td>1</td><td>Enable relative path function. <tt>f_chdir</tt> and <tt>f_chdrive</tt> function is available.</td></tr>
  107. <tr><td>2</td><td><tt>f_getcwd</tt> function is available in addition to 1</td></tr>
  108. </table>
  109. </div>
  110. <div class="para doc" id="volume">
  111. <h3>Volume/Drive Configurations</h3>
  112. <h4 id="volumes">_VOLUMES</h4>
  113. <p>This option configures number of volumes (logical drives, from 1 to 10) to be used.</p>
  114. <h4 id="str_volume_id">_STR_VOLUME_ID</h4>
  115. <p>Disable (0) or Enable (1). This option switches the support for string volume ID. When enabled, also pre-defined strings in <tt>_VOLUME_STRS</tt> can be used as drive identifier in the path name.</p>
  116. <h4 id="volume_strs">_VOLUME_STRS</h4>
  117. <p>This option defines the drive ID strings for each logical drives. Number of items must not be less than <tt>_VOLUMES</tt>. Valid characters for the drive ID string are: A-Z and 0-9.</p>
  118. <h4 id="multi_partition">_MULTI_PARTITION</h4>
  119. <p>Disable (0) or Enable (1). This option switches multi-partition function. By default (0), each logical drive number is bound to the same physical drive number and only an FAT volume in the physical drive is mounted. When enabled, each logical drive is bound to the partition on the physical drive listed in the user defined partition resolution table <tt>VolToPart[]</tt>. Also <tt>f_fdisk</tt> funciton will be available. For more information, read <a href="filename.html#vol">here</a>.</p>
  120. <h4 id="max_ss">_MIN_SS, _MAX_SS</h4>
  121. <p>This set of options defines the size of sector on low level disk I/O interface, <tt>disk_read</tt> and <tt>disk_write</tt> function. Valid values are 512, 1024, 2048 and 4096. <tt>_MIN_SS</tt> defines minimum sector size and <tt>_MAX_SS</tt> defines the maximum sector size. Always set both 512 for any type of memory card and harddisk. But a larger value may be required for on-board flash memory and some type of optical media. When <tt>_MAX_SS &gt; _MIN_SS</tt>, FatFs is configured to variable sector size and <tt>GET_SECTOR_SIZE</tt> command must be implemented to the <tt>disk_ioctl</tt> function.</p>
  122. <h4 id="use_trim">_USE_TRIM</h4>
  123. <p>Disable (0) or Enable (1). This option switches ATA-TRIM function. To enable Trim function, also <tt>CTRL_TRIM</tt> command should be implemented to the <tt>disk_ioctl</tt> function.</p>
  124. <h4 id="fs_nofsinfo">_FS_NOFSINFO</h4>
  125. <p>0 to 3. If you need to know correct free space on the FAT32 volume, set bit 0 of this option, and <tt>f_getfree</tt> function at first time after volume mount will force a full FAT scan. Bit 1 controls the use of last allocated cluster number.</p>
  126. <table class="lst1">
  127. <tr><th>Value</th><th>Description</th></tr>
  128. <tr><td>bit0=0</td><td>Use free cluster count in the FSINFO if available.</td></tr>
  129. <tr><td>bit0=1</td><td>Do not trust free cluster count in the FSINFO.</td></tr>
  130. <tr><td>bit1=0</td><td>Use last allocated cluster number in the FSINFO to find a free cluster if available.</td></tr>
  131. <tr><td>bit1=1</td><td>Do not trust last allocated cluster number in the FSINFO.</td></tr>
  132. </table>
  133. </div>
  134. <div class="para doc" id="system">
  135. <h3>System Configurations</h3>
  136. <h4 id="fs_tiny">_FS_TINY</h4>
  137. <p>Normal (0) or Tiny (1). At the tiny configuration, size of the file object <tt>FIL</tt> is reduced <tt>_MAX_SS</tt> bytes. Instead of private data buffer eliminated from the file object, common sector buffer in the file system object <tt>FATFS</tt> is used for the file data transfer.</p>
  138. <h4 id="fs_exfat">_FS_EXFAT</h4>
  139. <p>This option switches support for the exFAT file system in addition to the FAT file system, Enabled(1) or Disabled(1). To enable this feature, also LFN must be enabled and configureing <tt>_LFN_UNICODE = 1</tt> and <tt>_MAX_LFN = 255</tt> is recommended for full-featured exFAT function. Note that enabling exFAT discards C89 compatibility because of need for 64-bit integer type.</p>
  140. <h4 id="fs_nortc">_FS_NORTC</h4>
  141. <p>Use RTC (0) or Do not use RTC (1). This option controls timestamp function. If the system does not have an RTC function or valid timestamp is not needed, set <tt>_FS_NORTC</tt> to 1 to disable the timestamp function. Any object modified by FatFs will have a fixed timestamp defined by <tt>_NORTC_MON</tt>, <tt>_NORTC_MDAY</tt> and <tt>_NORTC_YEAR</tt>. To use the timestamp function, set <tt>_FS_NORTC = 0</tt> and add <tt>get_fattime</tt> function to the project to get the current time form real-time clock. This option has no effect at read-only configuration.</p>
  142. <h4 id="nortc_time">_NORTC_MON, _NORTC_MDAY, _NORTC_YEAR</h4>
  143. <p>This set of options defines the time to be used at no RTC systems. This option has no effect at read-only configuration or <tt>_FS_NORTC = 0</tt>.</p>
  144. <h4 id="fs_lock">_FS_LOCK</h4>
  145. <p>This option switches file lock function to control duplicated file open and illegal operations to open objects. Note that the file lock function is independent of re-entrancy. This option must be 0 at read-only configuration.</p>
  146. <table class="lst1">
  147. <tr><th>Value</th><th>Description</th></tr>
  148. <tr><td>0</td><td>Disable file lock function. To avoid collapsing file by wrong file operation, application program needs to avoid illegal open, remove and rename to the open objects.</td></tr>
  149. <tr><td>&gt;0</td><td>Enable file lock function. The value defines how many files/sub-directories can be opened simultaneously under the file lock control. Illigal operations to the open object will be rejected with <tt>FR_LOCKED</tt>.</td></tr>
  150. </table>
  151. <h4 id="fs_reentrant">_FS_REENTRANT</h4>
  152. <p>Disable (0) or Enable (1). This option switches the re-entrancy (thread safe) of the FatFs module itself. Note that file/directory access to the different volume is always re-entrant and it can work simultaneously regardless of this option but volume control functions. <tt>f_mount</tt>, <tt>f_mkfs</tt> and <tt>f_fdisk</tt>, are always not re-entrant. Only file/directory access to the same volume, in other words, exclusive use of each file system object, is under control of this function. To enable this feature, also user provided synchronization handlers, <tt>ff_req_grant</tt>, <tt>ff_rel_grant</tt>, <tt>ff_del_syncobj</tt> and <tt>ff_cre_syncobj</tt>, need to be added to the project. Sample code is available in <tt>option/syscall.c</tt>.</p>
  153. <h4 id="fs_timeout">_FS_TIMEOUT</h4>
  154. <p>Number of time ticks to abort the file function with <tt>FR_TIMEOUT</tt> when wait time is too long. This option has no effect when <tt>_FS_REENTRANT = 0</tt>.</p>
  155. <h4 id="sync_t">_SYNC_t</h4>
  156. <p>This option defines O/S dependent sync object type. e.g. <tt>HANDLE</tt>, <tt>ID</tt>, <tt>OS_EVENT*</tt>, <tt>SemaphoreHandle_t</tt> and etc. A header file for O/S definitions needs to be included somewhere in the scope of <tt>ff.c</tt>. This option has no effect when <tt>_FS_REENTRANT = 0</tt>.</p>
  157. </div>
  158. <p class="foot"><a href="../00index_e.html">Return</a></p>
  159. </body>
  160. </html>