fix(i80_controller): fix example crash when using filesystem

- Replace SPIFFS with LittleFS as the preferred
  NOR flash file system
- Expand the Image Resource section in README with
  detailed file system documentation
- Add pytest_i80_controller_lvgl.py to test both
  image_in_bin and image_in_fs configurations
- Increase LVGL task stack size from 4KB to 8KB to
  prevent stack overflow when loading images from FS
- Add CONFIG_LV_USE_CLIB_MALLOC to sdkconfig.defaults

Made-with: Cursor
This commit is contained in:
Chen Jichang
2026-04-21 15:44:27 +08:00
parent 0bed60db48
commit 63fa597efb
13 changed files with 113 additions and 68 deletions
@@ -4,10 +4,9 @@ if(CONFIG_EXAMPLE_LCD_IMAGE_FROM_EMBEDDED_BINARY)
endif()
idf_component_register(SRCS "i80_controller_example_main.c" "lvgl_demo_ui.c" ${embedded_images}
PRIV_REQUIRES esp_lcd spiffs esp_psram
PRIV_REQUIRES esp_lcd esp_psram
INCLUDE_DIRS ".")
if(CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM)
# Create a partition to store the image resources in the filesystem
spiffs_create_partition_image(storage ./images/filesystem FLASH_IN_PROJECT)
littlefs_create_partition_image(storage ./images/filesystem FLASH_IN_PROJECT)
endif()
@@ -3,7 +3,7 @@ menu "Example Configuration"
config EXAMPLE_LCD_I80_COLOR_IN_PSRAM
bool "Allocate color data from PSRAM"
depends on SOC_PSRAM_DMA_CAPABLE
default y
default n
help
Enable this option if you want to allocate the LVGL draw buffer from PSRAM.
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/
@@ -16,7 +16,7 @@
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "esp_spiffs.h"
#include "esp_littlefs.h"
#include "driver/gpio.h"
#include "lvgl.h"
@@ -71,7 +71,7 @@ static const char *TAG = "example";
#define EXAMPLE_LVGL_TICK_PERIOD_MS 2
#define EXAMPLE_LVGL_TASK_MAX_DELAY_MS 500
#define EXAMPLE_LVGL_TASK_MIN_DELAY_MS 1000 / CONFIG_FREERTOS_HZ
#define EXAMPLE_LVGL_TASK_STACK_SIZE (4 * 1024)
#define EXAMPLE_LVGL_TASK_STACK_SIZE (8 * 1024)
#define EXAMPLE_LVGL_TASK_PRIORITY 2
#define EXAMPLE_LVGL_DRAW_BUF_LINES 100
@@ -129,33 +129,31 @@ static void example_lvgl_port_task(void *arg)
void example_init_filesystem(void)
{
ESP_LOGI(TAG, "Initializing filesystem");
esp_vfs_spiffs_conf_t conf = {
.base_path = "/spiffs",
esp_vfs_littlefs_conf_t conf = {
.base_path = "/littlefs",
.partition_label = "storage",
.max_files = 5,
.format_if_mount_failed = true
.format_if_mount_failed = true,
.dont_mount = false,
};
// Use settings defined above to initialize and mount SPIFFS filesystem.
// Note: esp_vfs_spiffs_register is an all-in-one convenience function.
esp_err_t ret = esp_vfs_spiffs_register(&conf);
esp_err_t ret = esp_vfs_littlefs_register(&conf);
if (ret != ESP_OK) {
if (ret == ESP_FAIL) {
ESP_LOGE(TAG, "Failed to mount or format filesystem");
} else if (ret == ESP_ERR_NOT_FOUND) {
ESP_LOGE(TAG, "Failed to find SPIFFS partition");
ESP_LOGE(TAG, "Failed to find LittleFS partition");
} else {
ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
ESP_LOGE(TAG, "Failed to initialize LittleFS (%s)", esp_err_to_name(ret));
}
return;
}
size_t total = 0, used = 0;
ret = esp_spiffs_info(conf.partition_label, &total, &used);
ret = esp_littlefs_info(conf.partition_label, &total, &used);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s). Formatting...", esp_err_to_name(ret));
esp_spiffs_format(conf.partition_label);
ESP_LOGE(TAG, "Failed to get LittleFS partition information (%s). Formatting...", esp_err_to_name(ret));
esp_littlefs_format(conf.partition_label);
return;
} else {
ESP_LOGI(TAG, "Partition size: total: %zu, used: %zu", total, used);
@@ -1,2 +1,3 @@
dependencies:
lvgl/lvgl: "9.2.2"
joltwallet/littlefs: "~=1.20.0"
@@ -59,7 +59,7 @@ static void anim_timer_cb(lv_timer_t *timer)
// Create new image and make it transparent
img_text = lv_image_create(scr);
#if CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM
lv_image_set_src(img_text, "S:/spiffs/esp_text.png");
lv_image_set_src(img_text, "S:/littlefs/esp_text.png");
#elif CONFIG_EXAMPLE_LCD_IMAGE_FROM_EMBEDDED_BINARY
lv_image_set_src(img_text, &esp_text);
#endif
@@ -123,7 +123,7 @@ void example_lvgl_demo_ui(lv_disp_t *disp)
// Create image
img_logo = lv_image_create(scr);
#if CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM
lv_image_set_src(img_logo, "S:/spiffs/esp_logo.png");
lv_image_set_src(img_logo, "S:/littlefs/esp_logo.png");
#elif CONFIG_EXAMPLE_LCD_IMAGE_FROM_EMBEDDED_BINARY
lv_image_set_src(img_logo, &esp_logo);
#endif