fatfs v0.09a Aug 27,2012:

- Fixed assertion failure due to OS/2 EA on FAT12/16.
- Changed f_open() and f_opendir() reject null object pointer to avoid crash.
- Changed option name _FS_SHARE to _FS_LOCK.
This commit is contained in:
savelij13 2025-09-11 09:49:45 +03:00
parent 13034d028c
commit 030f12c942
20 changed files with 634 additions and 297 deletions

View File

@ -4,8 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Style-Type" content="text/css">
<meta name="description" content="Open souece FAT file system module for embedded projects"> <meta name="description" content="Open souece FAT file system module for embedded projects">
<link rel="start" title="Site Top" href="../../">
<link rel="up" title="Freewares" href="../../fsw_e.html">
<link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html"> <link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html">
<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
<title>ELM - FatFs Generic FAT File System Module</title> <title>ELM - FatFs Generic FAT File System Module</title>
@ -96,7 +94,7 @@
<p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p> <p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p>
<ul> <ul>
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li> <li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li>
<li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">July 28, 2012</span></li> <li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">August 27, 2012</span></li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li> <li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li> <li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li> <li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li>
@ -107,8 +105,5 @@
</ul> </ul>
</div> </div>
<hr>
<p class="foot"><a href="../../fsw_e.html">Return</a></p>
</body> </body>
</html> </html>

View File

@ -4,8 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Style-Type" content="text/css">
<meta name="description" content="組み込みシステム向けFATファイル・システム"> <meta name="description" content="組み込みシステム向けFATファイル・システム">
<link rel="start" title="Site Top" href="../../index_j.html">
<link rel="up" title="Freewares" href="../../fsw.html">
<link rel="alternate" hreflang="en" title="英文" href="00index_e.html"> <link rel="alternate" hreflang="en" title="英文" href="00index_e.html">
<link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default">
<title>ELM - FatFs 汎用FATファイルシステム・モジュール</title> <title>ELM - FatFs 汎用FATファイルシステム・モジュール</title>
@ -95,7 +93,7 @@
<p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的個人利用から商用まででも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ートを参照してください。</p> <p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的個人利用から商用まででも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ートを参照してください。</p>
<ul> <ul>
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li> <li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li>
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ート</a> <span class="mfd">2012. 7. 28</span></li> <li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ート</a> <span class="mfd">2012. 8. 27</span></li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li> <li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li> <li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li> <li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li>
@ -106,8 +104,5 @@
</ul> </ul>
</div> </div>
<hr>
<p class="foot"><a href="../../fsw.html">戻る</a></p>
</body> </body>
</html> </html>

View File

@ -41,7 +41,7 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<h4>System organizations</h4> <h4>System organizations</h4>
<p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p> <p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p>
<img src="../img/modules.png" width="507" height="224" alt="dependency diagram"> <p><img src="../img/modules.png" width="507" height="224" alt="dependency diagram"></p>
<h4>Which function is required?</h4> <h4>Which function is required?</h4>
<p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. All defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p> <p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. All defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p>
@ -72,17 +72,17 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
</div> </div>
<div class="para" id="memory"> <div class="para" id="memory">
<h3>Memory Usage (R0.09)</h3> <h3>Memory Usage (R0.09a)</h3>
<table class="lst2"> <table class="lst2">
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr> <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr>
<tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr> <tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr> <tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>10459</td><td>7201</td><td>6623</td><td>12646</td><td>10686</td><td>11466</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr> <tr class="lst3"><td>text (Full, R/W)</td><td>10375</td><td>7019</td><td>6561</td><td>13267</td><td>10525</td><td>11205</td><td>12812</td><td>7783</td><td>8715</td><td>5782</td><td>7615</td></tr>
<tr><td>text (Min, R/W)</td><td>6503</td><td>4745</td><td>4297</td><td>8306</td><td>6986</td><td>7440</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr> <tr> <td>text (Min, R/W)</td> <td>6487</td><td>4727</td><td>4283</td> <td>8521</td> <td>6967</td> <td>7398</td> <td>8800</td><td>5019</td><td>5635</td><td>3784</td><td>5003</td></tr>
<tr><td>text (Full, R/O)</td><td>4535</td><td>3181</td><td>2869</td><td>5960</td><td>4876</td><td>5286</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr> <tr> <td>text (Full, R/O)</td> <td>4551</td><td>3125</td><td>2895</td> <td>6219</td> <td>4895</td> <td>5268</td> <td>6123</td><td>3629</td><td>3843</td><td>2699</td><td>3527</td></tr>
<tr><td>text (Min, R/O)</td><td>3303</td><td>2493</td><td>2171</td><td>4366</td><td>3770</td><td>3984</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr> <tr> <td>text (Min, R/O)</td> <td>3321</td><td>2457</td><td>2197</td> <td>4527</td> <td>3797</td> <td>3999</td> <td>4663</td><td>2773</td><td>2999</td><td>2064</td><td>2736</td></tr>
<tr><td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr> <tr> <td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr> <tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr> <tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr>
</table> </table>
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> means number of mounted volumes and <em>F</em> means number of open files. All samples are optimezed in code size.</p> <p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> means number of mounted volumes and <em>F</em> means number of open files. All samples are optimezed in code size.</p>
@ -100,7 +100,7 @@ _FS_RPATH 0 (Disable relative path)
_VOLUMES D (Number of logical drives to be used) _VOLUMES D (Number of logical drives to be used)
_MULTI_PARTITION 0 (Single partition per drive) _MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable reentrancy) _FS_REENTRANT 0 (Disable reentrancy)
_FS_SHARE 0 (Disable shareing control) _FS_LOCK 0 (Disable shareing control)
</pre> </pre>
</div> </div>
@ -172,7 +172,7 @@ _FS_SHARE 0 (Disable shareing control)
<div class="para" id="dup"> <div class="para" id="dup">
<h3>Duplicated File Access</h3> <h3>Duplicated File Access</h3>
<p>FatFs module does not support the shareing controls of duplicated file access in default. It is permitted when open method to a file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, or the FAT structure on the volume can be collapted.</p> <p>FatFs module does not support the shareing controls of duplicated file access in default. It is permitted when open method to a file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, or the FAT structure on the volume can be collapted.</p>
<p>The file shareing control can also be available when <tt>_FS_SHARE</tt> is set to 1 or grater. The value specifies the number of files to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open files gets larger than <tt>_FS_SHARE</tt>, the f_open function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p> <p>The file shareing control can also be available when <tt>_FS_LOCK</tt> is set to 1 or grater. The value specifies the number of files to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open files gets larger than <tt>_FS_LOCK</tt>, the f_open function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
</div> </div>
<div class="para" id="fs1"> <div class="para" id="fs1">

View File

@ -38,7 +38,7 @@ DSTATUS disk_initialize (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The disk_initialize function initializes a physical drive and put it ready to read/write. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleard.</p> <p>The disk_initialize function initializes a physical drive and put it ready to read/write. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleard.</p>
<p><em>Application program MUST NOT call this function, or FAT structure on the volume can be corrapted. To re-initialize the file system, use f_mount function.</em>This function is called on volume mount process in the FatFs module to manage the media change.</p> <p><em>Application program MUST NOT call this function, or FAT structure on the volume can be corrapted. To re-initialize the file system, use f_mount function instead.</em>This function is called on volume mount process in the FatFs module to manage the media change.</p>
</div> </div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>

View File

@ -30,7 +30,7 @@ DRESULT disk_read (
<dt>Drive</dt> <dt>Drive</dt>
<dd>Specifies the physical drive number.</dd> <dd>Specifies the physical drive number.</dd>
<dt>Buffer</dt> <dt>Buffer</dt>
<dd>Pointer to the <em>byte array</em> to store the read data. The buffer size of number of bytes to be read, sector size * sector count, is required. Note that the specified memory address is not that always aligned to word boundary. If the hardware does not support misaligned data transfer, it must be solved in this function.</dd> <dd>Pointer to the <em>byte array</em> to store the read data. The size of buffer must be in sector size * sector count.</dd>
<dt>SectorNumber</dt> <dt>SectorNumber</dt>
<dd>Specifies the start sector number in logical block address (LBA).</dd> <dd>Specifies the start sector number in logical block address (LBA).</dd>
<dt>SectorCount</dt> <dt>SectorCount</dt>
@ -54,6 +54,17 @@ DRESULT disk_read (
</div> </div>
<div class="para desc">
<h4>Description</h4>
<p>The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds below to avoid this problem.</p>
<ul>
<li>In this function, convert word transfer to byte transfer. - Recommended.</li>
<li>On f_read(), avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li>
<li>On f_read(), make sure that the lower two bits of start address is equal to the lower two bits of file read/write pointer. - Word aligned direct transfer is guaranteed.</li>
</ul>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>
</body> </body>
</html> </html>

View File

@ -30,7 +30,7 @@ DRESULT disk_write (
<dt>Drive</dt> <dt>Drive</dt>
<dd>Specifies the physical drive number.</dd> <dd>Specifies the physical drive number.</dd>
<dt>Buffer</dt> <dt>Buffer</dt>
<dd>Pointer to the <em>byte array</em> to be written. Note that the specified memory address is not that always aligned to word boundary. If the hardware does not support misaligned data transfer, it must be solved in this function.</dd> <dd>Pointer to the <em>byte array</em> to be written.</dd>
<dt>SectorNumber</dt> <dt>SectorNumber</dt>
<dd>Specifies the start sector number in logical block address (LBA).</dd> <dd>Specifies the start sector number in logical block address (LBA).</dd>
<dt>SectorCount</dt> <dt>SectorCount</dt>
@ -58,7 +58,7 @@ DRESULT disk_write (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>This function is not required in read only configuration.</p> <p>This function is not required in read only configuration. The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE. For more information, read <a href="dread.html">description in disk_read function</a>.</p>
</div> </div>

View File

@ -68,7 +68,7 @@
<dt id="tm">FR_TIMEOUT</dt> <dt id="tm">FR_TIMEOUT</dt>
<dd>The function canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: _TIMEOUT)</dd> <dd>The function canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: _TIMEOUT)</dd>
<dt id="lo">FR_LOCKED</dt> <dt id="lo">FR_LOCKED</dt>
<dd>The file access is rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: _FS_SHARE)</dd> <dd>The file access is rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: _FS_LOCK)</dd>
<dt id="nc">FR_NOT_ENOUGH_CORE</dt> <dt id="nc">FR_NOT_ENOUGH_CORE</dt>
<dd>Not enough memory for the operation. There is one of the following reasons: <dd>Not enough memory for the operation. There is one of the following reasons:
<ul> <ul>
@ -77,7 +77,7 @@
</ul> </ul>
</dd> </dd>
<dt id="tf">FR_TOO_MANY_OPEN_FILES</dt> <dt id="tf">FR_TOO_MANY_OPEN_FILES</dt>
<dd>Number of open files has been reached maximum value and no more file can be opened. (Related option: _FS_SHARE)</dd> <dd>Number of open files has been reached maximum value and no more file can be opened. (Related option: _FS_LOCK)</dd>
<dt id="ip">FR_INVALID_PARAMETER</dt> <dt id="ip">FR_INVALID_PARAMETER</dt>
<dd>The given parameter is invalid or there is any inconsistent.</dd> <dd>The given parameter is invalid or there is any inconsistent.</dd>
</dl> </dl>

View File

@ -54,7 +54,7 @@ FRESULT f_read (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The file pointer of the file object increases in number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead &lt; ByteToRead</tt>, it means the read/write pointer reached end of the file during read operation.</p> <p>The file read/write pointer of the file object advances number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead &lt; ByteToRead</tt>, it means the read/write pointer reached end of the file during read operation.</p>
</div> </div>

View File

@ -54,7 +54,7 @@ FRESULT f_write (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The read/write pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p> <p>The read/write pointer of the file object advances number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
</div> </div>

BIN
doc/img/modules.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -42,7 +42,7 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI C
<h4>システム構成</h4> <h4>システム構成</h4>
<p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p> <p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p>
<img src="../img/modules.png" width="507" height="224" alt="システム構成図"> <p><img src="../img/modules.png" width="507" height="224" alt="システム構成図"></p>
<h4>ユーザの作成する関数</h4> <h4>ユーザの作成する関数</h4>
<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか、最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p> <p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか、最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
@ -73,21 +73,22 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI C
</div> </div>
<div class="para" id="memory"> <div class="para" id="memory">
<h3>メモリ使用量 (R0.09)</h3> <h3>メモリ使用量</h3>
<p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>は同時マウント・ボリューム数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p> <p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>は同時マウント・ボリューム数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p>
<table class="lst2"> <table class="lst2">
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr> <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr>
<tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr> <tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr> <tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>10459</td><td>7201</td><td>6623</td><td>12646</td><td>10686</td><td>11466</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr> <tr class="lst3"><td>text (Full, R/W)</td><td>10375</td><td>7019</td><td>6561</td><td>13267</td><td>10525</td><td>11205</td><td>12812</td><td>7783</td><td>8715</td><td>5782</td><td>7615</td></tr>
<tr><td>text (Min, R/W)</td><td>6503</td><td>4745</td><td>4297</td><td>8306</td><td>6986</td><td>7440</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr> <tr> <td>text (Min, R/W)</td> <td>6487</td><td>4727</td><td>4283</td> <td>8521</td> <td>6967</td> <td>7398</td> <td>8800</td><td>5019</td><td>5635</td><td>3784</td><td>5003</td></tr>
<tr><td>text (Full, R/O)</td><td>4535</td><td>3181</td><td>2869</td><td>5960</td><td>4876</td><td>5286</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr> <tr> <td>text (Full, R/O)</td> <td>4551</td><td>3125</td><td>2895</td> <td>6219</td> <td>4895</td> <td>5268</td> <td>6123</td><td>3629</td><td>3843</td><td>2699</td><td>3527</td></tr>
<tr><td>text (Min, R/O)</td><td>3303</td><td>2493</td><td>2171</td><td>4366</td><td>3770</td><td>3984</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr> <tr> <td>text (Min, R/O)</td> <td>3321</td><td>2457</td><td>2197</td> <td>4527</td> <td>3797</td> <td>3999</td> <td>4663</td><td>2773</td><td>2999</td><td>2064</td><td>2736</td></tr>
<tr><td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr> <tr> <td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr> <tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr> <tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr>
</table> </table>
<pre> <pre>
FatFs R0.09a options:
_FS_READONLY 0 (R/W), 1 (R/O) _FS_READONLY 0 (R/W), 1 (R/O)
_FS_MINIMIZE 0 (Full function), 3 (Minimized function) _FS_MINIMIZE 0 (Full function), 3 (Minimized function)
_USE_STRFUNC 0 (Disable string functions) _USE_STRFUNC 0 (Disable string functions)
@ -101,7 +102,7 @@ _FS_RPATH 0 (Disable relative path)
_VOLUMES D (Number of logical drives to be used) _VOLUMES D (Number of logical drives to be used)
_MULTI_PARTITION 0 (Single partition per drive) _MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable reentrancy) _FS_REENTRANT 0 (Disable reentrancy)
_FS_SHARE 0 (Disable shareing control) _FS_LOCK 0 (Disable file lock control)
</pre> </pre>
</div> </div>
@ -179,7 +180,7 @@ _FS_SHARE 0 (Disable shareing control)
<div class="para" id="dup"> <div class="para" id="dup">
<h3>多重ファイル・アクセス</h3> <h3>多重ファイル・アクセス</h3>
<p>FatFsモジュールではデフォルトでは多重アクセス制御機能をサポートしていません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや削除を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p> <p>FatFsモジュールではデフォルトでは多重アクセス制御機能をサポートしていません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや削除を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p>
<p><tt>_FS_SHARE</tt>に1以上の値(値は同時に管理できるファイル数)をセットすることで多重アクセス制御機能が有効になり、ファイル単位の排他制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数は<tt>FR_LOCKED</tt>で失敗します。<tt>_FS_SHARE</tt>を越えた数のファイルをオープンしようとすると、<tt>FR_TOO_MANY_OPEN_FILES</tt>で失敗します。</p> <p><tt>_FS_LOCK</tt>に1以上の値(値は同時に管理できるファイル数)をセットすることで多重アクセス制御機能が有効になり、ファイル単位の排他制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数は<tt>FR_LOCKED</tt>で失敗します。<tt>_FS_LOCK</tt>を越えた数のファイルをオープンしようとすると、<tt>FR_TOO_MANY_OPEN_FILES</tt>で失敗します。</p>
</div> </div>
<div class="para" id="fs1"> <div class="para" id="fs1">

View File

@ -1,11 +1,16 @@
R0.09, Sep 6, 2011 R0.09a, Aug 27, 2012
Fixed assertion failure due to OS/2 EA on FAT12/16.
Changed API rejects null object pointer to avoid crash.
Changed option name _FS_SHARE to _FS_LOCK.
R0.09, Sep 06, 2011
f_mkfs() supports multiple partition to finish the multiple partition feature. f_mkfs() supports multiple partition to finish the multiple partition feature.
Added f_fdisk(). (_MULTI_PARTITION = 2) Added f_fdisk(). (_MULTI_PARTITION = 2)
R0.08b, Jan 15, 2011 R0.08b, Jan 15, 2011
Fast seek feature is also applied to f_read() and f_write(). Fast seek feature is also applied to f_read() and f_write().
f_lseek() reports required table size on creating CLMP. f_lseek() reports required table size on creating CLMP.
Extended format syntax of f_printf function. Extended format syntax of f_printf().
Ignores duplicated directory separators in given path names. Ignores duplicated directory separators in given path names.
R0.08a, Aug 16, 2010 R0.08a, Aug 16, 2010

View File

@ -1,4 +1,4 @@
FatFs Module Source Files R0.09 (C)ChaN, 2011 FatFs Module Source Files R0.09a (C)ChaN, 2012
FILES FILES
@ -7,7 +7,8 @@ FILES
ff.h Common include file for FatFs and application module. ff.h Common include file for FatFs and application module.
ff.c FatFs module. ff.c FatFs module.
diskio.h Common include file for FatFs and disk I/O module. diskio.h Common include file for FatFs and disk I/O module.
integer.h Alternative type definitions for integer variables. diskio.c An example of glue function to attach existing disk I/O module to FatFs.
integer.h Integer type definitions for FatFs.
option Optional external functions. option Optional external functions.
Low level disk I/O module is not included in this archive because the FatFs Low level disk I/O module is not included in this archive because the FatFs
@ -23,7 +24,7 @@ AGREEMENTS
small embedded systems. This is a free software and is opened for education, small embedded systems. This is a free software and is opened for education,
research and commercial developments under license policy of following trems. research and commercial developments under license policy of following trems.
Copyright (C) 2011, ChaN, all right reserved. Copyright (C) 2012, ChaN, all right reserved.
* The FatFs module is a free software and there is NO WARRANTY. * The FatFs module is a free software and there is NO WARRANTY.
* No restriction on use. You can use, modify and redistribute it for * No restriction on use. You can use, modify and redistribute it for
@ -128,3 +129,7 @@ REVISION HISTORY
Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature. Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature.
Added f_fdisk(). (_MULTI_PARTITION = 2) Added f_fdisk(). (_MULTI_PARTITION = 2)
Aug 27,'12 R0.09a Fixed assertion failure due to OS/2 EA on FAT12/16.
Changed f_open() and f_opendir() reject null object pointer to avoid crash.
Changed option name _FS_SHARE to _FS_LOCK.

236
src/diskio.c Normal file
View File

@ -0,0 +1,236 @@
/*-----------------------------------------------------------------------*/
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2012 */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */
/* This is an example of glue functions to attach various exsisting */
/* storage control module to the FatFs module with a defined API. */
/*-----------------------------------------------------------------------*/
#include "diskio.h" /* FatFs lower layer API */
#include "usbdisk.h" /* Example: USB drive control */
#include "atadrive.h" /* Example: ATA drive control */
#include "sdcard.h" /* Example: MMC/SDC contorl */
/* Definitions of physical drive number for each media */
#define ATA 0
#define MMC 1
#define USB 2
/*-----------------------------------------------------------------------*/
/* Inidialize a Drive */
/*-----------------------------------------------------------------------*/
DSTATUS disk_initialize (
BYTE drv /* Physical drive nmuber (0..) */
)
{
DSTATUS stat;
int result;
switch (drv) {
case ATA :
result = ATA_disk_initialize();
// translate the reslut code here
return stat;
case MMC :
result = MMC_disk_initialize();
// translate the reslut code here
return stat;
case USB :
result = USB_disk_initialize();
// translate the reslut code here
return stat;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/
/* Get Disk Status */
/*-----------------------------------------------------------------------*/
DSTATUS disk_status (
BYTE drv /* Physical drive nmuber (0..) */
)
{
DSTATUS stat;
int result;
switch (drv) {
case ATA :
result = ATA_disk_status();
// translate the reslut code here
return stat;
case MMC :
result = MMC_disk_status();
// translate the reslut code here
return stat;
case USB :
result = USB_disk_status();
// translate the reslut code here
return stat;
}
return STA_NOINIT;
}
/*-----------------------------------------------------------------------*/
/* Read Sector(s) */
/*-----------------------------------------------------------------------*/
DRESULT disk_read (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to read (1..128) */
)
{
DRESULT res;
int result;
switch (drv) {
case ATA :
// translate the arguments here
result = ATA_disk_read(buff, sector, count);
// translate the reslut code here
return res;
case MMC :
// translate the arguments here
result = MMC_disk_read(buff, sector, count);
// translate the reslut code here
return res;
case USB :
// translate the arguments here
result = USB_disk_read(buff, sector, count);
// translate the reslut code here
return res;
}
return RES_PARERR;
}
/*-----------------------------------------------------------------------*/
/* Write Sector(s) */
/*-----------------------------------------------------------------------*/
#if _USE_WRITE
DRESULT disk_write (
BYTE drv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address (LBA) */
BYTE count /* Number of sectors to write (1..128) */
)
{
DRESULT res;
int result;
switch (drv) {
case ATA :
// translate the arguments here
result = ATA_disk_write(buff, sector, count);
// translate the reslut code here
return res;
case MMC :
// translate the arguments here
result = MMC_disk_write(buff, sector, count);
// translate the reslut code here
return res;
case USB :
// translate the arguments here
result = USB_disk_write(buff, sector, count);
// translate the reslut code here
return res;
}
return RES_PARERR;
}
#endif
/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/
#if _USE_IOCTL
DRESULT disk_ioctl (
BYTE drv, /* Physical drive nmuber (0..) */
BYTE ctrl, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res;
int result;
switch (drv) {
case ATA :
// pre-process here
result = ATA_disk_ioctl(ctrl, buff);
// post-process here
return res;
case MMC :
// pre-process here
result = MMC_disk_ioctl(ctrl, buff);
// post-process here
return res;
case USB :
// pre-process here
result = USB_disk_ioctl(ctrl, buff);
// post-process here
return res;
}
return RES_PARERR;
}
#endif

View File

@ -1,11 +1,16 @@
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
/ Low level disk interface modlue include file / Low level disk interface modlue include file (C)ChaN, 2012
/-----------------------------------------------------------------------*/ /-----------------------------------------------------------------------*/
#ifndef _DISKIO #ifndef _DISKIO_DEFINED
#define _DISKIO_DEFINED
#define _READONLY 0 /* 1: Remove write functions */ #ifdef __cplusplus
#define _USE_IOCTL 1 /* 1: Use disk_ioctl fucntion */ extern "C" {
#endif
#define _USE_WRITE 1 /* 1: Enable disk_write function */
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
#include "integer.h" #include "integer.h"
@ -26,19 +31,15 @@ typedef enum {
/*---------------------------------------*/ /*---------------------------------------*/
/* Prototypes for disk control functions */ /* Prototypes for disk control functions */
int assign_drives (int, int);
DSTATUS disk_initialize (BYTE); DSTATUS disk_initialize (BYTE);
DSTATUS disk_status (BYTE); DSTATUS disk_status (BYTE);
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);
#if _READONLY == 0
DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE);
#endif
DRESULT disk_ioctl (BYTE, BYTE, void*); DRESULT disk_ioctl (BYTE, BYTE, void*);
/* Disk Status Bits (DSTATUS) */ /* Disk Status Bits (DSTATUS) */
#define STA_NOINIT 0x01 /* Drive not initialized */ #define STA_NOINIT 0x01 /* Drive not initialized */
#define STA_NODISK 0x02 /* No medium in the drive */ #define STA_NODISK 0x02 /* No medium in the drive */
#define STA_PROTECT 0x04 /* Write protected */ #define STA_PROTECT 0x04 /* Write protected */
@ -46,17 +47,18 @@ DRESULT disk_ioctl (BYTE, BYTE, void*);
/* Command code for disk_ioctrl fucntion */ /* Command code for disk_ioctrl fucntion */
/* Generic command (defined for FatFs) */ /* Generic command (used by FatFs) */
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
/* Generic command */ /* Generic command (not used by FatFs) */
#define CTRL_POWER 5 /* Get/Set power status */ #define CTRL_POWER 5 /* Get/Set power status */
#define CTRL_LOCK 6 /* Lock/Unlock media removal */ #define CTRL_LOCK 6 /* Lock/Unlock media removal */
#define CTRL_EJECT 7 /* Eject media */ #define CTRL_EJECT 7 /* Eject media */
#define CTRL_FORMAT 8 /* Create physical format on the media */
/* MMC/SDC specific ioctl command */ /* MMC/SDC specific ioctl command */
#define MMC_GET_TYPE 10 /* Get card type */ #define MMC_GET_TYPE 10 /* Get card type */
@ -70,9 +72,17 @@ DRESULT disk_ioctl (BYTE, BYTE, void*);
#define ATA_GET_MODEL 21 /* Get model name */ #define ATA_GET_MODEL 21 /* Get model name */
#define ATA_GET_SN 22 /* Get serial number */ #define ATA_GET_SN 22 /* Get serial number */
/* NAND specific ioctl command */
#define NAND_FORMAT 30 /* Create physical format */ /* MMC card type flags (MMC_GET_TYPE) */
#define CT_MMC 0x01 /* MMC ver 3 */
#define CT_SD1 0x02 /* SD ver 1 */
#define CT_SD2 0x04 /* SD ver 2 */
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
#define CT_BLOCK 0x08 /* Block addressing */
#define _DISKIO #ifdef __cplusplus
}
#endif
#endif #endif

476
src/ff.c

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
/*---------------------------------------------------------------------------/ /*---------------------------------------------------------------------------/
/ FatFs - FAT file system module include file R0.09 (C)ChaN, 2011 / FatFs - FAT file system module include file R0.09a (C)ChaN, 2012
/----------------------------------------------------------------------------/ /----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems. / FatFs module is a generic FAT file system module for small embedded systems.
/ This is a free software that opened for education, research and commercial / This is a free software that opened for education, research and commercial
/ developments under license policy of following trems. / developments under license policy of following terms.
/ /
/ Copyright (C) 2011, ChaN, all right reserved. / Copyright (C) 2012, ChaN, all right reserved.
/ /
/ * The FatFs module is a free software and there is NO WARRANTY. / * The FatFs module is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for / * No restriction on use. You can use, modify and redistribute it for
@ -15,7 +15,7 @@
/----------------------------------------------------------------------------*/ /----------------------------------------------------------------------------*/
#ifndef _FATFS #ifndef _FATFS
#define _FATFS 6502 /* Revision ID */ #define _FATFS 4004 /* Revision ID */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -41,9 +41,9 @@ extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */ #define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */ #define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
#else /* Single partition configuration */ #else /* Single partition configuration */
#define LD2PD(vol) (vol) /* Each logical drive is bound to the same physical drive number */ #define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
#define LD2PT(vol) 0 /* Always mounts the 1st partition or in SFD */ #define LD2PT(vol) 0 /* Always mounts the 1st partition or in SFD */
#endif #endif
@ -111,24 +111,24 @@ typedef struct {
/* File object structure (FIL) */ /* File object structure (FIL) */
typedef struct { typedef struct {
FATFS* fs; /* Pointer to the owner file system object */ FATFS* fs; /* Pointer to the related file system object */
WORD id; /* Owner file system mount ID */ WORD id; /* File system mount ID of the related file system object */
BYTE flag; /* File status flags */ BYTE flag; /* File status flags */
BYTE pad1; BYTE pad1;
DWORD fptr; /* File read/write pointer (0 on file open) */ DWORD fptr; /* File read/write pointer (0ed on file open) */
DWORD fsize; /* File size */ DWORD fsize; /* File size */
DWORD sclust; /* File start cluster (0 when fsize==0) */ DWORD sclust; /* File data start cluster (0:no data cluster, always 0 when fsize is 0) */
DWORD clust; /* Current cluster */ DWORD clust; /* Current cluster of fpter */
DWORD dsect; /* Current data sector */ DWORD dsect; /* Current data sector of fpter */
#if !_FS_READONLY #if !_FS_READONLY
DWORD dir_sect; /* Sector containing the directory entry */ DWORD dir_sect; /* Sector containing the directory entry */
BYTE* dir_ptr; /* Ponter to the directory entry in the window */ BYTE* dir_ptr; /* Pointer to the directory entry in the window */
#endif #endif
#if _USE_FASTSEEK #if _USE_FASTSEEK
DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */ DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */
#endif #endif
#if _FS_SHARE #if _FS_LOCK
UINT lockid; /* File lock ID (index of file semaphore table) */ UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
#endif #endif
#if !_FS_TINY #if !_FS_TINY
BYTE buf[_MAX_SS]; /* File data read/write buffer */ BYTE buf[_MAX_SS]; /* File data read/write buffer */
@ -176,14 +176,14 @@ typedef struct {
typedef enum { typedef enum {
FR_OK = 0, /* (0) Succeeded */ FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occured in the low level disk I/O layer */ FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */ FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */ FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* (4) Could not find the file */ FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */ FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */ FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Acces denied due to prohibited access or directory full */ FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Acces denied due to prohibited access */ FR_EXIST, /* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
@ -191,7 +191,7 @@ typedef enum {
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */ FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file shareing policy */ FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */ FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */ FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
@ -216,8 +216,8 @@ FRESULT f_truncate (FIL*); /* Truncate file */
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */ FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
FRESULT f_unlink (const TCHAR*); /* Delete an existing file or directory */ FRESULT f_unlink (const TCHAR*); /* Delete an existing file or directory */
FRESULT f_mkdir (const TCHAR*); /* Create a new directory */ FRESULT f_mkdir (const TCHAR*); /* Create a new directory */
FRESULT f_chmod (const TCHAR*, BYTE, BYTE); /* Change attriburte of the file/dir */ FRESULT f_chmod (const TCHAR*, BYTE, BYTE); /* Change attribute of the file/dir */
FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change timestamp of the file/dir */ FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change times-tamp of the file/dir */
FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */ FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */
FRESULT f_chdrive (BYTE); /* Change current drive */ FRESULT f_chdrive (BYTE); /* Change current drive */
FRESULT f_chdir (const TCHAR*); /* Change current directory */ FRESULT f_chdir (const TCHAR*); /* Change current directory */

View File

@ -1,5 +1,5 @@
/*---------------------------------------------------------------------------/ /*---------------------------------------------------------------------------/
/ FatFs - FAT file system module configuration file R0.09 (C)ChaN, 2011 / FatFs - FAT file system module configuration file R0.09a (C)ChaN, 2012
/----------------------------------------------------------------------------/ /----------------------------------------------------------------------------/
/ /
/ CAUTION! Do not forget to make clean the project after any changes to / CAUTION! Do not forget to make clean the project after any changes to
@ -7,7 +7,7 @@
/ /
/----------------------------------------------------------------------------*/ /----------------------------------------------------------------------------*/
#ifndef _FFCONF #ifndef _FFCONF
#define _FFCONF 6502 /* Revision ID */ #define _FFCONF 4004 /* Revision ID */
/*---------------------------------------------------------------------------/ /*---------------------------------------------------------------------------/
@ -182,9 +182,9 @@
/ function must be added to the project. */ / function must be added to the project. */
#define _FS_SHARE 0 /* 0:Disable or >=1:Enable */ #define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
/* To enable file shareing feature, set _FS_SHARE to 1 or greater. The value /* To enable file lock control feature, set _FS_LOCK to 1 or greater.
defines how many files can be opened simultaneously. */ The value defines how many files can be opened simultaneously. */
#endif /* _FFCONFIG */ #endif /* _FFCONFIG */

View File

@ -1,6 +1,6 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Sample code of OS dependent controls for FatFs R0.08b */ /* Sample code of OS dependent controls for FatFs */
/* (C)ChaN, 2011 */ /* (C)ChaN, 2012 */
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
#include <stdlib.h> /* ANSI memory controls */ #include <stdlib.h> /* ANSI memory controls */

17
src/option/unicode.c Normal file
View File

@ -0,0 +1,17 @@
#include "../ff.h"
#if _USE_LFN != 0
#if _CODE_PAGE == 932
#include "cc932.c"
#elif _CODE_PAGE == 936
#include "cc936.c"
#elif _CODE_PAGE == 949
#include "cc949.c"
#elif _CODE_PAGE == 950
#include "cc950.c"
#else
#include "ccsbcs.c"
#endif
#endif