首页 > 解决方案 > LittleFS 在我尝试挂载时返回 LFS_ERR_CORRUPT 和 LFS_ERR_NOSPC

问题描述

我正在将 LittleFS 移植到我正在处理的项目中,当我尝试安装它时,它返回 -84(已损坏)。在那之后,我格式化文件系统并尝试重新挂载它,然后它返回 -28(设备上没有剩余空间)。

这是我要实现的代码:

/* variables used by the filesystem */

const U8 lfs_read_buf[256];
const U8 lfs_prog_buf[256];
const U8 lfs_lookahead_buf[16];

lfs_t lfs;

/* configuration of the filesystem is provided by this struct */

const struct lfs_config cfg = {
  // block device operations
  .read  = FLASHEx_block_read,
  .prog  = FLASHEx_block_write,
  .erase = FLASHEx_block_erase,
  .sync  = FLASHEx_block_sync,

  // block device configuration
  .read_size       = 256,
  .prog_size       = 256,
  .block_size      = 4096,
  .block_count     = 3072, // The block count is actually 4096, but I lowered it to test. (Failed.)
  .cache_size      = 256,
  .lookahead_size  = 256,
  .block_cycles    = 200,

  .read_buffer      = (void*)lfs_read_buf,
  .prog_buffer      = (void*)lfs_prog_buf,
  .lookahead_buffer = (void*)lfs_lookahead_buf,

};

 // mount the filesystem
  int err = lfs_mount(&lfs, &cfg); // Returns LFS_ERR_CORRUPT (-84, "Corrupted")

  // reformat to try to re-mount the filesystem
  if (err) {
    err = lfs_format(&lfs, &cfg); // Returns -28 (no space left on device).
    err = lfs_mount(&lfs, &cfg);  // Returns -28 (no space left on device).
  }

我使用的外部闪存模块是Winbond W25Q128JV

我的实现基于这篇网络文章LittleFS 文档示例。

任何人都可以阐明使它起作用吗?

谢谢你。

标签: armfilesystemsembedded

解决方案


推荐阅读