CrowPanel keeps resetting
Hello,
I'm having a problem where the CrowPanel ESP32 HMI 5.0-inch Display keeps resetting with my program. It shows half of the 1st screen and then resets, and keeps doing this in an endless loop. The UI was created with SquareLine Studio. I'm using VS Code with ESP-IDF to compile.
Using the "Monitor Device" terminal on VS Code, this is what the CrowPanel returns upon reset:
[ 1064][E][Wire.cpp:539] write(): NULL TX buffer pointer
> [ 1069][E][Wire.cpp:449] endTransmission(): NULL TX buffer pointer
> [ 1086][E][Wire.cpp:485] requestFrom(): NULL buffer pointer
> [ 1091][E][Wire.cpp:566] read(): NULL RX buffer pointer
> I (1244) gpio: GPIO[2]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
> I (1244) gpio: GPIO[38]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
> Setup done
> Loop 1
> Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
>
> Core 1 register dump:
> PC : 0x4201ed71 PS : 0x00060e30 A0 : 0x8201f408 A1 : 0x3fcccfd0
> --- 0x4201ed71: circ_calc_aa4 at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw_mask.c:1123
> A2 : 0x3fcb6190 A3 : 0x00000000 A4 : 0x0000000d A5 : 0x00000070
> A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x3fcccfdc
> A10 : 0x0000000d A11 : 0x3fcccfd8 A12 : 0x00000034 A13 : 0x42036f78
> --- 0x42036f78: dispatch at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw.c:431
> A14 : 0x3fcbd700 A15 : 0x00000000 SAR : 0x0000001e EXCCAUSE: 0x0000001d
> EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000000
> --- 0x40056f5c: memcpy in ROM
> --- 0x40056f72: memcpy in ROM
>
>
> Backtrace: 0x4201ed6e:0x3fcccfd0 0x4201f405:0x3fccd030 0x42037d1d:0x3fccd050 0x42037f45:0x3fccd0c0 0x42036eeb:0x3fccd1d0 0x42036f5e:0x3fccd1f0 0x42036fa9:0x3fccd210 0x4201c0dd:0x3fccd230 0x4201c108:0x3fccd250 0x4201c18a:0x3fccd270 0x4201d94a:0x3fccd290 0x4203526e:0x3fccd310 0x42035a67:0x3fccd3b0 0x4206b29d:0x3fccd3f0 0x420366fe:0x3fccd410 0x4203678e:0x3fccd430 0x4201a8a4:0x3fccd470 0x4201abad:0x3fccd5a0 0x4201a95a:0x3fccd680 0x4201abad:0x3fccd7b0 0x4201a95a:0x3fccd890 0x4201abad:0x3fccd9c0 0x4201a95a:0x3fccdaa0 0x4201abad:0x3fccdbd0 0x4201ae48:0x3fccdcb0 0x4201afc2:0x3fccdcd0 0x4201b173:0x3fccdd00 0x4201b27d:0x3fccdd40 0x4201b43f:0x3fccdd60 0x42024201:0x3fccdd80 0x420242b5:0x3fccdda0 0x42009f50:0x3fccddc0 0x4200d568:0x3fccdde0 0x40380105:0x3fccde00
> --- 0x4201ed6e: circ_calc_aa4 at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw_mask.c:1123
> --- 0x4201f405: lv_draw_sw_mask_radius_init at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw_mask.c:352
> --- 0x42037d1d: shadow_draw_corner_buf at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw_box_shadow.c:585
> --- 0x42037f45: lv_draw_sw_box_shadow at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw_box_shadow.c:123
> --- 0x42036eeb: execute_drawing at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw.c:512
> --- 0x42036f5e: execute_drawing_unit at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw.c:383
> --- 0x42036fa9: dispatch at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/sw/lv_draw_sw.c:463
> --- 0x4201c0dd: lv_draw_dispatch_layer at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/lv_draw.c:276
> --- 0x4201c108: lv_draw_dispatch at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/lv_draw.c:182
> --- 0x4201c18a: lv_draw_finalize_task_creation at C:/Users/noteb/Desktop/New_DPI/lesson_5_DHT_screen_50_basic/components/lvgl-3/src/draw/lv_draw.c:147
I've used the base project (source code) provided by Elecrow as base for my C++ project. For some reason I'm getting an error on the forum when I try to post a link or image, but this is my main code:
#include "CrowPanel_ESP32_5.h"
#include <lvgl.h>
#include <DHT20.h>
#include "LGFX_driver.h" // You need to configure LGFX and touch in this file.
#include <SPI.h>
#include <Arduino.h>
#include "ui.h"
#include <esp_task_wdt.h>
#define WDT_TIMEOUT 25 // Timeout in seconds
LGFX lcd;
DHT20 dht20;
#define LVGL_TICK_PERIOD 5
// Screen cache
#define DRAW_BUF_SIZE (800 * 480 / 10)
lv_color_t draw_buf[DRAW_BUF_SIZE];
static lv_display_t *disp;
void send_debug_msg0() {
// Serial.print("x");
}
//Automatically refresh temperature and humidity data in real time.
lv_obj_t *temp_label;
lv_obj_t *humi_label;
void update_sensor_values() {
int temperature = dht20.getTemperature();
int humidity = dht20.getHumidity();
lv_label_set_text_fmt(temp_label, "%d", temperature);
lv_label_set_text_fmt(humi_label, "%d", humidity);
Serial.print("Temp: ");
Serial.print(temperature);
Serial.println(" °C");
Serial.print("Humi: ");
Serial.print(humidity);
Serial.println(" %");
}
// Touch reading function
void my_touchpad_read(lv_indev_t *indev, lv_indev_data_t *data) {
if (lcd.getTouch(&data->point.x, &data->point.y)) {
data->state = LV_INDEV_STATE_PRESSED;
Serial.printf("Touch at: (%ld, %ld)\n", data->point.x, data->point.y);
} else {
data->state = LV_INDEV_STATE_RELEASED;
}
}
// Refresh function
void my_disp_flush(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map) {
uint32_t w = lv_area_get_width(area);
uint32_t h = lv_area_get_height(area);
lcd.pushImageDMA(area->x1, area->y1, w, h, (lgfx::rgb565_t *)px_map);
lv_display_flush_ready(disp);
}
// Obtain the tick time
uint32_t my_tick() {
return millis();
}
void setup() {
Serial.begin(115200);
dht20.begin();
lcd.begin();
lcd.setTextSize(2);
lcd.fillScreen(TFT_BLACK);
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
pinMode(38, OUTPUT);
digitalWrite(38, LOW);
// Initialize LVGL
lv_init();
lv_tick_set_cb(my_tick);
// Create display
disp = lv_display_create(800, 480);
lv_display_set_flush_cb(disp, my_disp_flush);
lv_display_set_buffers(disp, draw_buf, NULL, sizeof(draw_buf), LV_DISPLAY_RENDER_MODE_PARTIAL);
// Register input device (touch)
lv_indev_t *indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_touchpad_read);
ui_init();
// Create a temperature digital label
temp_label = lv_label_create(lv_screen_active());
lv_obj_set_style_text_font(temp_label, &lv_font_montserrat_48, 0); // A larger font can be changed
lv_obj_align(temp_label, LV_ALIGN_CENTER, -40, -100); // Center and shift upwards
lv_label_set_text(temp_label, "--");
// Create a humidity digital label
humi_label = lv_label_create(lv_screen_active());
lv_obj_set_style_text_font(humi_label, &lv_font_montserrat_48, 0);
lv_obj_align(humi_label, LV_ALIGN_CENTER,-40, 50); // Center and offset downward
lv_label_set_text(humi_label, "--");
Serial.println("Setup done");
}
void loop() {
Serial.println("Loop 1");
lv_timer_handler(); // LVGL task processing
Serial.println("Loop 2");
static unsigned long last_update = 0;
if (millis() - last_update > 2000) {
update_sensor_values();
last_update = millis();
}
Serial.println("Loop 3");
delay(300);
Serial.println("Loop 4");
}
Tracing the problem, I've seen that exception is happening inside the lv_timer_handler() function that's on the main loop.
What could it be? I've tried to change the UI, and when I keep the UI short it works without resetting. But if I create more screens, it resets on the 1st screen even without any access or references to the new screens on it. If I keep removing objects one my one from the last screen that caused the issue to start happening, at a certain point it will work. Just one object (any object) will cause the problem to start. I don't think its the object itself, as I've tried other objects and other screens, and it still happens. It looks like its something related to SRAM allocation or FLASH memory addresses.
Thanks for your help!
Comments
Note: When I compile my project, I get this memory usage information: