Skip to content

Commit 1bd3d70

Browse files
committed
fs: Add a minimal littlefs blocksize
Prevents littlefs from failing when block size is too small to work Signed-off-by: Camille BAUD <[email protected]>
1 parent fd51dde commit 1bd3d70

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/fs/littlefs_fs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
/* Used on devices that have no explicit erase */
3232
#define LITTLEFS_DEFAULT_BLOCK_SIZE 4096
33+
/* Rounded up from minimal block size for littlefs working */
34+
#define LITTLEFS_MINIMUM_BLOCK_SIZE 128
3335

3436
/* note: one of the next options have to be enabled, at least */
3537
BUILD_ASSERT(IS_ENABLED(CONFIG_FS_LITTLEFS_BLK_DEV) ||
@@ -786,6 +788,10 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
786788
return -EINVAL;
787789
}
788790

791+
if (block_size < LITTLEFS_MINIMUM_BLOCK_SIZE) {
792+
block_size = LITTLEFS_MINIMUM_BLOCK_SIZE;
793+
}
794+
789795
int32_t block_cycles = lcp->block_cycles;
790796

791797
if (block_cycles == 0) {

0 commit comments

Comments
 (0)