Skip to content

Possible Cache Decoherence Issue #2

@johanderson

Description

@johanderson

Problem Summary

When trying to either:

I have noticed that sometimes the text is rendered as garbled text such as:
Image

Reproduction steps:

Comment out the line

lv_demo_benchmark();

Replace with example Bar code: https://docs.lvgl.io/master/details/widgets/bar.html#styling-a-bar

contains surrounding context:

  /* USER CODE BEGIN 2 */

  lvgl_port_init();

  static lv_style_t style_bg;
  static lv_style_t style_indic;

  lv_style_init(&style_bg);
  lv_style_set_border_color(&style_bg, lv_palette_main(LV_PALETTE_BLUE));
  lv_style_set_border_width(&style_bg, 2);
  lv_style_set_pad_all(&style_bg, 6); /*To make the indicator smaller*/
  lv_style_set_radius(&style_bg, 6);
  lv_style_set_anim_duration(&style_bg, 1000);

  lv_style_init(&style_indic);
  lv_style_set_bg_opa(&style_indic, LV_OPA_COVER);
  lv_style_set_bg_color(&style_indic, lv_palette_main(LV_PALETTE_BLUE));
  lv_style_set_radius(&style_indic, 3);

  lv_obj_t * bar = lv_bar_create(lv_screen_active());
  lv_obj_remove_style_all(bar);  /*To have a clean start*/
  lv_obj_add_style(bar, &style_bg, 0);
  lv_obj_add_style(bar, &style_indic, LV_PART_INDICATOR);

  lv_obj_set_size(bar, 200, 20);
  lv_obj_center(bar);
  lv_bar_set_value(bar, 100, LV_ANIM_ON);

  //lv_demo_benchmark();

Solution discussion

I have isolated the problem down to when

MX_DCACHE2_Init();

this line is commented out, disabling the use of DCACHE2, the text garbling goes away. Note that DACHE1 is coupled with the CPU while DCACHE2 is coupled with the DMA2D.

Image

This makes me think that there may be a cache decoherence problem that is occurring between DCACHE1, SRAM and DCACHE2. I am wondering if you have run into this problem before. What is interesting is that the demo as is seems to work just fine, but I only run into issues when I begin modifying this project.

In order to make use of the DCACHE2's performance increase, I am wondering if we have to add a strategy to managing the caches such as:

Image

However I am not sure where would be the most appropriate or best lvgl practiced place to put this.

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