Skip to content

LVGL on GIGA seems to be running out of memory - lvgl sketch doesnt fit. #142

Open
@mjs513

Description

@mjs513

@facchinm - @pillo79 - @KurtE

We modified our gigadisplay library to include the LVGL 9.3.0 code from the Arduino_H7_library, i.e., code wrapped in #if __has_include("lvgl.h"). It now compiles the grid example:

#if __MBED__
#include "Arduino_H7_Video.h"
#include "lvgl.h"
#include "Arduino_GigaDisplayTouch.h"

Arduino_H7_Video Display(800, 480, GigaDisplayShield);
Arduino_GigaDisplayTouch TouchDetector;
#elif __ZEPHYR__
#include "lvgl.h"
#include "Arduino_GigaDisplay.h"

Display Display(800, 480);
#endif

void setup() {
  delay(3000);
  Display.begin();

  //Display & Grid Setup
  lv_obj_t* screen = lv_obj_create(lv_scr_act());
  lv_obj_set_size(screen, Display.width(), Display.height());

  static lv_coord_t col_dsc[] = { 370, 370, LV_GRID_TEMPLATE_LAST };
  static lv_coord_t row_dsc[] = { 215, 215, 215, 215, LV_GRID_TEMPLATE_LAST };

  lv_obj_t* grid = lv_obj_create(lv_scr_act());
  lv_obj_set_grid_dsc_array(grid, col_dsc, row_dsc);
  lv_obj_set_size(grid, Display.width(), Display.height());

  //top left
  lv_obj_t* obj;
  obj = lv_obj_create(grid);
  lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1,  //column
                       LV_GRID_ALIGN_STRETCH, 0, 1);      //row

  //bottom left
  obj = lv_obj_create(grid);
  lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 0, 1,  //column
                       LV_GRID_ALIGN_STRETCH, 1, 1);      //row
  //top right
  obj = lv_obj_create(grid);
  lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 1, 1,  //column
                       LV_GRID_ALIGN_STRETCH, 0, 1);      //row

  //bottom right
  obj = lv_obj_create(grid);
  lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, 1, 1,  //column
                       LV_GRID_ALIGN_STRETCH, 1, 1);      //row
}

void loop() {
  lv_timer_handler();
  delay(5);

}

However, it fails to load the sketch with the following error:

uart:~$ sketch
[00:00:07.672,000] <err> llext: Failed allocating 499264 bytes 4-aligned for region 0
[00:00:07.680,000] <err> llext: Failed to copy regions, ret -12
Failed to load sketch, rc -12

so at this point not sure what can be done.

To run the sketch you will need the library: https://github.com/mjs513/Arduino_GigaDisplay/tree/Arduino_GigaDisplay_Zephyr

Activity

KurtE

KurtE commented on Jun 20, 2025

@KurtE

@mjs513 and all.

Wondering about the memory management and usage of memory.
For example, today I am playing with the Portenta H7, with an ST77XX SPI display driver which is starting to work...

But is so limited in memory, that I can not load a single ILI9341 like font in the different examples without the sketch failing
to load with errors like:

uart:~$
*** Booting Zephyr OS build v3.7.0-16361-gcd0993ba3220 ***
[00:00:00.207,000] <err> llext: Failed allocating 131072 bytes 131072-aligned for region 2
[00:00:00.218,000] <err> llext: Failed to copy regions, ret -12
Failed to load sketch, rc -12
uart:~$

Not sure what to do about it, but would be nice if:
a) the summary of a build that may say something like:

Sketch uses 28120 bytes (3%) of program storage space. Maximum is 786432 bytes.
Global variables use 2384 bytes (0%) of dynamic memory, leaving 521240 bytes for local variables. Maximum is 523624 bytes.
Performing 1200-bps touch reset on serial port COM23

That the sizes and summary would match up, with what actually can be loaded.

b) Wondering if it is possible with Arduino/Zephyr/ST77XX - to do like we can do with a Teensy and tell certain things like
font tables to not copy it down from flash to memory, but instead access it directly from flash...

Back to playing

EDIT: Was able to get some of the font test sketch working but only with GFX fonts as they are smaller... Only one
size per file

mjs513

mjs513 commented on Jun 21, 2025

@mjs513
Author

@KurtE - @facchinm - @pillo79

Been playing a bit more and trying to debug whats going on with lvgl.

First think is that I dont understand why with MBed I can do

#include "Arduino_H7_Video.h"
#include "lvgl.h"

and it uses lvgl_config in the library folder but with Zephyr I have

#include "lvgl.h"
#include "Arduino_GigaDisplay.h"

and put lvgl_config files in the arduino libraries folder next to where lvgl is installed? Have a horrible feeling lvgl is not using sdram as memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      LVGL on GIGA seems to be running out of memory - lvgl sketch doesnt fit. · Issue #142 · arduino/ArduinoCore-zephyr