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

关于lfs_init断言失败问题 #1042

Open
Best-Hanc opened this issue Nov 9, 2024 · 0 comments
Open

关于lfs_init断言失败问题 #1042

Best-Hanc opened this issue Nov 9, 2024 · 0 comments

Comments

@Best-Hanc
Copy link

  1. 断言失败代码:
    // check that block size is a multiple of cache size is a multiple // of prog and read sizes LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->read_size == 0); LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->prog_size == 0); LFS_ASSERT(lfs->cfg->block_size % lfs->cfg->cache_size == 0);

  2. 打印提示如下:
    *** assertion failed: lfs->cfg->cache_size % lfs->cfg->read_size == 0, file packages\littlefs-latest\lfs.c, line 4184
    SIGABRT: Abnormal termination
    image

  3. 跟踪问题发现:
    执行static int DFS_LFS_MKFS(rt_device_t dev_id, const char *fs_name)函数中的result = lfs_format(&dfs_lfs->lfs, &dfs_lfs->cfg);代码时,dfs_lfs->cfg和进入lfs_format函数之后的cfg数据不一致,具体说应该是数据出现偏移
    image

  4. 解决方案:
    将lfs.h头文件struct lfs_config结构体中的如下代码,放到结构体最后
    `#ifdef LFS_THREADSAFE
    // Lock the underlying block device. Negative error codes
    // are propagated to the user.
    int (*lock)(const struct lfs_config *c);

    // Unlock the underlying block device. Negative error codes
    // are propagated to the user.
    int (*unlock)(const struct lfs_config *c);
    #endif`

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

1 participant