Skip to content

Commit 6515cd0

Browse files
pi-anldpgeorge
authored andcommitted
extmod/vfs_lfsx: Allow overriding the LFS2 on-disk version format.
Back in LFS2 version 2.6 they updated the on-disk version from 2.0 to 2.1 which broke back compatibility (aka older versions could no long read new version disk format), see https://github.com/littlefs-project/littlefs/releases/tag/v2.6.0 Then in LFS2 v2.7 an optional `config->disk_version` was added to force the library to use an older disk format instead, see: https://github.com/littlefs-project/littlefs/releases/tag/v2.7.0 This commit simply exposes `config->disk_version` as a compile time option if LFS2_MULTIVERSION is set, otherwise there is no change in behavior. This is Useful for compatibility with older LFS versions. Note: LFS2_MULTIVERSION needs to be defined at the make / CFLAGS level, setting it in mpconfigboard.h doesn't work as it's not included in the `lfs2.c` file in any way. Signed-off-by: Andrew Leech <[email protected]>
1 parent 28082d1 commit 6515cd0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

extmod/vfs_lfsx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ static void MP_VFS_LFSx(init_config)(MP_OBJ_VFS_LFSx * self, mp_obj_t bdev, size
104104
config->read_buffer = m_new(uint8_t, config->cache_size);
105105
config->prog_buffer = m_new(uint8_t, config->cache_size);
106106
config->lookahead_buffer = m_new(uint8_t, config->lookahead_size);
107+
#ifdef LFS2_MULTIVERSION
108+
// This can be set to override the on-disk lfs version.
109+
// eg. for compat with lfs2 < v2.6 add the following to make:
110+
// CFLAGS += '-DLFS2_MULTIVERSION=0x00020000'
111+
config->disk_version = LFS2_MULTIVERSION;
112+
#endif
107113
#endif
108114
}
109115

0 commit comments

Comments
 (0)