LCD Display: buffer not aligned to 16

vritzka
Posts: 33
Joined: Wed Sep 07, 2022 5:33 am

LCD Display: buffer not aligned to 16

Postby vritzka » Fri Feb 28, 2025 3:17 am

I am using the RGB LCD Example: https://github.com/espressif/esp-idf/bl ... ple_main.c.

on ESP32-S3

My display worked with previous code, but since updating to the latest example, I'm getting this error:
E (1203) gdma: gdma_link_mount_buffers(175): buffer not aligned to 16
E (1203) lcd_panel.rgb: lcd_rgb_panel_init_trans_link(955): mount DMA restart buffer failed
E (1213) lcd_panel.rgb: esp_lcd_new_rgb_panel(345): init DMA link failed
I tried various thing like changing the alignment:

Code: Select all

    
    esp_lcd_rgb_panel_config_t panel_config = {
        .sram_trans_align = 32,
        .psram_trans_align = 32,
        .
        .
        .
I also tried different buffer sizes and types.

How can I align my buffer to 16?


Here is my code:

Code: Select all

 
 
     #define EXAMPLE_LCD_PIXEL_CLOCK_HZ     (18 * 1000 * 1000)
#define EXAMPLE_LCD_H_RES              800
#define EXAMPLE_LCD_V_RES              480
#define EXAMPLE_LCD_HSYNC              1
#define EXAMPLE_LCD_HBP                40
#define EXAMPLE_LCD_HFP                20
#define EXAMPLE_LCD_VSYNC              1
#define EXAMPLE_LCD_VBP                10
#define EXAMPLE_LCD_VFP                5

#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL  1
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_PIN_NUM_BK_LIGHT       -1
#define EXAMPLE_PIN_NUM_DISP_EN        -1

#define EXAMPLE_PIN_NUM_HSYNC          CONFIG_EXAMPLE_LCD_HSYNC_GPIO
#define EXAMPLE_PIN_NUM_VSYNC          CONFIG_EXAMPLE_LCD_VSYNC_GPIO
#define EXAMPLE_PIN_NUM_DE             CONFIG_EXAMPLE_LCD_DE_GPIO
#define EXAMPLE_PIN_NUM_PCLK           CONFIG_EXAMPLE_LCD_PCLK_GPIO

#define EXAMPLE_PIN_NUM_DATA0          CONFIG_EXAMPLE_LCD_DATA0_GPIO
#define EXAMPLE_PIN_NUM_DATA1          CONFIG_EXAMPLE_LCD_DATA1_GPIO
#define EXAMPLE_PIN_NUM_DATA2          CONFIG_EXAMPLE_LCD_DATA2_GPIO
#define EXAMPLE_PIN_NUM_DATA3          CONFIG_EXAMPLE_LCD_DATA3_GPIO
#define EXAMPLE_PIN_NUM_DATA4          CONFIG_EXAMPLE_LCD_DATA4_GPIO
#define EXAMPLE_PIN_NUM_DATA5          CONFIG_EXAMPLE_LCD_DATA5_GPIO
#define EXAMPLE_PIN_NUM_DATA6          CONFIG_EXAMPLE_LCD_DATA6_GPIO
#define EXAMPLE_PIN_NUM_DATA7          CONFIG_EXAMPLE_LCD_DATA7_GPIO
#define EXAMPLE_PIN_NUM_DATA8          CONFIG_EXAMPLE_LCD_DATA8_GPIO
#define EXAMPLE_PIN_NUM_DATA9          CONFIG_EXAMPLE_LCD_DATA9_GPIO
#define EXAMPLE_PIN_NUM_DATA10         CONFIG_EXAMPLE_LCD_DATA10_GPIO
#define EXAMPLE_PIN_NUM_DATA11         CONFIG_EXAMPLE_LCD_DATA11_GPIO
#define EXAMPLE_PIN_NUM_DATA12         CONFIG_EXAMPLE_LCD_DATA12_GPIO
#define EXAMPLE_PIN_NUM_DATA13         CONFIG_EXAMPLE_LCD_DATA13_GPIO
#define EXAMPLE_PIN_NUM_DATA14         CONFIG_EXAMPLE_LCD_DATA14_GPIO
#define EXAMPLE_PIN_NUM_DATA15         CONFIG_EXAMPLE_LCD_DATA15_GPIO


#if CONFIG_EXAMPLE_USE_DOUBLE_FB
#define EXAMPLE_LCD_NUM_FB             2
#else
#define EXAMPLE_LCD_NUM_FB             1
#endif // CONFIG_EXAMPLE_USE_DOUBLE_FB

#if CONFIG_EXAMPLE_LCD_DATA_LINES_16
#define EXAMPLE_DATA_BUS_WIDTH         16
#define EXAMPLE_PIXEL_SIZE             2
#define EXAMPLE_LV_COLOR_FORMAT        LV_COLOR_FORMAT_RGB565
#elif CONFIG_EXAMPLE_LCD_DATA_LINES_24
#define EXAMPLE_DATA_BUS_WIDTH         24
#define EXAMPLE_PIXEL_SIZE             3
#define EXAMPLE_LV_COLOR_FORMAT        LV_COLOR_FORMAT_RGB888
#endif

#define EXAMPLE_LVGL_DRAW_BUF_LINES    5 // number of display lines in each draw buffer
#define EXAMPLE_LVGL_TICK_PERIOD_MS    2
#define EXAMPLE_LVGL_TASK_STACK_SIZE   (3 * 1024)
#define EXAMPLE_LVGL_TASK_PRIORITY     2
    
    
 
 
 esp_lcd_rgb_panel_config_t panel_config = {
        .sram_trans_align = 32, //added by myself
        .psram_trans_align = 32, // added by myself
        .data_width = EXAMPLE_DATA_BUS_WIDTH,
        .dma_burst_size = 16,
        .num_fbs = EXAMPLE_LCD_NUM_FB,
#if CONFIG_EXAMPLE_USE_BOUNCE_BUFFER
        .bounce_buffer_size_px = 1 * EXAMPLE_LCD_H_RES,
#endif
        .clk_src = LCD_CLK_SRC_DEFAULT,
        .disp_gpio_num = EXAMPLE_PIN_NUM_DISP_EN,
        .pclk_gpio_num = EXAMPLE_PIN_NUM_PCLK,
        .vsync_gpio_num = EXAMPLE_PIN_NUM_VSYNC,
        .hsync_gpio_num = EXAMPLE_PIN_NUM_HSYNC,
        .de_gpio_num = EXAMPLE_PIN_NUM_DE,
        .data_gpio_nums = {
            EXAMPLE_PIN_NUM_DATA0,
            EXAMPLE_PIN_NUM_DATA1,
            EXAMPLE_PIN_NUM_DATA2,
            EXAMPLE_PIN_NUM_DATA3,
            EXAMPLE_PIN_NUM_DATA4,
            EXAMPLE_PIN_NUM_DATA5,
            EXAMPLE_PIN_NUM_DATA6,
            EXAMPLE_PIN_NUM_DATA7,
            EXAMPLE_PIN_NUM_DATA8,
            EXAMPLE_PIN_NUM_DATA9,
            EXAMPLE_PIN_NUM_DATA10,
            EXAMPLE_PIN_NUM_DATA11,
            EXAMPLE_PIN_NUM_DATA12,
            EXAMPLE_PIN_NUM_DATA13,
            EXAMPLE_PIN_NUM_DATA14,
            EXAMPLE_PIN_NUM_DATA15,
        },
        .timings = {
            .pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
            .h_res = EXAMPLE_LCD_H_RES,
            .v_res = EXAMPLE_LCD_V_RES,
            .hsync_back_porch = EXAMPLE_LCD_HBP,
            .hsync_front_porch = EXAMPLE_LCD_HFP,
            .hsync_pulse_width = EXAMPLE_LCD_HSYNC,
            .vsync_back_porch = EXAMPLE_LCD_VBP,
            .vsync_front_porch = EXAMPLE_LCD_VFP,
            .vsync_pulse_width = EXAMPLE_LCD_VSYNC,
            .flags = {
                .pclk_active_neg = true,
            },
        },
        .flags.fb_in_psram = true, // allocate frame buffer in PSRAM
    };
    ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle));
    
    (...)
    
        ESP_LOGI(TAG, "Allocate LVGL draw buffers");
    // it's recommended to allocate the draw buffer from internal memory, for better performance
    size_t draw_buffer_sz = EXAMPLE_LCD_H_RES * EXAMPLE_LVGL_DRAW_BUF_LINES * EXAMPLE_PIXEL_SIZE;
    buf1 = heap_caps_malloc(draw_buffer_sz, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
    assert(buf1);
    

User avatar
ok-home
Posts: 156
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: LCD Display: buffer not aligned to 16

Postby ok-home » Fri Feb 28, 2025 6:07 am

hi
heap_caps_aligned_alloc(.....)

Sprite
Espressif staff
Espressif staff
Posts: 10596
Joined: Thu Nov 26, 2015 4:08 am

Re: LCD Display: buffer not aligned to 16

Postby Sprite » Fri Feb 28, 2025 6:28 am


My display worked with previous code, but since updating to the latest example, I'm getting this error:
Did you only update the example code, or did you also update esp-idf?

vritzka
Posts: 33
Joined: Wed Sep 07, 2022 5:33 am

Re: LCD Display: buffer not aligned to 16

Postby vritzka » Fri Feb 28, 2025 6:57 am

I also updated ESP-IDF. Its on v5.4

owenjames
Posts: 20
Joined: Fri Sep 02, 2022 6:24 pm

Re: LCD Display: buffer not aligned to 16

Postby owenjames » Tue Apr 15, 2025 10:17 am

I have the same problem after upgrading to esp-idf v5.3.3. Is there a fix for this?

MicroController
Posts: 2661
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: LCD Display: buffer not aligned to 16

Postby MicroController » Tue Apr 15, 2025 12:06 pm

I have the same problem after upgrading to esp-idf v5.3.3. Is there a fix for this?
Have you tried using heap_caps_aligned_alloc(.....)?

tonystuart
Posts: 7
Joined: Wed Mar 25, 2020 10:59 pm

Re: LCD Display: buffer not aligned to 16

Postby tonystuart » Sat May 03, 2025 10:14 pm

I encountered this problem as well.

It looks like esp_lcd_new_i80_bus in esp_lcd_panel_io_i80.c allocates a format_buffer that is not aligned to a 16-byte boundary, and later gdma_link_mount_buffers in gdma_link.c returns an error if the buffer it's passed is not on a 16-byte boundary.

Not sure what component is supposed to set the buffer_alignment field of gdma_link_list_config_t, nor what it should be set to in this case.

It's possible to work around this by changing the following line in esp_lcd_panel_io_i80.c from:

Code: Select all

bus->format_buffer = heap_caps_calloc(1, LCD_I80_IO_FORMAT_BUF_SIZE, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
to:

Code: Select all

bus->format_buffer = heap_caps_aligned_calloc(16, 1, LCD_I80_IO_FORMAT_BUF_SIZE, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
I don't have time at the moment to investigate further, and I'm not sure if that is the correct fix, or whether there is another way to achieve the desired result. Perhaps someone from Espressif can take a look?

Who is online

Users browsing this forum: Bing [Bot], GPTBot and 2 guests