How do I manage memory on ESP32?

Description

I’m trying to use littlevgl to read an image from SDcard and display it on an ILI9341. No matter what I do, I run into memory problems.

What MCU/Processor/Board and compiler are you using?

  • ESP32, TTGO-T1, chip is of type ESP32D0WDQ6 (revision 1), having 4M of memory
  • The TTGO has an on board SD card reader, connected to HSPI
  • ILI9341 (320x240) is connected to VSPI (changed menuconfig, but also some lines in disp_spi_init to replace HSPI by VSPI and prevent a DMA channel conflict with the SD card (would be nice to add this to menuconfig too!)
  • Using latest version of ESP-IDF
  • Using latest version of littlevgl (esp32_ili9341) installed as ‘externals’ under my project
  • Using CMake
  • Both the screen and the SD card work well individually
  • Images were converted to .bin using the online tool and stored at the SD card

What do you want to achieve?

I want to load a full screen .bin image and display it on the screen, and I want to learn how to solve memory problems in a more generic way. I can’t find a clear overview of the memory on the espressif site, what the capabilities are, and how to use it.

What have you tried so far?

  • I have tried to change flash memory between 1M, 2M and 4M in menuconfig
  • I have changed LV_MEM_SIZE in lv_conf.h (currently at 100U * 1024U)
  • Tried different levels of LV_LOG_LEVEL (currently at LV_LOG_LEVEL_INFO)

Code to reproduce

Maybe there is something wrong with the code too. I’m a newbe.

    lv_coord_t hres = lv_disp_get_hor_res(NULL);
    lv_coord_t vres = lv_disp_get_ver_res(NULL);

    wp = lv_img_create(lv_disp_get_scr_act(NULL), NULL);

    lv_obj_set_protect(wp, LV_PROTECT_PARENT);          
    lv_obj_set_size(wp, hres, vres);
    lv_obj_set_pos(wp, 0, 0);
    lv_img_set_src(wp, "/sdcard/image2.bin");
    lv_obj_set_hidden(wp, false);
    lv_img_set_style(wp, LV_IMG_STYLE_MAIN, &style_wp);
    lv_img_set_auto_size(wp, false);

PS

It is really a great framework. I really appreciate the elegance and all the hard work that was put into it. But I still need to learn a lot.

You’ll need to explain what “memory problems” are. Does it run out of heap space? Is it not working?

You need to add a File system interface to tell LittlevGL how to read data from SD card.

You can get some inspiration from this repo.

Please let us know if you made it work There were a lot questions related to ESP file system and it’d be great to add it to the lv_fs_if repo.