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 <zueger.peter@icloud.com>
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy