ARM面向IoT推出Littlefs,并对比了FATfs

2019-12-12 18:21发布

File systems for embedded systems and IoT devices have some additional requirements:

Power-cut resilience - it requires strong guarantees that the file system remains consistent, and data is flushed to the underlying storage.
Wear-leveling - typically storage supports a limited number of erases per block, so making use of the entire storage device is important for reliability.
Tiny footprint - IoT devices are constrained by ROM and RAM. A small footprint saves money.




友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
72条回答
shangdawei
1楼-- · 2019-12-17 03:58
https://github.com/geky/littlefs

littlefs-master.zip (57.79 KB, 下载次数: 77) 2017-12-27 07:56 上传 点击文件名下载附件

gamep
2楼-- · 2019-12-17 05:05
好消息,又多一个选择。
joesonzzy
3楼-- · 2019-12-17 10:29
学习了,以后可以用到Littlefs
52avr
4楼-- · 2019-12-17 13:06
 精彩回答 2  元偷偷看……
lindabell
5楼-- · 2019-12-17 13:17
用Qt试了一下,仅仅试一试;
用数组来模拟falsh的。

  1. #include "lfs.h"
  2. #include "lfs_emubd.h"
  3. #include "lfs_ram.h"
  4. // variables used by the filesystem
  5. lfs_t lfs;
  6. lfs_file_t file;

  7. // configuration of the filesystem is provided by this struct
  8. struct lfs_config cfg = {
  9.     // block device operations
  10.     .read  = lfs_ram_read,
  11.     .prog  = lfs_ram_prog,
  12.     .erase = lfs_ram_erase,
  13.     .sync  = lfs_ram_sync,

  14.     // block device configuration
  15.     .read_size = 16,
  16.     .prog_size = 16,
  17.     .block_size = 1024,
  18.     .block_count =10240,
  19.     .lookahead = 128,
  20.     .context=&cfg,
  21. };

  22. // entry point
  23. int main(void)
  24. {


  25.     // mount the filesystem
  26.     int err = lfs_mount(&lfs, &cfg);

  27.     // reformat if we can't mount the filesystem
  28.     // this should only happen on the first boot
  29.     if (err) {
  30.         lfs_format(&lfs, &cfg);
  31.         lfs_mount(&lfs, &cfg);
  32.     }

  33.     // read current count
  34.     uint32_t boot_count = 0;
  35.     lfs_file_open(&lfs, &file, "boot_count", LFS_O_RDWR | LFS_O_CREAT);
  36.     lfs_file_read(&lfs, &file, &boot_count, sizeof(boot_count));

  37.     // update boot count
  38.     boot_count += 1;
  39.     lfs_file_rewind(&lfs, &file);
  40.     lfs_file_write(&lfs, &file, &boot_count, sizeof(boot_count));

  41.     // remember the storage is not updated until the file is closed successfully
  42.     lfs_file_close(&lfs, &file);

  43.     // release any resources we were using
  44.     lfs_unmount(&lfs);

  45.     // print the boot count
  46.     printf("boot_count: %d ", boot_count);


  47.     //test
  48.     boot_count=0;
  49.     lfs_mount(&lfs, &cfg);
  50.     lfs_file_open(&lfs, &file, "boot_count", LFS_O_RDWR | LFS_O_CREAT);
  51.     lfs_file_read(&lfs, &file, &boot_count, sizeof(boot_count));
  52.     printf("boot_count: %d ", boot_count);
  53.     boot_count++;
  54.     lfs_file_rewind(&lfs, &file);
  55.     lfs_file_write(&lfs, &file, &boot_count, sizeof(boot_count));
  56.     lfs_file_close(&lfs, &file);
  57.     lfs_unmount(&lfs);

  58.     //test
  59.     boot_count=0;
  60.     lfs_mount(&lfs, &cfg);
  61.     lfs_file_open(&lfs, &file, "boot_count", LFS_O_RDWR | LFS_O_CREAT);
  62.     lfs_file_read(&lfs, &file, &boot_count, sizeof(boot_count));
  63.     printf("boot_count: %d ", boot_count);
  64.     boot_count++;
  65.     lfs_file_rewind(&lfs, &file);
  66.     lfs_file_write(&lfs, &file, &boot_count, sizeof(boot_count));
  67.     lfs_file_close(&lfs, &file);
  68.     lfs_unmount(&lfs);

  69.     //test
  70.     boot_count=0;
  71.     lfs_mount(&lfs, &cfg);
  72.     lfs_file_open(&lfs, &file, "boot_count", LFS_O_RDWR | LFS_O_CREAT);
  73.     lfs_file_read(&lfs, &file, &boot_count, sizeof(boot_count));
  74.     printf("boot_count: %d ", boot_count);
  75.     boot_count++;
  76.     lfs_file_rewind(&lfs, &file);
  77.     lfs_file_write(&lfs, &file, &boot_count, sizeof(boot_count));
  78.     lfs_file_close(&lfs, &file);
  79.     lfs_unmount(&lfs);

  80. }
复制代码

littlefs.zip (62.27 KB, 下载次数: 66) 2017-12-27 21:13 上传 点击文件名下载附件
windrarara
6楼-- · 2019-12-17 13:38
nandflash可用吗?

一周热门 更多>