zephyr/modules/fatfs
Grygorii Strashko e638602b6a 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-09-03 14:39:18 +01:00
..
CMakeLists.txt
Kconfig
zephyr_fatfs_config.h fs: fatfs: Add CONFIG_FS_MULTI_PARTITION 2024-09-03 14:39:18 +01:00
zfs_diskio.c
zfs_diskio.h
zfs_ffsystem.c