基于W25Q256的Littlefs无法打开大量文件

问题描述 投票:0回答:1

**我在W25Q256上使用littlefs来管理我的文件。当我使用 Github“tests/test_files.toml”上的 Littlefs 时,它有问题。 开始时代码运行正确并且“open_return”= 0“read_return”= 7;当代码“for (int i = 0; i < MANY_FILES_N; i++)" i run to 63 it suspended and lasts for 20seconds. Then "open_return" = -2 and "read_return" = -84. When I change ".read_size" = 64, ".prog_size" = 64, the error will be quick as i run to 31. I don not konw where has the problem, maybe littlefs interrupt function, maybe w25q, maybe spi. I know littlefs is an uncommon file system. I can not use it well. **

enter code here

无效的many_files_test() {

    uint8_t *path = rt_malloc(20);

    format_return = lfs_format(&lfs, &lfs_cfg);
    
    mount_return = lfs_mount(&lfs, &lfs_cfg);
    
    for (int i = 0; i < 100; i++) {
        
        sprintf(path, "file_%03d", i);
        
        open_return = lfs_file_open(&lfs, &lfs_file, path,
                  LFS_O_WRONLY | LFS_O_CREAT | LFS_O_EXCL);
        
        size = 7;
        snprintf(wbuffer, size, "Hi %03d", i);
        write_return = lfs_file_write(&lfs, &lfs_file, wbuffer, size);
       
        close_return = lfs_file_close(&lfs, &lfs_file);
        

        for(uint16_t file_count = 0; file_count < i + 1; file_count++)
        {
            sprintf(path, "file_%03d", file_count);
            open_return = lfs_file_open(&lfs, &lfs_file, path, LFS_O_RDONLY);
           
            read_return = lfs_file_read(&lfs, &lfs_file, rbuffer, size);
            
            close_return = lfs_file_close(&lfs, &lfs_file);
           
        }
    }
    unmount_return = lfs_unmount(&lfs);
   
    rt_free(path);
}
c file flash spi
1个回答
0
投票

我也有类似的问题,也找不到原因。有大神可以给点建议吗

© www.soinside.com 2019 - 2024. All rights reserved.