Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to use littlefs with v1.20.0 #52

Open
simon88 opened this issue Oct 24, 2024 · 1 comment
Open

Trying to use littlefs with v1.20.0 #52

simon88 opened this issue Oct 24, 2024 · 1 comment

Comments

@simon88
Copy link

simon88 commented Oct 24, 2024

Hi,
I'm trying to use your librairy version 1.20.0 (old version) with little fs and w25q16 chip, but I'm stuck when I'm trying to format the chip.
I'm able to detect the flash

w25qxx Init Begin...
w25qxx ID:0xEF4015
w25qxx Chip: w25q16
w25qxx Page Size: 256 Bytes
w25qxx Page Count: 8192
w25qxx Sector Size: 4096 Bytes
w25qxx Sector Count: 512
w25qxx Block Size: 65536 Bytes
w25qxx Block Count: 32
w25qxx Capacity: 2048 KiloBytes
w25qxx Init Done

here is my lfs configuration

#define LFS_BUFFER_SIZE     256
static uint8_t read_buffer[LFS_BUFFER_SIZE];
static uint8_t prog_buffer[LFS_BUFFER_SIZE];
static uint8_t lookahead_buffer[128];


struct lfs_config cfg_lfs = {
        .read = lfs_read,
        .prog = lfs_prog,
        .erase = lfs_erase,
        .sync = lfs_sync,

        .read_size = 256,
        .prog_size = 256,
        .block_size = 4096,
        .block_count = 32,
        .cache_size = 256,
        .lookahead_size = 128,
        .block_cycles = 500,

        .read_buffer = read_buffer,
        .prog_buffer = prog_buffer,
        .lookahead_buffer = lookahead_buffer
};

And wrapper

int lfs_sync(const struct lfs_config *c) {
  return 0;
}

int lfs_erase(const struct lfs_config *c, lfs_block_t block) {
  W25qxx_EraseBlock(&handler_spi, 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) {
  W25qxx_WritePage(&handler_spi, (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) {
  W25qxx_ReadPage(&handler_spi, (uint8_t*)buffer, block*c->block_size, offset, size);
  return 0;
}

my handler

w25qxx_peripheral handler_spi = {
        .hspi = &hspi2,           // Initialisation du périphérique SPI
        .cs_gpio = GPIOB,          // Port GPIOB pour le Chip Select
        .cs_pin = GPIO_PIN_12
};

Have ever use littlefs or not ?

EDIT : after updating lfs_configwith

        .block_size = 65536,
        .block_count = 32,

I'm able to format but as soon as I try to create a file I got lfs error no more free space 0xb

@nimaltd
Copy link
Owner

nimaltd commented Oct 26, 2024

Hi. unfortunately i have never used little fs. but why you did not try with new library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants