feat(fs): implement littlefs lfs.h driver support (#5562)
This commit is contained in:
@@ -14,6 +14,7 @@ LVG has built in support for:
|
||||
- POSIX (Linux and Windows using POSIX function .e.g ``open``, ``read``)
|
||||
- WIN32 (Windows using Win32 API function .e.g ``CreateFileA``, ``ReadFile``)
|
||||
- MEMFS (read a file from a memory buffer)
|
||||
- LITTLEFS (a little fail-safe filesystem designed for microcontrollers)
|
||||
|
||||
You still need to provide the drivers and libraries, this extension
|
||||
provides only the bridge between FATFS, STDIO, POSIX, WIN32 and LVGL.
|
||||
|
||||
@@ -22,3 +22,4 @@
|
||||
rlottie
|
||||
ffmpeg
|
||||
rle
|
||||
lfs
|
||||
|
||||
59
docs/libs/lfs.rst
Normal file
59
docs/libs/lfs.rst
Normal file
@@ -0,0 +1,59 @@
|
||||
.. _lfs:
|
||||
|
||||
==============
|
||||
littlefs
|
||||
==============
|
||||
|
||||
littlefs is a little fail-safe filesystem designed for microcontrollers.
|
||||
|
||||
Detailed introduction: https://github.com/littlefs-project/littlefs
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Enable :c:macro:`LV_USE_FS_LITTLEFS` and define a :c:macro`LV_FS_LITTLEFS_LETTER` in ``lv_conf.h``.
|
||||
|
||||
When enabled :c:macro:`lv_littlefs_set_handler` can be used to set up a mount point.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code:: c
|
||||
#include "lfs.h"
|
||||
|
||||
// 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,
|
||||
};
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
lv_littlefs_set_handler(&lfs);
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user