Why does my heap_caps_malloc() crash?
Posted: Tue Oct 25, 2022 6:06 am
Hello,
I'm running a 7-inch Display with an ESP32-S3 and LVGL.
I can allocate my draw buffer like this and it works, but the display flickers.
So I try to use a bigger draw buffer with heap_caps_malloc() like this:
But that causes a Guru Meditation error:
Can somebody see why this crashes?
My display code looks like this:
Thanks
I'm running a 7-inch Display with an ESP32-S3 and LVGL.
I can allocate my draw buffer like this and it works, but the display flickers.
Code: Select all
// this works, but display flickers.
static lv_color_t buf1[screenWidth * 80];
static lv_color_t buf2[screenWidth * 80];
//static lv_color_t buf1[screenWidth * 100]; //buffer overrun
//static lv_color_t buf2[screenWidth * 100]; // buffer overrun
Code: Select all
void *buf1 = heap_caps_malloc(screenWidth * screenHeight, MALLOC_CAP_DMA );
void *buf2 = heap_caps_malloc(screenWidth * screenHeight , MALLOC_CAP_DMA );
Code: Select all
13:48:53.304 -> Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
13:48:53.304 ->
13:48:53.304 -> Core 1 register dump:
13:48:53.304 -> PC : 0x4204e448 PS : 0x00060430 A0 : 0x820142c9 A1 : 0x3fce26c0
13:48:53.336 -> A2 : 0x00000000 A3 : 0x00000010 A4 : 0x00000320 A5 : 0x0000031f
13:48:53.336 -> A6 : 0x00000000 A7 : 0x00000000 A8 : 0x10a310a3 A9 : 0x000010a3
13:48:53.336 -> A10 : 0x00000000 A11 : 0x0000031f A12 : 0x8037d78d A13 : 0x3fce25c0
13:48:53.368 -> A14 : 0x00060023 A15 : 0x00000003 SAR : 0x0000001f EXCCAUSE: 0x0000001d
13:48:53.368 -> EXCVADDR: 0x00000000 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000
13:48:53.368 ->
13:48:54.346 -> Backtrace:0x4204e445:0x3fce26c00x420142c6:0x3fce26e0 0x42013f8b:0x3fce2760 0x42016705:0x3fce2790 0x42017a2d:0x3fce2830 0x4204dd75:0x3fce2900 0x4200ac4b:0x3fce2920 0x4200b3bb:0x3fce29d0 0x4204d722:0x3fce2a00 0x42008a48:0x3fce2a20 0x42008bf2:0x3fce2a40 0x4200fb1d:0x3fce2a80 0x4200fbd9:0x3fce2ad0 0x4200fe46:0x3fce2b40 0x4200ff5b:0x3fce2b70 0x420109c3:0x3fce2c40 0x42022d04:0x3fce2c90 0x420022d3:0x3fce2cc0 0x4202d0f9:0x3fce2ce0
13:48:54.379 ->
13:48:54.379 ->
13:48:54.379 ->
13:48:54.379 -> ELF file SHA256: 0000000000000000
13:48:54.379 ->
13:48:54.379 -> Rebooting...
My display code looks like this:
Code: Select all
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_rgb_panel_config_t panel_config = {
.clk_src = LCD_CLK_SRC_PLL160M,
.timings = {
.pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
.h_res = screenWidth,
.v_res = screenHeight,
.hsync_pulse_width = 1,
.hsync_back_porch = 46,
.hsync_front_porch = 210,
.vsync_pulse_width = 1,
.vsync_back_porch = 23,
.vsync_front_porch = 147,
.flags{
//.hsync_idle_low = 1,
//.vsync_idle_low = 1,
.de_idle_high = 0,
.pclk_active_neg = 1,
.pclk_idle_high = 0 } },
.data_width = 16, // RGB565 in parallel mode, thus 16bit in width
.psram_trans_align = 64,
//.hsync_gpio_num = EXAMPLE_PIN_NUM_HSYNC,
//.vsync_gpio_num = EXAMPLE_PIN_NUM_VSYNC,
.de_gpio_num = EXAMPLE_PIN_NUM_DE,
.pclk_gpio_num = EXAMPLE_PIN_NUM_PCLK,
.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,
},
.disp_gpio_num = EXAMPLE_PIN_NUM_DISP_EN,
.on_frame_trans_done = example_notify_lvgl_flush_ready,
.user_ctx = &disp_drv,
.flags{ .disp_active_low = 1, .relax_on_idle = 0, .fb_in_psram = 1 }
};
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
lv_init();
//lv_disp_draw_buf_init(&draw_buf, buf1, buf2, screenWidth * 80); ///<----WORKS, but too slow
lv_disp_draw_buf_init(&draw_buf, buf1, buf2, screenWidth * screenHeight); ///<---- CRASHES with GURU Meditation Error
/*Initialize the display*/
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
disp_drv.user_data = panel_handle;
lv_disp_drv_register(&disp_drv);
Thanks