fatfs v0.04b May 05, 2007:

- Added _USE_NTFLAG option.
- Added FSInfo support.
- Fixed some problems corresponds to FAT32. (Tiny-FatFs)
- Fixed DBCS name can result FR_INVALID_NAME.
- Fixed short seek (<= csize) collapses the file object.
This commit is contained in:
savelij13 committed 2025-09-11 09:08:31 +03:00
1 parent 8e92305484
commit c0c10d0bea
21 files changed
+492 -307

No files matched your search

+12 -14
View File
@@ -18,30 +18,30 @@
<ul>
<li>ANSI C<br>
The FatFs module is a middleware that written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C. However it handles the system portable FAT structures. You must take the <strong>endian</strong> into consideration. This setting is defined in ff.h (tff.h). It must be changed for your platform first or the compiler will abort with an error.</li>
<li>Size of char/short/long are 8/16/32 bit.<br>
<li>Size of char/short/long are 8/16/32 bit and int is 16 bit or grater.<br>
These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict of the definitions between the integer.h and existing definitions is occured, you must resolve the confrict with care.</li>
</ul>
</div>
<div class="para">
<h3>Memory Usage (R0.04a)</h3>
<h3>Memory Usage (R0.04b)</h3>
<p>These are the memory usage on some target systems. The memory sizes are in unit of byte, D means number of logical drives and F means number of open files. All samples are optimezed in code size.</p>
<table class="lst2">
<tr><th></th><th>AVR</th><th>H8/300H</th><th>MSP430</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th></tr>
<tr><td>Compiler</td><td>gcc</td><td>CH38</td><td>CL430</td><td>CC870C</td><td>CA850</td><td>SHC</td></tr>
<tr><td>_MCU_ENDIAN</td><td>1</td><td>2</td><td>2</td><td>1</td><td>1</td><td>2</td></tr>
<tr><td>FatFs Code<br>(Full, R/W cfg.)</td><td>8672</td><td>8746</td><td></td><td></td><td>6384</td><td>7390</td></tr>
<tr><td>FatFs Code<br>(Full, R/O cfg.)</td><td>4230</td><td>4100</td><td></td><td></td><td>3012</td><td>3510</td></tr>
<tr><td>FatFs Code<br>(Mininum, R/W cfg.)</td><td>5706</td><td>5678</td><td></td><td></td><td>4042</td><td>4882</td></tr>
<tr><td>FatFs Code<br>(Minimum, R/O cfg.)</td><td>3016</td><td>3116</td><td></td><td></td><td>2198</td><td>2702</td></tr>
<tr><td>FatFs Code<br>(Standard, R/W cfg.)</td><td>8722</td><td>8776</td><td></td><td></td><td>6402</td><td>7338</td></tr>
<tr><td>FatFs Code<br>(Minimum, R/W cfg.)</td><td>5814</td><td>5722</td><td></td><td></td><td>4094</td><td>4906</td></tr>
<tr><td>FatFs Code<br>(Standard, R/O cfg.)</td><td>4248</td><td>4096</td><td></td><td></td><td>3010</td><td>3506</td></tr>
<tr><td>FatFs Code<br>(Minimum, R/O cfg.)</td><td>3038</td><td>3110</td><td></td><td></td><td>2210</td><td>2698</td></tr>
<tr><td>FatFs Work (Static)</td><td>D*2 + 2</td><td>D*4 + 2</td><td></td><td></td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr><td>FatFs Work (Dynamic)</td><td>D*550 + F*544</td><td>D*550 + F*550</td><td></td><td></td><td>D*550 + F*550</td><td>D*550 + F*550</td></tr>
<tr><td>Tiny-FatFs Code<br>(Full, R/W cfg.)</td><td>7188</td><td>7206</td><td>6590</td><td>8799</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Code<br>(Full, R/O cfg.)</td><td>3592</td><td>3560</td><td>3162</td><td>4353</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Code<br>(Minimum, R/W cfg.)</td><td>4670</td><td>4772</td><td>4322</td><td>6073</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Code<br>(Minimum, R/O cfg.)</td><td>2576</td><td>2714</td><td>2378</td><td>3324</td><td></td><td></td></tr>
<tr><td>FatFs Work (Dynamic)</td><td>D*554 + F*544</td><td>D*554 + F*550</td><td></td><td></td><td>D*554 + F*550</td><td>D*554 + F*550</td></tr>
<tr><td>Tiny-FatFs Code<br>(Standard, R/W cfg.)</td><td>7264</td><td>7240</td><td>6634</td><td>8837</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Code<br>(Minimum, R/W cfg.)</td><td>4750</td><td>4806</td><td>4366</td><td>6163</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Code<br>(Standard, R/O cfg.)</td><td>3600</td><td>3548</td><td>3212</td><td>4347</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Code<br>(Minimum, R/O cfg.)</td><td>2568</td><td>2702</td><td>2394</td><td>3322</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Wrok (Static)</td><td>4</td><td>6</td><td>4</td><td>4</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Work (Dynamic)</td><td>542 + F*28</td><td>542 + F*32</td><td>542 + F*28</td><td>542 + F*28</td><td></td><td></td></tr>
<tr><td>Tiny-FatFs Work (Dynamic)</td><td>544 + F*28</td><td>544 + F*32</td><td>544 + F*28</td><td>544 + F*28</td><td></td><td></td></tr>
</table>
</div>
@@ -110,8 +110,6 @@ Figure 5. Minimized critical section<br>
Currently the file object structure is held by application layer. This is not a problem for Tiny-FatFs, it consumes the task stack only 26 bytes per file. But FatFs requires 550 bytes per file. When managed the file objects in file handle, stack consumption at application module will able to be reduced. In this case, the work area for file objects is managed in FatFs module. This has a disadvantage that direct access to the file object structure cannot be used and additional file functions, such as feof and ftell, will be needed.</li>
<li>Efficient sector buffer management<br>
The FatFs module has only one sector buffer per logical drive. There is an ineffciency on random file access with many files simultanesously. When additional memory for the sector buffer is available, the file access performance will able to be improved with an advanced cache mechanism.</li>
<li>FSInfo sector<br>
On FAT32 file system, the cluster search to create a file as new or get number of free clusters takes time due to a great many clusters. The FSInfo sector that has last allocated cluster number and number of free clusters is provided to prevent the silly cluster search. However the FatFs module does not support this feature.</li>
<li>Long file name<br>
There is an extended feature to handle long file name (LFN) up to 255 characters, in addition to 8.3 format file name, on FAT file system. To support this, 512 byte string buffer for file name and UCS-2 - Shift_JIS mutual conversion table are required. Therefore memory consumption of code and work area will be increased drastically. The FatFs module does not support this feature. The LFN on the FAT file system is a patent of Microsoft. When support it on the commercial products, you have to be licensed.</li>
<li>Porting to RTOS<br>
+1 -1
View File
@@ -46,7 +46,7 @@ FRESULT f_close (
<div class="para">
<h4>Description</h4>
<p>The f_close function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the disk. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
<p>The f_close function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the disk. After the function succeeded, the file object is no longer valid and it can be discarded. If the file object has been opened in read-only mode, it may be discarded without closing process by this function.</p>
</div>
+2 -1
View File
@@ -56,7 +56,8 @@ FRESULT f_getfree (
<div class="para">
<h4>Descriptions</h4>
<p>The f_getfree function gets number of free clusters on the drive. The <tt>sects_clust</tt> member in the file system object refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. This function is not supported in read-only configuration and minimization level of &gt;= 1.</p>
<p>The f_getfree function gets number of free clusters on the drive. The <tt>sects_clust</tt> member in the file system object refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When _USE_FSINFO option is enabled, this function can return inaccurate free cluster count on FAT32 volume. When _USE_FSINFO option is disabled, this function will take a time on FAT32 volume.</p>
<p>This function is not supported in read-only configuration and minimization level of &gt;= 1.</p>
</div>
+4 -4
View File
@@ -64,13 +64,13 @@ void scan_files (char* path)
if (f_opendir(&dirs, path) == FR_OK) {
i = strlen(path);
while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.f_name[0]) {
if (finfo.f_attrib & AM_DIR) {
sprintf(path+i, "/%s", &finfo.f_name[0]);
while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) {
if (finfo.fattrib & AM_DIR) {
sprintf(path+i, "/%s", &finfo.fname[0]);
scan_files(path);
*(path+i) = '\0';
} else {
printf("%s/%s\n", path, &finfo.f_name[0]);
printf("%s/%s\n", path, &finfo.fname[0]);
}
}
}
+3 -1
View File
@@ -12,7 +12,7 @@
<div class="para">
<h2>FATFS</h2>
<p>The <tt>FATFS</tt> structure holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. There is no member that can be changed from the application program.</p>
<p>The <tt>FATFS</tt> structure holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Following members are in standard configuration. There is no member that can be changed from the application program.</p>
<h4>FatFs</h4>
<pre>
typedef struct _FATFS {
@@ -25,6 +25,7 @@ typedef struct _FATFS {
DWORD dirbase; /* Root directory start sector (cluster# for FAT32) */
DWORD database; /* Data start sector */
DWORD last_clust; /* Last allocated cluster */
DWORD free_clust; /* Number of free clusters */
BYTE fs_type; /* FAT type (0:Not mounted) */
BYTE sects_clust; /* Sectors per cluster */
BYTE n_fats; /* Number of FAT copies */
@@ -47,6 +48,7 @@ typedef struct _FATFS {
CLUST sects_fat; /* Sectors per fat */
CLUST max_clust; /* Maximum cluster# + 1 */
CLUST last_clust; /* Last allocated cluster */
CLUST free_clust; /* Number of free clusters */
BYTE fs_type; /* FAT type (0:Not mounted) */
BYTE sects_clust; /* Sectors per cluster */
BYTE n_fats; /* Number of FAT copies */