ESP-IDF and SPIFFS

My device is a WT32-SC01 Plus and I wanted to use LVGL with ESP-IDF (no Arduino Core) to show images, which I downloaded from my server. So the images aren’t as C files. The files should be stored in flash within the spiffs partition.

My code is as following

static auto *image = lv_image_create(lv_scr_act());
lv_image_set_src(image, "S:image.png");
lv_obj_align(image, LV_ALIGN_TOP_LEFT, 0, 0);

I used the lv_conf.h for the setup

#define LV_USE_FS_POSIX 1
 #if LV_USE_FS_POSIX
    #define LV_FS_POSIX_LETTER 'S' 
    #define LV_FS_POSIX_PATH ""
    #define LV_FS_POSIX_CACHE_SIZE 0
#endif

To test my setup, I created an image and bundled it within the binary

spiffs_create_partition_image(storage ../storage FLASH_IN_PROJECT)

But I always see in the log an error message

W (1695) LVGL: [Warn] lv_image_set_src: failed to get image info: S:image.png lv_image.c:189

Now I’m not sure, if my file is in the storage.bin or if lvgl just has an failure while reading.

SPIFFS doesn’t use POSIX file functions to access the files. You would need to write your own custom driver.

If you use fatfs which is also built into the ESP-IDF then you can use POSIX functions to access the files.

https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/storage/fatfs.html

using SPIFFS is a really bad idea and you can read about why it is not a good idea in the link below.

https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/storage/spiffs.html#notes

Where can I find the documentation for a custom driver? I want to go this route.

I know spiffs wouldn‘t be good, but it was my first idea.

Here is the API documentation…

https://docs.lvgl.io/9.2/API/misc/lv_fs.html#

and here is a little bit more information…

https://docs.lvgl.io/9.2/libs/fs.html

1 Like

https://docs.lvgl.io/9.2/integration/chip/espressif.html#using-the-file-system-under-esp-idf

1 Like