Need help getting rid of flickering on display

Hi!

I am migrating my project from TouchGFX to LVGL for a custom STM32 board.

I got things up-and-running but there are some flickering for the first 5-10 rows on the display, rest of the display is fine and the updating of a counter label works fine. I know for sure there is no problem with the hardware since it is tested and works fine with TouchGFX.

I suspect there might be something wrong with the setup of the display buffer and the callback function, here is the code:

#define DISPLAY_WIDTH 1024
#define DISPLAY_HEIGHT 600

static lv_color_t displayBuf1[DISPLAY_WIDTH * DISPLAY_HEIGHT];

void set_pixel(uint32_t x, uint32_t y, lv_color_t color)
{
  // Ensure we are within the buffer bounds
  if (x < DISPLAY_WIDTH && y < DISPLAY_HEIGHT)
  {
    // Calculate the index for the pixel, each pixel is 3 bytes (RGB)
    uint32_t index = y * DISPLAY_WIDTH + x;

    // Set the pixel color in the buffer
    displayBuf1[index] = color;
  }
}

void my_flush_cb(lv_display_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
  //  Yes it is a slow and simple implementation.
  for (int32_t y = area->y1; y <= area->y2; y++)
  {
    for (int32_t x = area->x1; x <= area->x2; x++)
    {
      set_pixel(x, y, *color_p);
      color_p++;
    }
  }

And this code goes in the Main()

  lv_init();

  // Create a display
  // Basic initialization with horizontal and vertical resolution in pixels
  lv_display_t *disp = lv_display_create(DISPLAY_WIDTH, DISPLAY_HEIGHT);

  // Set a flush callback to draw to the display
  lv_display_set_flush_cb(disp, (void *)my_flush_cb);

  //Initialize the buffer(s). With only one buffer use NULL instead buf_2 
  lv_display_set_buffers(disp, displayBuf1, NULL, sizeof(displayBuf1), LV_DISPLAY_RENDER_MODE_PARTIAL);

I am using only one single buffer for the whole of the display (1024 x 600 RGB888) since there is not enough memory on the hardware to use two.

Any ideas how I can get rid of the flickering?

Thanks in advance