Skip to content

Commit ce42c9e

Browse files
peterzugerdpgeorge
authored andcommitted
extmod/vfs_lfs: Fix lfs cache_size calculation.
The calculation of the lfs2 cache_size was incorrect, the maximum allowed size is block_size. The cache size must be: "a multiple of the read and program sizes, and a factor of the block size". Signed-off-by: Peter Züger <[email protected]>
1 parent 3bca93b commit ce42c9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extmod/vfs_lfsx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ STATIC void MP_VFS_LFSx(init_config)(MP_OBJ_VFS_LFSx * self, mp_obj_t bdev, size
9999
config->lookahead_buffer = m_new(uint8_t, config->lookahead / 8);
100100
#else
101101
config->block_cycles = 100;
102-
config->cache_size = 4 * MAX(read_size, prog_size);
102+
config->cache_size = MIN(config->block_size, (4 * MAX(read_size, prog_size)));
103103
config->lookahead_size = lookahead;
104104
config->read_buffer = m_new(uint8_t, config->cache_size);
105105
config->prog_buffer = m_new(uint8_t, config->cache_size);

0 commit comments

Comments
 (0)