Skip to content

After adding content to a certain file multiple times, the file content is incorrect version is 2.7.0 #1174

@ming12345678-code

Description

@ming12345678-code

The flash chip I use is W25Q32FV
The system configuration is as follows
` fs.lfs_cfg.read = LittlefsRead;
fs.lfs_cfg.prog = LittlefsProg;
fs.lfs_cfg.erase = LittlefsErase;
fs.lfs_cfg.sync = LittlefsSync;
fs.lfs_cfg.lock = LittlefsLock;
fs.lfs_cfg.unlock = LittlefsUnlock;

fs.lfs_cfg.read_size = 1;
fs.lfs_cfg.prog_size = 256;
fs.lfs_cfg.block_size = 4096,
fs.lfs_cfg.block_count = 1024;
fs.lfs_cfg.cache_size = 256;
fs.lfs_cfg.lookahead_size = 256;
fs.lfs_cfg.block_cycles = 500;`

The test code is as follows
` char *date = "12345678901234567890";

err = lfs_remove(&fs.lfs_w25qxx,"/test3.txt");
if (err<0)
{
     printf("lfs_remove fail\r\n");
}else
{   
    printf("lfs_remove success\r\n");
    custom_delay_us(100000);
}

for (int i = 0; i < 36; i++)
{
    printf("number =%d \r\n",i);
    err = lfs_file_open(&fs.lfs_w25qxx, &file, "/test3.txt", LFS_O_RDWR | LFS_O_CREAT | LFS_O_APPEND);

    w_size = lfs_file_write(&fs.lfs_w25qxx, &file, date, strlen(date));
    printf("w_size =%d \r\n",w_size);

    err = lfs_file_close(&fs.lfs_w25qxx, &file);

    err = lfs_file_open(&fs.lfs_w25qxx, &file, "/test3.txt", LFS_O_RDWR | LFS_O_CREAT | LFS_O_APPEND);

    file_size = lfs_file_size(&fs.lfs_w25qxx, &file);
    printf("file_size =%d \r\n",file_size);

    err = lfs_file_close(&fs.lfs_w25qxx, &file);

    printf(" \r\n\r\n");

    custom_delay_us(100000);
}`

The result obtained from running the test code is that the file size did not reach the expected 720 bytes, and the final size was 280 bytes. The test log shows that after the file size reached about 256 bytes, the file would drop back from 280 bytes to 260 bytes, constantly fluctuating between this value. Is this a problem with the parameter Settings or the operation? Because our business requires multiple write operations within a certain period of time, we found this problem during the usage process. Can this be solved?

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions