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>
This commit is contained in:
parent
01f72f92b4
commit
e638602b6a
2 changed files with 20 additions and 0 deletions
|
|
@ -76,6 +76,11 @@
|
|||
#define FF_LBA64 CONFIG_FS_FATFS_LBA64
|
||||
#endif /* defined(CONFIG_FS_FATFS_LBA64) */
|
||||
|
||||
#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) */
|
||||
|
||||
/*
|
||||
* These options are override from default values, but have no Kconfig
|
||||
* options.
|
||||
|
|
|
|||
|
|
@ -237,6 +237,21 @@ config FS_FATFS_LBA64
|
|||
This option enables support for 64-bit LBA, which also
|
||||
enables GPT support.
|
||||
|
||||
config FS_FATFS_MULTI_PARTITION
|
||||
bool "Support for multiple volumes on the physical drive"
|
||||
help
|
||||
When this function is enabled, each logical drive number can
|
||||
be bound to arbitrary physical drive and partition listed
|
||||
in the VolToPart[] of the fatfs module. The VolToPart[] is expected to be
|
||||
provided by Zephyr application.
|
||||
The mount points have to be numbered in this case.
|
||||
For example, 2 FAT partition on SD disk (3) in terms of Zephyr:
|
||||
{3, 1} - mount point "/0:"
|
||||
{3, 2} - mount point "/1:"
|
||||
When disabled (default), each logical drive number is bound to the same
|
||||
physical drive number and only an FAT volume found on the physical drive
|
||||
will be mounted.
|
||||
|
||||
endmenu
|
||||
|
||||
endif # FAT_FILESYSTEM_ELM
|
||||
|
|
|
|||
Loading…
Reference in a new issue