I’m trying to implement the littefs system with a w25n01g
chip and an stm32f405
with SPI
. Regarding the w25n01
library I use this one here
Here is what I’ve tried :
struct lfs_config cfg_lfs_w25n = { //My lfs config
.read = lfs_read,
.prog = lfs_prog,
.erase = lfs_erase,
.sync = lfs_sync,
.read_size = 2048,
.prog_size = 2048,
.block_size = 64*2048,
.block_count = 1024,
.cache_size = 4*2048,
.lookahead_size = 64,
.block_cycles = 500,
};
All my lfs
functions calling library function :
int lfs_sync(const struct lfs_config *c) {
return 0;
}
int lfs_erase(const struct lfs_config *c, lfs_block_t block) {
LOG_DEBUG("block %lu %d", block, c->block_size);
W25NXX_Erase_Block128K(block * c->block_size);
return 0;
}
int lfs_prog(const struct lfs_config *c, lfs_block_t block, lfs_off_t offset, const void *buffer, lfs_size_t size) {
W25NXX_Write((uint8_t *)buffer , (block * c->block_size + offset), size);
return 0;
}
int lfs_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t offset, void *buffer, lfs_size_t size) {
W25NXX_Read((uint8_t *)buffer , (block * c->block_size + offset), size);
return 0;
}
And for testing :
int f = lfs_format(&lfs, &cfg_lfs_w25n);
LOG_DEBUG("code format = %d", f);
int err = lfs_mount(&lfs, &cfg_lfs_w25n);
LOG_DEBUG("code mount = %d", err);
I encounter a problem when formatting my chip, I got LFS_ERR_NOSPC
error code, but mount
works well and return 0. Don’t understand what I’ve missed configuration and/or erase function ?
1