ESP LV FS
esp_lv_fs allows LVGL to use filesystems for accessing assets. This component integrates with esp_mmap_assets to efficiently manage file operations and supports multiple partitions.
Features
Integrates with esp_mmap_assets for filesystem creation.
Supports standard file operations: fopen, fclose, fread, ftell, and fseek.
Uses the esp_partition_read API for efficient file access.
Supports multiple partitions.
Dependencies
The esp_mmap_assets component is required. It provides file offset index relationship.
Application Examples
Register Filesystem
Register the Filesystem after LVGL starts.
#include "esp_lv_fs.h"
#include "esp_mmap_assets.h"
esp_lv_fs_handle_t fs_drive_a_handle;
mmap_assets_handle_t mmap_drive_a_handle;
const mmap_assets_config_t asset_cfg = {
.partition_label = "assets_A",
.max_files = MMAP_DRIVE_A_FILES,
.checksum = MMAP_DRIVE_A_CHECKSUM,
.flags = {
.mmap_enable = true,
}
};
mmap_assets_new(&asset_cfg, &mmap_drive_a_handle);
const fs_cfg_t fs_drive_a_cfg = {
.fs_letter = 'A',
.fs_assets = mmap_drive_a_handle,
.fs_nums = MMAP_DRIVE_A_FILES
};
esp_lv_fs_desc_init(&fs_drive_a_cfg, &fs_drive_a_handle);
API Reference
Header File
Functions
-
esp_err_t esp_lv_fs_desc_init(const fs_cfg_t *cfg, esp_lv_fs_handle_t *ret_handle)
Initialize file descriptors for the filesystem.
This function sets up the filesystem by initializing file descriptors based on the provided configuration. It allocates necessary memory and populates the file descriptors with information about the assets.
- Parameters
cfg – [in] Pointer to the filesystem configuration structure.
ret_handle – [out] Pointer to the handle that will hold the initialized filesystem instance.
- Returns
ESP_OK: Success
ESP_ERR_INVALID_ARG: Invalid argument
ESP_ERR_NO_MEM: Memory allocation failed
-
esp_err_t esp_lv_fs_desc_deinit(esp_lv_fs_handle_t handle)
Deinitialize the filesystem and clean up resources.
This function cleans up the filesystem by freeing allocated memory for file descriptors and other resources associated with the provided handle.
- Parameters
handle – [in] Handle to the filesystem instance to be deinitialized.
- Returns
ESP_OK: Success
ESP_ERR_INVALID_ARG: Invalid argument
Structures
-
struct fs_cfg_t
Configuration structure for the filesystem.
Public Members
-
char fs_letter
Filesystem letter identifier
-
int fs_nums
Number of filesystem instances
-
mmap_assets_handle_t fs_assets
Handle to memory-mapped assets
-
char fs_letter
Type Definitions
-
typedef void *esp_lv_fs_handle_t
Filesystem handle type definition.