Porting STM32 - doesnt draw the whole screen after updating to lvgl 8.2

Description

Hi everyone,
I’ve recently updated LVGL and can’t get it to work correctly.
If I run an animation the screen seems to update in some cases if the animation is moving to that particular place. Please see the pic.

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

STM32H7A3 Nucleo board and ILI9341

What do you want to achieve?

What have you tried so far?

I’ve tried changing the buffer size, trying full refresh, one buffer, two buffers, memory allocation, DMA and SPI settings.

Code to reproduce

void tft_init(void)
{
    /*-------------------------
     * Initialize your display
     * -----------------------*/
    disp_init();

    #define buffer_size DISP_HOR_RES * 10

    static lv_disp_draw_buf_t disp_buf_1;
    static lv_color_t buf1_1[buffer_size];                        /*A buffer for 10 rows*/
    static lv_color_t buf1_2[buffer_size];                        /*An other buffer for 10 rows*/
    lv_disp_draw_buf_init(&disp_buf_1, buf1_1, buf1_2, buffer_size);   /*Initialize the display buffer*/

    
    lv_disp_drv_init(&disp_drv);                    /*Basic initialization*/

    /*Set up the functions to access to your display*/
	disp_drv.sw_rotate = 0;

	disp_drv.rotated = Disp.rotation;

    /*Used to copy the buffer's content to the display*/
    disp_drv.flush_cb = disp_flush;

    /*Set a display buffer*/
    disp_drv.draw_buf = &disp_buf_1;

   // disp_drv.full_refresh = 1;

    /*Finally register the driver*/
    lv_disp_drv_register(&disp_drv);

    
    	disp_drv.hor_res = DISP_HOR_RES;
    	disp_drv.ver_res = DISP_VER_RES;

}
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{

#if SPI_DMA
    /*SPI transmit data with DMA*/
	ILI9341_Send_Data_DMA(area->x1, area->y1, area->x2, area->y2, (uint8_t *)color_p);
#else
    /*SPI transmit data without DMA*/
    ILI9341_Send_Data(area->x1, area->y1, area->x2, area->y2, (uint8_t *)color_p);
    lv_disp_flush_ready(disp_drv);
#endif
}
#if SPI_DMA
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
{
	lv_disp_flush_ready(&disp_drv);
    ILI9341_Deselect();
   
}
static void ILI9341_SPI_Send_DMA(uint8_t *data, uint16_t size)
{
#if Using_LVGL
	#if CS_ENABLE
    ILI9341_Select();
    HAL_SPI_Transmit(&ILI9341_SPI_PORT, data, size, 1000);
    ILI9341_Deselect();
	#else
    HAL_SPI_Transmit(&ILI9341_SPI_PORT, data, size, 1000); //Library functions will not use DMA if LVGL is being used
#endif
#else
#if CS_ENABLE
    ILI9341_Select();
    HAL_SPI_Transmit_DMA(&ILI9341_SPI_PORT, data, size);
    ILI9341_SPI_WAIT_DMA();
    ILI9341_Deselect();
#else
    HAL_SPI_Transmit_DMA(&ILI9341_SPI_PORT, data, size);
    ILI9341_SPI_WAIT_DMA();
#endif
#endif
}
static void ILI9341_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
{
    uint8_t bufx[4]={(x1+Disp.xstart) >> 8, (x1+Disp.xstart) & 0xFF, (x2+Disp.xstart) >> 8, (x2+Disp.xstart) & 0xFF};
	ILI9341_Write_Cmd(ILI9341_COLUMN_ADDR);
    ILI9341_Write_Data(bufx, 4);

    uint8_t bufy[4] = {(y1+Disp.ystart) >> 8, (y1+Disp.ystart) & 0xFF, (y2+Disp.ystart) >> 8, (y2+Disp.ystart) & 0xFF};
    ILI9341_Write_Cmd(ILI9341_PAGE_ADDR);
    ILI9341_Write_Data(bufy, 4);

    ILI9341_Write_Cmd(ILI9341_GRAM);
}
void ILI9341_Init(uint8_t rotation) {

	uint8_t madctl=0;
	uint8_t data[15];

	UNUSED(madctl);
	UNUSED(Disp);

	ILI9341_DisplayOff();
    ILI9341_Reset();

    //TURN OFF DISPLAY
	ILI9341_Write_Cmd(0x28);

	Disp.rotation = rotation;
	switch(Disp.rotation)
	{
		case DISP_ROT_Portrait:
			Disp.width = ILI9341_Width;
			Disp.height = ILI9341_Height;
			Disp.xstart = 0;
			Disp.ystart = 0;
			madctl = 0x40|0x08;
			break;
		case DISP_ROT_Landscape:
			Disp.width = ILI9341_Height;
			Disp.height = ILI9341_Width;
			Disp.xstart = 0;
			Disp.ystart = 0;
			madctl = 0x20|0x08;
			break;
		case DISP_ROT_Inv_Portrait:
			Disp.width = ILI9341_Width;
			Disp.height = ILI9341_Height;
			Disp.xstart = 0;
			Disp.ystart = 0;
			madctl = 0x80|0x08;
			break;
		case DISP_ROT_Inv_Landscape:
			Disp.width = ILI9341_Height;
			Disp.height = ILI9341_Width;
			Disp.xstart = 0;
			Disp.ystart = 0;
			madctl = 0x40|0x80|0x20|0x08;

			break;
		default:
			//EXIT IF SCREEN ROTATION NOT VALID!
			madctl = 0x48;
			break;
	}
void ILI9341_Send_Data_DMA(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint8_t *p)
{
    ILI9341_Address_Set(x_start, y_start, x_end, y_end);
#if CS_ENABLE
    ILI9341_Select();
    ILI9341_SPI_WAIT_DMA();
    HAL_SPI_Transmit_DMA(&ILI9341_SPI_PORT, (uint8_t *)p, (x_end - x_start + 1) * (y_end - y_start + 1) * 2);
    //ILI9341_SPI_WAIT_DMA();

#else
    HAL_SPI_Transmit_DMA(&ILI9341_SPI_PORT, (uint8_t *)p, (x_end - x_start + 1) * (y_end - y_start + 1) * 2);
#endif

}
/**
 *  Fills LCD screen with a color
 *
 * @param   color
 *
 * @return  void
 */

void ILI9341_Fill_Color(uint16_t color)
{
	uint32_t total_bytes, sent_bytes=0;
	uint16_t i, remain_bytes;
	uint8_t Buffer[65534]; 				//max DMA transfer size is 65535 bytes, but 65535 is not divided by 2 and a uint16_t has 2 bytes.
	uint8_t data[2] = {0};

	total_bytes = (uint32_t) ILI9341_Size*2;

	ILI9341_Address_Set(0, 0, Disp.width - 1, Disp.height - 1);

    data[0] = color >> 8;
    data[1] = color;

	for(i = 0; i < 32762; i++)
	{
		Buffer[(i*2)] =  data[0];
		Buffer[(i*2)+1] =  data[1];
	}

    for(i=0; i < total_bytes/65534; i++){
    	ILI9341_SPI_Send_DMA(Buffer, 65534);
    	sent_bytes+=65534;
    }

    remain_bytes = (uint32_t)total_bytes - sent_bytes;
    ILI9341_SPI_Send_DMA(Buffer, remain_bytes);
}


/**
 *  Fills LCD area with a color
 *
 * @param   x_start,y_start
 * @param   x_end,y_end
 * @param   color
 *
 * @return  void
 */

void ILI9341_Fill_Area_Color(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint16_t color)
{
	uint32_t total_bytes, sent_bytes=0;
	uint16_t i, remain_bytes;
	uint8_t Buffer[65534]; 				//max DMA transfer size is 65535 bytes, but 65535 is not divided by 2 and a uint16_t has 2 bytes.


    total_bytes = (x_end - x_start + 1) * (y_end - y_start + 1) * 2;

    ILI9341_Address_Set(x_start, y_start, x_end, y_end);

    if(total_bytes>65534){
        for(i = 0; i < 65534 / 2; i++)
        {
        	Buffer[2 * i] = color >> 8;
        	Buffer[2 * i + 1] = color;
        }

        for(i=0; i < total_bytes/65534; i++){
        	ILI9341_SPI_Send_DMA(Buffer, 65534);
        	sent_bytes+=65534;
        }

        remain_bytes = (uint32_t)total_bytes - sent_bytes;
        ILI9341_SPI_Send_DMA(Buffer, remain_bytes);
    }else{

    	for(i = 0; i < total_bytes / 2; i++)
        {
        	Buffer[2 * i] = color >> 8;
        	Buffer[2 * i + 1] = color;
        }
        ILI9341_SPI_Send_DMA(Buffer, total_bytes);
    }

}

Screenshot and/or video

I solved it. The problem was that I registered the driver before specifying the resolution.
It should be like this:

    /*Set a display buffer*/
    disp_drv.draw_buf = &disp_buf_1;


    	disp_drv.hor_res = DISP_HOR_RES;
    	disp_drv.ver_res = DISP_VER_RES;


    /*Finally register the driver*/
    lv_disp_drv_register(&disp_drv);