2022-10-28 14:51:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 Nordic Semiconductor ASA
|
2022-12-16 16:05:02 +01:00
|
|
|
* Copyright (c) 2023 Husqvarna AB
|
2022-10-28 14:51:22 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2022-11-23 14:27:38 +00:00
|
|
|
#if FFCONF_DEF != 80286
|
2022-10-28 14:51:22 +00:00
|
|
|
#error "Configuration version mismatch"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Overrides of FF_ options from ffconf.h
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_FS_FATFS_READ_ONLY)
|
|
|
|
#undef FF_FS_READONLY
|
|
|
|
#define FF_FS_READONLY CONFIG_FS_FATFS_READ_ONLY
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_READ_ONLY) */
|
|
|
|
|
|
|
|
#if defined(CONFIG_FS_FATFS_MKFS)
|
|
|
|
#undef FF_USE_MKFS
|
|
|
|
#define FF_USE_MKFS CONFIG_FS_FATFS_MKFS
|
|
|
|
#else
|
|
|
|
/* Note that by default the ffconf.h disables MKFS */
|
|
|
|
#undef FF_USE_MKFS
|
|
|
|
#define FF_USE_MKFS 1
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_MKFS) */
|
|
|
|
|
|
|
|
#if defined(CONFIG_FS_FATFS_CODEPAGE)
|
|
|
|
#undef FF_CODE_PAGE
|
|
|
|
#define FF_CODE_PAGE CONFIG_FS_FATFS_CODEPAGE
|
|
|
|
#else
|
|
|
|
/* Note that default value, in ffconf.h, for FF_CODE_PAGE is 932 */
|
|
|
|
#undef FF_CODE_PAGE
|
|
|
|
#define FF_CODE_PAGE 437
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_CODEPAGE) */
|
|
|
|
|
2022-11-23 11:16:29 +00:00
|
|
|
#if defined(CONFIG_FS_FATFS_FF_USE_LFN)
|
|
|
|
#if CONFIG_FS_FATFS_FF_USE_LFN <= 3
|
2022-10-28 14:51:22 +00:00
|
|
|
#undef FF_USE_LFN
|
2022-11-23 11:16:29 +00:00
|
|
|
#define FF_USE_LFN CONFIG_FS_FATFS_FF_USE_LFN
|
2022-10-28 14:51:22 +00:00
|
|
|
#else
|
|
|
|
#error Invalid LFN buffer location
|
|
|
|
#endif
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_LFN) */
|
|
|
|
|
|
|
|
#if defined(CONFIG_FS_FATFS_MAX_LFN)
|
|
|
|
#undef FF_MAX_LFN
|
|
|
|
#define FF_MAX_LFN CONFIG_FS_FATFS_MAX_LFN
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_MAX_LFN) */
|
|
|
|
|
2022-11-24 13:15:10 +00:00
|
|
|
#if defined(CONFIG_FS_FATFS_MIN_SS)
|
|
|
|
#undef FF_MIN_SS
|
|
|
|
#define FF_MIN_SS CONFIG_FS_FATFS_MIN_SS
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_MIN_SS) */
|
|
|
|
|
2022-10-28 14:51:22 +00:00
|
|
|
#if defined(CONFIG_FS_FATFS_MAX_SS)
|
|
|
|
#undef FF_MAX_SS
|
|
|
|
#define FF_MAX_SS CONFIG_FS_FATFS_MAX_SS
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_MAX_SS) */
|
|
|
|
|
|
|
|
#if defined(CONFIG_FS_FATFS_EXFAT)
|
|
|
|
#undef FF_FS_EXFAT
|
|
|
|
#define FF_FS_EXFAT CONFIG_FS_FATFS_EXFAT
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_EXFAT) */
|
|
|
|
|
2022-12-16 16:05:02 +01:00
|
|
|
#if defined(CONFIG_FS_FATFS_REENTRANT)
|
|
|
|
#undef FF_FS_REENTRANT
|
|
|
|
#undef FF_FS_TIMEOUT
|
|
|
|
#include <zephyr/kernel.h>
|
|
|
|
#define FF_FS_REENTRANT CONFIG_FS_FATFS_REENTRANT
|
|
|
|
#define FF_FS_TIMEOUT K_FOREVER
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_REENTRANT) */
|
|
|
|
|
2024-05-31 18:13:44 +03:00
|
|
|
#if defined(CONFIG_FS_FATFS_LBA64)
|
|
|
|
#undef FF_LBA64
|
|
|
|
#define FF_LBA64 CONFIG_FS_FATFS_LBA64
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_LBA64) */
|
|
|
|
|
fs: fatfs: Add CONFIG_FS_MULTI_PARTITION
This option switches support for multiple volumes on the physical drive. By
default (0), each logical drive number is bound to the same physical drive
number and only a first FAT volume found on the physical drive will be
mounted.
When this function is enabled (1), each logical drive number can be bound
to arbitrary physical drive and partition listed in the VolToPart[].
The VolToPart[] is expected to be provided by Zephyr application.
For example, 2 FAT partition on SD disk ("SD" index 3) in terms of Zephyr:
{3, 1} - mount point "/0:"
{3, 2} - mount point "/1:"
The mount points have to be numbered in this case.
Code example of mounting a second FATFS partition places on SD-card:
static FATFS fat_fs;
static struct fs_mount_t mp = {
.type = FS_FATFS,
.fs_data = &fat_fs,
.mnt_point = "/1:
};
/*
* 2 FAT partition on SD disk
* PARTITION.pd - Physical drive number. "SD" has index 3 in terms of
* Zephyr (see FF_VOLUME_STRS)
* PARTITION.pt - Partition (0:Auto detect, 1-4:Forced partition). So 1 for
* the first FATFS partition and 2 - for second.
*/
PARTITION VolToPart[FF_VOLUMES] = {
[0] = {3, 1}, /* "0:" ==> 1st partition on the pd#0 */
[1] = {3, 2}, /* "1:" ==> 2nd partition on the pd#0 */
[2] = {0, -1}, /* "2:" ==> 3rd partition on the pd#0 */
[3] = {0, -1},
[4] = {0, -1},
[5] = {0, -1},
[6] = {0, -1},
[7] = {0, -1},
};
fs_mount(&mp);
Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
2024-06-01 11:43:10 +03:00
|
|
|
#if defined(CONFIG_FS_FATFS_MULTI_PARTITION)
|
|
|
|
#undef FF_MULTI_PARTITION
|
|
|
|
#define FF_MULTI_PARTITION CONFIG_FS_FATFS_MULTI_PARTITION
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_MULTI_PARTITION) */
|
|
|
|
|
2022-10-28 14:51:22 +00:00
|
|
|
/*
|
|
|
|
* These options are override from default values, but have no Kconfig
|
|
|
|
* options.
|
|
|
|
*/
|
|
|
|
#undef FF_FS_TINY
|
|
|
|
#define FF_FS_TINY 1
|
|
|
|
|
|
|
|
#undef FF_FS_NORTC
|
2024-07-11 14:58:16 +10:00
|
|
|
#if defined(CONFIG_FS_FATFS_HAS_RTC)
|
|
|
|
#define FF_FS_NORTC 0
|
|
|
|
#else
|
2022-10-28 14:51:22 +00:00
|
|
|
#define FF_FS_NORTC 1
|
2024-07-11 14:58:16 +10:00
|
|
|
#endif /* defined(CONFIG_FS_FATFS_HAS_RTC) */
|
2022-10-28 14:51:22 +00:00
|
|
|
|
|
|
|
/* Zephyr uses FF_VOLUME_STRS */
|
|
|
|
#undef FF_STR_VOLUME_ID
|
|
|
|
#define FF_STR_VOLUME_ID 1
|
|
|
|
|
|
|
|
/* By default FF_STR_VOLUME_ID in ffconf.h is 0, which means that
|
|
|
|
* FF_VOLUME_STRS is not used. Zephyr uses FF_VOLUME_STRS, which
|
|
|
|
* by default holds 8 possible strings representing mount points,
|
|
|
|
* and FF_VOLUMES needs to reflect that, which means that dolt
|
|
|
|
* value of 1 is overridden here with 8.
|
|
|
|
*/
|
|
|
|
#undef FF_VOLUMES
|
|
|
|
#define FF_VOLUMES 8
|
|
|
|
|
2024-07-11 14:58:16 +10:00
|
|
|
#if defined(CONFIG_FS_FATFS_EXTRA_NATIVE_API)
|
|
|
|
#undef FF_USE_LABEL
|
|
|
|
#undef FF_USE_EXPAND
|
|
|
|
#undef FF_USE_FIND
|
|
|
|
#define FF_USE_LABEL 1
|
|
|
|
#define FF_USE_EXPAND 1
|
|
|
|
#define FF_USE_FIND 1
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_EXTRA_NATIVE_API) */
|
|
|
|
|
2022-10-28 14:51:22 +00:00
|
|
|
/*
|
|
|
|
* Options provided below have been added to ELM FAT source code to
|
|
|
|
* support Zephyr specific features, and are not part of ffconf.h.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* The FS_FATFS_WINDOW_ALIGNMENT is used to align win buffer of FATFS structure
|
|
|
|
* to allow more optimal use with MCUs that require specific bufer alignment
|
|
|
|
* for DMA to work.
|
|
|
|
*/
|
|
|
|
#if defined(CONFIG_FS_FATFS_WINDOW_ALIGNMENT)
|
|
|
|
#define FS_FATFS_WINDOW_ALIGNMENT CONFIG_FS_FATFS_WINDOW_ALIGNMENT
|
|
|
|
#else
|
|
|
|
#define FS_FATFS_WINDOW_ALIGNMENT 1
|
|
|
|
#endif /* defined(CONFIG_FS_FATFS_WINDOW_ALIGNMENT) */
|