|
按照官网的代码移植,https://github.com/littlefs-project/littlefs:
- #include "lfs.h"
- // variables used by the filesystem
- lfs_t lfs;
- lfs_file_t file;
- // configuration of the filesystem is provided by this struct
- const struct lfs_config cfg = {
- // block device operations
- .read = user_provided_block_device_read,
- .prog = user_provided_block_device_prog,
- .erase = user_provided_block_device_erase,
- .sync = user_provided_block_device_sync,
- // block device configuration
- .read_size = 16,
- .prog_size = 16,
- .block_size = 4096,
- .block_count = 128,
- .cache_size = 16,
- .lookahead_size = 16,
- .block_cycles = 500,
- };
- // entry point
- int main(void) {
- // mount the filesystem
- int err = lfs_mount(&lfs, &cfg);
- // reformat if we can't mount the filesystem
- // this should only happen on the first boot
- if (err) {
- lfs_format(&lfs, &cfg);
- lfs_mount(&lfs, &cfg);
- }
- // read current count
- uint32_t boot_count = 0;
- lfs_file_open(&lfs, &file, "boot_count", LFS_O_RDWR | LFS_O_CREAT);
- lfs_file_read(&lfs, &file, &boot_count, sizeof(boot_count));
- // update boot count
- boot_count += 1;
- lfs_file_rewind(&lfs, &file);
- lfs_file_write(&lfs, &file, &boot_count, sizeof(boot_count));
- // remember the storage is not updated until the file is closed successfully
- lfs_file_close(&lfs, &file);
- // release any resources we were using
- lfs_unmount(&lfs);
- // print the boot count
- printf("boot_count: %d\n", boot_count);
- }
复制代码
其中三个Flash操作的代码都换成了自已的代码,操作Flash没有问题,但是运行的时候会在串口输出提示:
放狗搜了很多也有类似报错的,但是没有解决方法。我这个把别人移植好的代码直接拷过来换成自已Flash操作代码,一样的堤示,不明白是哪里的问题。有人移值碰到过同样的问题吗?
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|