Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 SPIFFS #6325

Closed
gauix4 opened this issue Jun 2, 2024 · 11 comments
Closed

ESP32 SPIFFS #6325

gauix4 opened this issue Jun 2, 2024 · 11 comments

Comments

@gauix4
Copy link

gauix4 commented Jun 2, 2024

Introduce the problem

No documentation or example for using SPIFFS on ESP32 S3

Proposal

it would be nice to make an example of the use of SPIFFS on ESP32 S3 many people can't do this and there is no documentation on this subject
I can't either
thanks in advance :)

@becseya
Copy link
Contributor

becseya commented Jun 4, 2024

SPIFF is compatible with POSIX which is supported in LVGL. But I see value adding an explicit example. What do you think? @kisvegabor

@gauix4 What would be the use-case? Do you want to store images in the internal flash?

@gauix4
Copy link
Author

gauix4 commented Jun 4, 2024

@becseya
Yes, this would be to store images but not in JPEG but rather in binary lvgl or compressed binary, this is much more interesting because the volume is much smaller than JPEG.

Thank you very much for answering anyway ! :)

@kisvegabor
Copy link
Member

It was already asked by many people how to use LVGL's File System on ESP. So an example and a more detailed docs would be really nice.

@gauix4
Copy link
Author

gauix4 commented Jun 12, 2024

@kisvegabor hoo yess
I would also like to use it

@kisvegabor
Copy link
Member

See #6367 🙂

@kisvegabor
Copy link
Member

If it's not working by following the instruction in #6367 please comment in the Pull request.

@gauix4
Copy link
Author

gauix4 commented Sep 16, 2024

Capture d’écran 2024-09-16 à 02 46 30

Well I'm coming back to you because I'm starting to go crazy because I can't find any documentation or examples, nothing on Google after spending days searching. I'm not the type to ask for something but this is really getting on my nerves and I'm fed up!

So I'm explaining the problem so that you can understand that we are on the same wavelength.
like 99% of people i use squareline studio. The problem when you have a big project is that you can't use simple images or export source code as an image.
if we still want to use the spiffs knowing that there can be a lot of space we must therefore use the compressed binary format.

now the big problem I encounter is that I put my compressed binary files in the spiffs memory for the rest it's total nothingness.

Capture d’écran 2024-09-16 à 02 54 36

I looked in the config files I tried several configs but nothing more there is not an extremely simple example to understand how this code works.

lv_config.h

/** Decode bin images to RAM */
#define LV_BIN_DECODER_RAM_LOAD 1

/** Setting a default driver letter allows skipping the driver prefix in filepaths. */
#define LV_FS_DEFAULT_DRIVE_LETTER 'A'

/** API for fopen, fread, etc. */
#define LV_USE_FS_STDIO 1
#if LV_USE_FS_STDIO
    #define LV_FS_STDIO_LETTER 'A'     /**< Set an upper cased letter on which the drive will accessible (e.g. 'A') */
    #define LV_FS_STDIO_PATH "/"         /**< Set the working directory. File/directory paths will be appended to it. */
    #define LV_FS_STDIO_CACHE_SIZE 4096   /**< >0 to cache this number of bytes in lv_fs_read() */
#endif

it's really and only the implementation of the spiffs memory and its management that I don't understand at all everything the rest no problem but for that I can't find any documentation how to use the spif memory the names to use and which formats are supported

@jgauchia
Copy link
Contributor

jgauchia commented Sep 16, 2024

Hi @gauix4

I'm using binary images and SPIFFS in my project since LVGL 8.3. (icons and small images)

My programming skills are limited but maybe these steps can help you:

  • Check partitions of your board, I suposed that you have a SPIFFS partition with available space

  • Create a folder in your project called data and put bin files on it

help

  • Upload data to ESP32 file system
    (This metod or pio run --target uploadfs)

help

  • lv_conf.h (using POSIX)
/** Setting a default driver letter allows skipping the driver prefix in filepaths. */
#define LV_FS_DEFAULT_DRIVE_LETTER 'F'

/** API for fopen, fread, etc. */
#define LV_USE_FS_STDIO 0
#if LV_USE_FS_STDIO
    #define LV_FS_STDIO_LETTER '\0'     /**< Set an upper cased letter on which the drive will accessible (e.g. 'A') */
    #define LV_FS_STDIO_PATH ""         /**< Set the working directory. File/directory paths will be appended to it. */
    #define LV_FS_STDIO_CACHE_SIZE 0    /**< >0 to cache this number of bytes in lv_fs_read() */
#endif

/** API for open, read, etc. */
#define LV_USE_FS_POSIX 1
#if LV_USE_FS_POSIX
    #define LV_FS_POSIX_LETTER 'F'     /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
    #define LV_FS_POSIX_PATH "/spiffs"         /*Set the working directory. File/directory paths will be appended to it.*/
    #define LV_FS_POSIX_CACHE_SIZE 0    /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
  • Init SPIFFS
  esp_vfs_spiffs_conf_t conf = {
    .base_path = "/spiffs",
    .partition_label = NULL,
    .max_files = 5,
    .format_if_mount_failed = false
  };

  esp_err_t ret = esp_vfs_spiffs_register(&conf);

  if (ret !=ESP_OK)
  {
    if (ret == ESP_FAIL)
      log_e("Failed to mount or format filesystem");
    else if (ret == ESP_ERR_NOT_FOUND)
      log_e("Failed to find SPIFFS partition");
    else
      log_e("Failed to initialize SPIFFS (%s)",esp_err_to_name(ret));
    return ESP_FAIL;
  }

  size_t total = 0, used = 0;
  ret = esp_spiffs_info(NULL, &total, &used);
  if (ret!= ESP_OK)
    log_e("Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
  else
    log_i("Partition size: total: %d used: %d", total, used);
  
  return ESP_OK;
  • Use your bin file in LVGL (example)
lv_obj_t *altitImg = lv_img_create(lv_scr_act());
lv_img_set_src(altitImg, "/altit.bin");

I don't know how squareline studio works, but maybe it doesn't create bin files (seems it's creating a C file ¿?), I'm using LVGL image converter python script in order to create bin file

(Sorry @kisvegabor if I answer this closed Issue)

@gauix4
Copy link
Author

gauix4 commented Sep 16, 2024

Thank you for your help ! Yes of course I put the binary files in data there is no problem with all that the only problem as I say is really the implementation of the code and the options nothing works! zero documentation nothing and rereading the code is a monumental mess!

Capture d’écran 2024-09-16 à 17 07 46

where did you find the minimum documentation to know how to make this library work because frankly I find absolutely nothing and when I find something; since I don't speak English it's only technical words and it doesn't translate them and I don't understand anything frankly the developers really didn't make any effort to detail the functionalities I think they are too caught up in their work and forget that other people will reread the code but given the name of the variables it is very complicated especially when you don't speak English at all

Capture d’écran 2024-09-16 à 18 14 39

So I made something simple but nothing works, only the text works, so my screen is set up correctly but nothing for the images from SPIFFS
impossible to find an example on the internet

@gauix4
Copy link
Author

gauix4 commented Sep 17, 2024

@kisvegabor @kisvegabor

I still haven't seen any documentation or examples, it's still a pain, I've been on it for several days and I've been testing things, I still haven't made any progress except being even more annoyed at not finding anything and seeing a lot of people looking too.
sorry if I bet ungrateful that's not the goal it's just that there I'm fed up of not moving forward spending hours to go nowhere each time I think I find something in the end it's absolutely not that I try to reread the code to do tests but nothing conclusive at all

@gauix4
Copy link
Author

gauix4 commented Sep 17, 2024

Capture d’écran 2024-09-17 à 04 13 45

458484493_386962824452389_5389570496780490856_n

Capture d’écran 2024-09-17 à 04 44 48 Capture d’écran 2024-09-17 à 04 45 40 Capture d’écran 2024-09-17 à 04 47 21 Capture d’écran 2024-09-17 à 04 46 48

I am also unable to activate PNG decoding, it always asks me for a library which cannot be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants