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

fs: littlefs: define default disk version in Kconfig #84181

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion modules/littlefs/zephyr_lfs_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern "C"
{
#endif

#ifdef CONFIG_FS_LITTLEFS_DISK_VERSION
#ifdef CONFIG_FS_LITTLEFS_MULTIVERSION
#define LFS_MULTIVERSION
#endif

Expand Down
9 changes: 8 additions & 1 deletion subsys/fs/Kconfig.littlefs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,19 @@ config FS_LITTLEFS_BLK_DEV
Enable this option to provide support for littlefs on the block
devices (like for example SD card).

config FS_LITTLEFS_DISK_VERSION
config FS_LITTLEFS_MULTIVERSION
bool "Support for selecting littlefs disk version"
default y if $(dt_compat_any_has_prop,$(DT_COMPAT_ZEPHYR_FSTAB_LITTLEFS),disk-version)
help
Enable this option to provide support for selecting littlefs disk version
to maintain backward compatibility with existing littlefs
with the same major disk version.

config FS_LITTLEFS_DISK_VERSION
hex "Default littlefs disk version"
default 0
depends on FS_LITTLEFS_MULTIVERSION
help
Set to 0 to use the latest littlefs disk version (LFS_DISK_VERSION).

endif # FILE_SYSTEM_LITTLEFS
15 changes: 9 additions & 6 deletions subsys/fs/littlefs_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,13 +789,16 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
lookahead_size = CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE;
}

#ifdef CONFIG_FS_LITTLEFS_DISK_VERSION
#ifdef CONFIG_FS_LITTLEFS_MULTIVERSION
uint32_t disk_version = lcp->disk_version;

if (disk_version == 0) {
disk_version = LFS_DISK_VERSION;
disk_version = CONFIG_FS_LITTLEFS_DISK_VERSION;
if (disk_version == 0) {
disk_version = LFS_DISK_VERSION;
}
}
#endif /* CONFIG_FS_LITTLEFS_DISK_VERSION */
#endif /* CONFIG_FS_LITTLEFS_MULTIVERSION */

/* No, you don't get to override this. */
lfs_size_t block_count = 0;
Expand Down Expand Up @@ -881,12 +884,12 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
lcp->sync = lfs_api_sync;
}

#ifdef CONFIG_FS_LITTLEFS_DISK_VERSION
#ifdef CONFIG_FS_LITTLEFS_MULTIVERSION
lcp->disk_version = disk_version;
LOG_INF("partition disk version: %u.%u",
(uint32_t)FS_LITTLEFS_DISK_VERSION_MAJOR_GET(disk_version),
(uint32_t)FS_LITTLEFS_DISK_VERSION_MINOR_GET(disk_version));
#endif /* CONFIG_FS_LITTLEFS_DISK_VERSION */
#endif /* CONFIG_FS_LITTLEFS_MULTIVERSION */

lcp->block_size = block_size;
lcp->block_count = block_count;
Expand Down Expand Up @@ -1060,7 +1063,7 @@ static const struct fs_file_system_t littlefs_fs = {

#define DT_DRV_COMPAT zephyr_fstab_littlefs
#define FS_PARTITION(inst) DT_PHANDLE_BY_IDX(DT_DRV_INST(inst), partition, 0)
#ifdef CONFIG_FS_LITTLEFS_DISK_VERSION
#ifdef CONFIG_FS_LITTLEFS_MULTIVERSION
#define FS_DISK_VERSION(inst) \
.disk_version = DT_INST_PROP_OR(inst, disk_version, LFS_DISK_VERSION),
#else
Expand Down
Loading