From b3d08857615b0e0e637d8b5658d7abb029cd7775 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Wed, 16 Jun 2021 11:31:18 +0000 Subject: [PATCH 1/2] west.yml: Update FAT FS driver revision to raise version to 0.14b The commit updates revision of the Zephyr for of ELM Chan FAT FS driver to the revision that updates source code to version 0.14b. Signed-off-by: Dominik Ermel --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 0c8ec26df4d86a..12e1284a3e8dff 100644 --- a/west.yml +++ b/west.yml @@ -42,7 +42,7 @@ manifest: groups: - tools - name: fatfs - revision: 1d1fcc725aa1cb3c32f366e0c53d7490d0fe1109 + revision: 94fcd6bfb3801ac0a5e12ea2f52187e0a688b90e path: modules/fs/fatfs groups: - fs From fc51edbcf086447baff8201429d6c44f919cf99e Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Wed, 16 Jun 2021 11:35:31 +0000 Subject: [PATCH 2/2] fs/fatfs: Apply changes required for version 0.14b The commit applies changes that are required by update of ELM Chan's FAT FS driver update to version 0.14b. Signed-off-by: Dominik Ermel --- subsys/fs/Kconfig.fatfs | 4 +--- subsys/fs/fat_fs.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/subsys/fs/Kconfig.fatfs b/subsys/fs/Kconfig.fatfs index 4e0b3ef5041eff..99018fb53d51c0 100644 --- a/subsys/fs/Kconfig.fatfs +++ b/subsys/fs/Kconfig.fatfs @@ -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 diff --git a/subsys/fs/fat_fs.c b/subsys/fs/fat_fs.c index 809ff6e6de4077..2a3aedf917031f 100644 --- a/subsys/fs/fat_fs.c +++ b/subsys/fs/fat_fs.c @@ -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); @@ -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); @@ -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); }