Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatfs 0.14b update #36302

Merged
merged 2 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions subsys/fs/Kconfig.fatfs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ endif # FS_FATFS_LFN

config FS_FATFS_CODEPAGE
int "FatFS code page (character set)"
default 437 if FS_FATFS_LFN
default 1
default 437
help
Valid code page values:
1 - ASCII (No extended character. Non-LFN cfg. only)
437 - U.S.
720 - Arabic
737 - Greek
Expand Down
25 changes: 17 additions & 8 deletions subsys/fs/fat_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,20 @@ static int fatfs_statvfs(struct fs_mount_t *mountp,
int res = -ENOTSUP;
#if !defined(CONFIG_FS_FATFS_READ_ONLY)
FATFS *fs;
DWORD f_bfree = 0;

res = f_getfree(&mountp->mnt_point[1], &stat->f_bfree, &fs);
res = f_getfree(&mountp->mnt_point[1], &f_bfree, &fs);
if (res != FR_OK) {
return -EIO;
}

stat->f_bfree = f_bfree;

/*
* _MIN_SS holds the sector size. It is one of the configuration
* FF_MIN_SS holds the sector size. It is one of the configuration
* constants used by the FS module
*/
stat->f_bsize = _MIN_SS;
stat->f_bsize = FF_MIN_SS;
stat->f_frsize = fs->csize * stat->f_bsize;
stat->f_blocks = (fs->n_fatent - 2);

Expand All @@ -416,10 +419,16 @@ static int fatfs_mount(struct fs_mount_t *mountp)
/* If no file system found then create one */
if (res == FR_NO_FILESYSTEM &&
(mountp->flags & FS_MOUNT_FLAG_NO_FORMAT) == 0) {
uint8_t work[_MAX_SS];

res = f_mkfs(&mountp->mnt_point[1],
(FM_FAT | FM_SFD), 0, work, sizeof(work));
uint8_t work[FF_MAX_SS];
MKFS_PARM mkfs_opt = {
.fmt = FM_FAT | FM_SFD, /* Any suitable FAT */
.n_fat = 1, /* One FAT fs table */
.align = 0, /* Get sector size via diskio query */
.n_root = 512, /* Max 512 root directory entries */
.au_size = 0 /* Auto calculate cluster size */
};

res = f_mkfs(&mountp->mnt_point[1], &mkfs_opt, work, sizeof(work));
if (res == FR_OK) {
res = f_mount((FATFS *)mountp->fs_data,
&mountp->mnt_point[1], 1);
Expand All @@ -435,7 +444,7 @@ static int fatfs_unmount(struct fs_mount_t *mountp)
{
FRESULT res;

res = f_mount(NULL, &mountp->mnt_point[1], 1);
res = f_mount(NULL, &mountp->mnt_point[1], 0);

return translate_error(res);
}
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ manifest:
groups:
- tools
- name: fatfs
revision: 1d1fcc725aa1cb3c32f366e0c53d7490d0fe1109
revision: 94fcd6bfb3801ac0a5e12ea2f52187e0a688b90e
path: modules/fs/fatfs
groups:
- fs
Expand Down