Spurious memory issues using gradients


I have two graphics where I have used gradients - I am getting suspected memory issues
when the underlying gradient graphics are either being drawn or been drawn.

The screen locks up when this happens.

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

Processor is STM32H743

What LVGL version are you using?

V8.1.1 (I cant upgrade to a later version as this is on a existing product, this is a minor update project)

What do you want to achieve?

I would like to find out what is going on so I can make the gradients work

What have you tried so far?

Debugging using Crossworks compiler for ST

Code to reproduce

I do have the code running in a visual studio simulator, but it works with no issue,

The code block(s) should be formatted like:

This is the code for the first graphic, its a roller widget with a gradient

This declaration is static  lv_obj_t* TemperatureSelectRoller = lv_roller_create(ParentTemperatureContainer);
lv_obj_set_size(TemperatureSelectRoller, 220, 220);
    lv_obj_set_pos(TemperatureSelectRoller, (CONTAINER_WIDTH / 2) - 110, (CONTAINER_HEIGHT / 2) - 110);
    lv_obj_set_style_text_font(TemperatureSelectRoller, font_large_temp, LV_PART_SELECTED);
    lv_obj_set_style_text_align(TemperatureSelectRoller, LV_TEXT_ALIGN_CENTER, LV_PART_SELECTED);
    lv_obj_set_style_text_font(TemperatureSelectRoller, font_title, 0);
    lv_roller_set_options(TemperatureSelectRoller, TargetTemperatureSelectOptions, LV_ROLLER_MODE_NORMAL);
    lv_roller_set_visible_row_count(TemperatureSelectRoller, 4);
    lv_obj_set_style_bg_color(TemperatureSelectRoller, lv_color_hex(COLOUR_WARM), 0);
    lv_obj_set_style_bg_color(TemperatureSelectRoller, lv_color_hex(ROLLER_BAR_CENTRE_COLOUR), LV_PART_SELECTED);
    lv_obj_set_style_border_color(TemperatureSelectRoller, lv_color_hex(SETTINGS_BTN_COLOUR), 0);
    lv_obj_set_style_bg_opa(TemperatureSelectRoller, LV_OPA_COVER, 0);
    lv_obj_set_style_bg_opa(TemperatureSelectRoller, LV_OPA_80, LV_PART_SELECTED);
    lv_obj_set_style_bg_grad_color(TemperatureSelectRoller, lv_color_hex(COLOUR_COLD), 0);
    lv_obj_set_style_bg_grad_dir(TemperatureSelectRoller, LV_GRAD_DIR_VER, 0);
    lv_obj_set_style_radius(TemperatureSelectRoller, LV_RADIUS_CIRCLE, 0);
    lv_obj_set_style_radius(TemperatureSelectRoller, 20, LV_PART_SELECTED);
    lv_roller_set_selected(TemperatureSelectRoller, 10, LV_ANIM_ON); 

The second graphic is:-

PowerLevelSelect.slider is a static declaration

        lv_obj_set_pos(PowerLevelSelect.slider, 86, 16);
        lv_obj_set_size(PowerLevelSelect.slider, 740, 24);
        lv_obj_set_style_bg_color(PowerLevelSelect.slider, lv_color_hex(0xACABED), 0);
        lv_obj_set_style_bg_color(PowerLevelSelect.slider, lv_color_hex(0xFFFFFF), LV_PART_KNOB);
        lv_obj_set_style_bg_opa(PowerLevelSelect.slider, LV_OPA_TRANSP, LV_PART_INDICATOR);
        lv_obj_set_style_bg_opa(PowerLevelSelect.slider, LV_OPA_COVER, 0);
        lv_obj_set_style_bg_grad_color(PowerLevelSelect.slider, lv_color_hex(0x3B24C6), 0);
        lv_obj_set_style_radius(PowerLevelSelect.slider, 16, 0);
        lv_obj_set_style_bg_grad_dir(PowerLevelSelect.slider, LV_GRAD_DIR_HOR, 0);

Screenshot and/or video

When the second gradient graphic has been drawn,
the below images are where the software is hanging up,

These were two different runs… both hang in similar but different places

Hmm, really hard to help, as we just look through a very small peephole.
The real cause of your problem can be located anywhere. Not necessarily located within the code you posted.


Thank you for the reply, is there anything that would help to find the problem.
I can go through the call stack.

I would guess that there is some uncontrolled writing to the memory, so the memory got corrupted.
That is what we see with the integrity_walker failing.

But how to find you the location where this happens?
Do you use FreeRTOS or anything equivalent?
Do you use lvgl from different tasks, or call lvgl functions from interrupts?
Do you use string functions (with inadequate buffersizes)
Any pointer operations?

You can use the macro LV_ASSERT_MEM_INTEGRITY(); when entering your functions and when leaving your functions, to see until when the the assertion fails.

Thank you for the reply,

I am using FreeRTOS, LVGL is all run from one task, and no calls from interrupts,

I will double check the string buffer, that is an easy one to catch me out,

As I am working on an embedded project, I have opted to use static data for all the objects, very deterministic and worked well for everything else.

I’ll see what I can find with MEM intergrity call too.