Skip to content

Commit 747f5c2

Browse files
committed
[fatfs] Update ChaN's FatFs to R0.13c with patch 1~3
1 parent 6b01ad0 commit 747f5c2

File tree

19 files changed

+18514
-33272
lines changed

19 files changed

+18514
-33272
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=RT-Thread
2-
version=0.3.0
2+
version=0.3.1
33
author=Bernard Xiong <[email protected]>, onelife <[email protected]>
44
maintainer=onelife <[email protected]>
55
sentence=Real Time Operating System porting for Arduino SAM and SAMD boards

src/components/dfs/filesystems/elmfat/00history.txt

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ R0.10a (January 15, 2014)
212212
R0.10b (May 19, 2014)
213213

214214
Fixed a hard error in the disk I/O layer can collapse the directory entry.
215-
Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN. (appeared at R0.07)
215+
Fixed LFN entry is not deleted when delete/rename an object with lossy converted SFN. (appeared at R0.07)
216216

217217

218218

@@ -268,7 +268,7 @@ R0.12a (July 10, 2016)
268268

269269
R0.12b (September 04, 2016)
270270

271-
Improved f_rename() to be able to rename objects with the same name but case.
271+
Made f_rename() be able to rename objects with the same name but case.
272272
Fixed an error in the case conversion teble of code page 866. (ff.c)
273273
Fixed writing data is truncated at the file offset 4GiB on the exFAT volume. (appeared at R0.12)
274274
Fixed creating a file in the root directory of exFAT volume can fail. (appeared at R0.12)
@@ -277,3 +277,54 @@ R0.12b (September 04, 2016)
277277
Fixed large file allocation/removing on the exFAT volume collapses allocation bitmap. (appeared at R0.12)
278278
Fixed some internal errors in f_expand() and f_lseek(). (appeared at R0.12)
279279

280+
281+
282+
R0.12c (March 04, 2017)
283+
284+
Improved write throughput at the fragmented file on the exFAT volume.
285+
Made memory usage for exFAT be able to be reduced as decreasing _MAX_LFN.
286+
Fixed successive f_getfree() can return wrong count on the FAT12/16 volume. (appeared at R0.12)
287+
Fixed configuration option _VOLUMES cannot be set 10. (appeared at R0.10c)
288+
289+
290+
291+
R0.13 (May 21, 2017)
292+
293+
Changed heading character of configuration keywords "_" to "FF_".
294+
Removed ASCII-only configuration, FF_CODE_PAGE = 1. Use FF_CODE_PAGE = 437 instead.
295+
Added f_setcp(), run-time code page configuration. (FF_CODE_PAGE = 0)
296+
Improved cluster allocation time on stretch a deep buried cluster chain.
297+
Improved processing time of f_mkdir() with large cluster size by using FF_USE_LFN = 3.
298+
Improved NoFatChain flag of the fragmented file to be set after it is truncated and got contiguous.
299+
Fixed archive attribute is left not set when a file on the exFAT volume is renamed. (appeared at R0.12)
300+
Fixed exFAT FAT entry can be collapsed when write or lseek operation to the existing file is done. (appeared at R0.12c)
301+
Fixed creating a file can fail when a new cluster allocation to the exFAT directory occures. (appeared at R0.12c)
302+
303+
304+
305+
R0.13a (October 14, 2017)
306+
307+
Added support for UTF-8 encoding on the API. (FF_LFN_UNICODE = 2)
308+
Added options for file name output buffer. (FF_LFN_BUF, FF_SFN_BUF).
309+
Added dynamic memory allocation option for working buffer of f_mkfs() and f_fdisk().
310+
Fixed f_fdisk() and f_mkfs() create the partition table with wrong CHS parameters. (appeared at R0.09)
311+
Fixed f_unlink() can cause lost clusters at fragmented file on the exFAT volume. (appeared at R0.12c)
312+
Fixed f_setlabel() rejects some valid characters for exFAT volume. (appeared at R0.12)
313+
314+
315+
316+
R0.13b (April 07, 2018)
317+
318+
Added support for UTF-32 encoding on the API. (FF_LFN_UNICODE = 3)
319+
Added support for Unix style volume ID. (FF_STR_VOLUME_ID = 2)
320+
Fixed accesing any object on the exFAT root directory beyond the cluster boundary can fail. (appeared at R0.12c)
321+
Fixed f_setlabel() does not reject some invalid characters. (appeared at R0.09b)
322+
323+
324+
325+
R0.13c (October 14, 2018)
326+
Supported stdint.h for C99 and later. (integer.h was included in ff.h)
327+
Fixed reading a directory gets infinite loop when the last directory entry is not empty. (appeared at R0.12)
328+
Fixed creating a sub-directory in the fragmented sub-directory on the exFAT volume collapses FAT chain of the parent directory. (appeared at R0.12)
329+
Fixed f_getcwd() cause output buffer overrun when the buffer has a valid drive number. (appeared at R0.13b)
330+
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
FatFs Module Source Files R0.12a
1+
FatFs Module Source Files R0.13c
22

33

44
FILES
55

6-
00readme.txt This file.
7-
history.txt Revision history.
8-
ffconf.h Configuration file for FatFs module.
9-
ff.h Common include file for FatFs and application module.
10-
ff.c FatFs module.
11-
diskio.h Common include file for FatFs and disk I/O module.
12-
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
13-
integer.h Integer type definitions for FatFs.
14-
option Optional external functions.
6+
00readme.txt This file.
7+
00history.txt Revision history.
8+
ff.c FatFs module.
9+
ffconf.h Configuration file of FatFs module.
10+
ff.h Common include file for FatFs and application module.
11+
diskio.h Common include file for FatFs and disk I/O module.
12+
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
13+
ffunicode.c Optional Unicode utility functions.
14+
ffsystem.c An example of optional O/S related functions.
1515

1616

1717
Low level disk I/O module is not included in this archive because the FatFs
18-
module is only a generic file system layer and not depend on any specific
19-
storage device. You have to provide a low level disk I/O module that written
20-
to control the target storage device.
18+
module is only a generic file system layer and it does not depend on any specific
19+
storage device. You need to provide a low level disk I/O module written to
20+
control the storage device that attached to the target system.
2121

src/components/dfs/filesystems/elmfat/dfs_elm.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "components/dfs/include/dfs_fs.h"
3030
#include "components/dfs/include/dfs_file.h"
3131

32-
static rt_device_t disk[_VOLUMES] = {0};
32+
static rt_device_t disk[FF_VOLUMES] = {0};
3333

3434
static int elm_result_to_dfs(FRESULT result)
3535
{
@@ -86,7 +86,7 @@ static int get_disk(rt_device_t id)
8686
{
8787
int index;
8888

89-
for (index = 0; index < _VOLUMES; index ++)
89+
for (index = 0; index < FF_VOLUMES; index ++)
9090
{
9191
if (disk[index] == id)
9292
return index;
@@ -114,7 +114,7 @@ int dfs_elm_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *d
114114
/* check sector size */
115115
if (rt_device_control(fs->dev_id, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry) == RT_EOK)
116116
{
117-
if (geometry.bytes_per_sector > _MAX_SS)
117+
if (geometry.bytes_per_sector > FF_MAX_SS)
118118
{
119119
rt_kprintf("The sector size of device is greater than the sector size of FAT.\n");
120120
return -EINVAL;
@@ -202,7 +202,7 @@ int dfs_elm_mkfs(rt_device_t dev_id)
202202
int index;
203203
char logic_nbr[2] = {'0',':'};
204204

205-
work = rt_malloc(_MAX_SS);
205+
work = rt_malloc(FF_MAX_SS);
206206
if(RT_NULL == work) {
207207
return -ENOMEM;
208208
}
@@ -265,7 +265,7 @@ int dfs_elm_mkfs(rt_device_t dev_id)
265265
/* [IN] Size of the allocation unit */
266266
/* [-] Working buffer */
267267
/* [IN] Size of working buffer */
268-
result = f_mkfs(logic_nbr, FM_ANY|FM_SFD, 0, work, _MAX_SS);
268+
result = f_mkfs(logic_nbr, FM_ANY|FM_SFD, 0, work, FF_MAX_SS);
269269
rt_free(work); work = RT_NULL;
270270

271271
/* check flag status, we need clear the temp driver stored in disk[] */
@@ -299,7 +299,7 @@ int dfs_elm_statfs(struct dfs_filesystem *fs, struct statfs *buf)
299299

300300
f = (FATFS *)fs->data;
301301

302-
rt_snprintf(driver, sizeof(driver), "%d:", f->drv);
302+
rt_snprintf(driver, sizeof(driver), "%d:", f->pdrv);
303303
res = f_getfree(driver, &fre_clust, &f);
304304
if (res)
305305
return elm_result_to_dfs(res);
@@ -310,7 +310,7 @@ int dfs_elm_statfs(struct dfs_filesystem *fs, struct statfs *buf)
310310

311311
buf->f_bfree = fre_sect;
312312
buf->f_blocks = tot_sect;
313-
#if _MAX_SS != 512
313+
#if FF_MAX_SS != 512
314314
buf->f_bsize = f->ssize;
315315
#else
316316
buf->f_bsize = 512;
@@ -326,7 +326,7 @@ int dfs_elm_open(struct dfs_fd *file)
326326
FRESULT result;
327327
char *drivers_fn;
328328

329-
#if (_VOLUMES > 1)
329+
#if (FF_VOLUMES > 1)
330330
int vol;
331331
struct dfs_filesystem *fs = (struct dfs_filesystem *)file->data;
332332
extern int elm_get_vol(FATFS * fat);
@@ -356,7 +356,7 @@ int dfs_elm_open(struct dfs_fd *file)
356356
result = f_mkdir(drivers_fn);
357357
if (result != FR_OK)
358358
{
359-
#if _VOLUMES > 1
359+
#if FF_VOLUMES > 1
360360
rt_free(drivers_fn);
361361
#endif
362362
return elm_result_to_dfs(result);
@@ -367,14 +367,14 @@ int dfs_elm_open(struct dfs_fd *file)
367367
dir = (DIR *)rt_malloc(sizeof(DIR));
368368
if (dir == RT_NULL)
369369
{
370-
#if _VOLUMES > 1
370+
#if FF_VOLUMES > 1
371371
rt_free(drivers_fn);
372372
#endif
373373
return -ENOMEM;
374374
}
375375

376376
result = f_opendir(dir, drivers_fn);
377-
#if _VOLUMES > 1
377+
#if FF_VOLUMES > 1
378378
rt_free(drivers_fn);
379379
#endif
380380
if (result != FR_OK)
@@ -408,14 +408,14 @@ int dfs_elm_open(struct dfs_fd *file)
408408
fd = (FIL *)rt_malloc(sizeof(FIL));
409409
if (fd == RT_NULL)
410410
{
411-
#if _VOLUMES > 1
411+
#if FF_VOLUMES > 1
412412
rt_free(drivers_fn);
413413
#endif
414414
return -ENOMEM;
415415
}
416416

417417
result = f_open(fd, drivers_fn, mode);
418-
#if _VOLUMES > 1
418+
#if FF_VOLUMES > 1
419419
rt_free(drivers_fn);
420420
#endif
421421
if (result == FR_OK)
@@ -637,7 +637,7 @@ int dfs_elm_unlink(struct dfs_filesystem *fs, const char *path)
637637
{
638638
FRESULT result;
639639

640-
#if _VOLUMES > 1
640+
#if FF_VOLUMES > 1
641641
int vol;
642642
char *drivers_fn;
643643
extern int elm_get_vol(FATFS * fat);
@@ -657,7 +657,7 @@ int dfs_elm_unlink(struct dfs_filesystem *fs, const char *path)
657657
#endif
658658

659659
result = f_unlink(drivers_fn);
660-
#if _VOLUMES > 1
660+
#if FF_VOLUMES > 1
661661
rt_free(drivers_fn);
662662
#endif
663663
return elm_result_to_dfs(result);
@@ -667,7 +667,7 @@ int dfs_elm_rename(struct dfs_filesystem *fs, const char *oldpath, const char *n
667667
{
668668
FRESULT result;
669669

670-
#if _VOLUMES > 1
670+
#if FF_VOLUMES > 1
671671
char *drivers_oldfn;
672672
const char *drivers_newfn;
673673
int vol;
@@ -692,7 +692,7 @@ int dfs_elm_rename(struct dfs_filesystem *fs, const char *oldpath, const char *n
692692
#endif
693693

694694
result = f_rename(drivers_oldfn, drivers_newfn);
695-
#if _VOLUMES > 1
695+
#if FF_VOLUMES > 1
696696
rt_free(drivers_oldfn);
697697
#endif
698698
return elm_result_to_dfs(result);
@@ -703,7 +703,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
703703
FILINFO file_info;
704704
FRESULT result;
705705

706-
#if _VOLUMES > 1
706+
#if FF_VOLUMES > 1
707707
int vol;
708708
char *drivers_fn;
709709
extern int elm_get_vol(FATFS * fat);
@@ -723,7 +723,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
723723
#endif
724724

725725
result = f_stat(drivers_fn, &file_info);
726-
#if _VOLUMES > 1
726+
#if FF_VOLUMES > 1
727727
rt_free(drivers_fn);
728728
#endif
729729
if (result == FR_OK)

src/components/dfs/filesystems/elmfat/diskio.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
extern "C" {
1010
#endif
1111

12-
#include "integer.h"
13-
14-
1512
/* Status of Disk Functions */
1613
typedef BYTE DSTATUS;
1714

@@ -46,11 +43,11 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
4643
/* Command code for disk_ioctrl fucntion */
4744

4845
/* Generic command (Used by FatFs) */
49-
#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
50-
#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
51-
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
52-
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
53-
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
46+
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
47+
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
48+
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
49+
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
50+
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
5451

5552
/* Generic command (Not used by FatFs) */
5653
#define CTRL_POWER 5 /* Get/Set power status */

0 commit comments

Comments
 (0)