Waveshare ESP32 S3 Touch LCD 4.3B - LVGL + Wifi - no luck

Hi,
I’m using a Waveshare ESP32 S3 Touch 4.3B board.
LVGL 8 (no drivers for 9)
Arduino build

I’m fine building basic UI with LGVL have the demo’s working on the board etc.

also have a standalone WifI only .ino which successfully connects to WiFi, NTP etc.- i.e. I think WiFi is good on its own.

Issue
As soon as I try to WiFi.Begin after Board->Init in Setup - the board reboots over and over.

If I WiFi.Begin at the top of Setup then the board will startup and I get a GUI, but as soon as there’s a WiFi interaction - a packet etc, then same behaviour it falls over and reboots.

I’ve seen various threads talking about IRAM_ATTR - but no luck this doesn’t seem to fix the problem.

Request
Does anyone have a boiler plate LVGL + Wifi working on this board?

Cheers.

I had a similar issue with other board (LiLyGo T4-S3).

The problem was related to memory allocation, the two partial screen buffers where too large (600x450 screen, even with 1/10 of buffer was too large), the QSPI driver do not accept SPIRAM buffers (it always create internal RAM buffers) and the LV_MEM size was to high (82KB) therefore there wasn’t enough memory in order for the Wifi driver to allocated all the buffers it requires.

In my case, the solution was:

  • Reduce the Partial Buffer size (limit to 32KB to match max SPI transfer size with single queue)
  • Enable KConfig option CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP in order for the Wifi driver to attempt to use SPIRAM for most of buffers (not all of them, but most…)

In my case, this fixed the problem.

Thank you -
I’ve also just tried a minimal Wifi setup, PSRAM off - works fine
Then boad init and PSRAM off - works fine

PSRAM on - and it breaks - so aligned with your findings, if I can persuade WiFi NOT to use PSRAM that may fix the problem.

(Learning all the time :slight_smile: )

Replying to myself - I suspect the most stable setup will be a separate ESP32 for Wifi.

The Wifi ESP32 can just do serial<>wifi
The main ESP32 with tocuh screen the Ui.

My gut feel is the issue I’m hitting is basically a memory problem and I could tinker around the edges of it trying to fine tune the wifi library to co-exist, but at best its going to be super brittle and sensetive to upgrades.

I mean is based on lcd driver type, i use SPI display and GUI plus internet radio streaming without issue. Too versions is critical…

I am currently using a display with 600x450, using just two partial buffers (32KB each) and have Wifi, LVGL (with a memory size of 80KB) and a couple of RTOS Tasks, and still have around of 42KB free internal memory.

Show us how you have the LVGL Buffers setup, that way we can attempt to give some extra feedback.

Also you can try, to call something similar to this:

            printf("Free heap size: %lu bytes\n", esp_get_free_heap_size());
            printf("Free internal heap size: %lu bytes\n", esp_get_free_internal_heap_size());
            printf("Minimum free heap size: %lu bytes\n", esp_get_minimum_free_heap_size());
            printf("Free RTOS Heap Size: %zu bytes\n", heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));

Before calling each initialization function (lvgl, wifi, display, etc…) to see where the memory is being consumed, not sure if this is 100% correct, but it helped me when was having issues with the memory and attempting to pass things to SPIRAM (NVS structures, WIFI, etc…).

And also monitor the LVGL memory, to see if you can reduce its size:

            lv_mem_monitor_t mon;
            Display_lvgl_lock(-1);
            lv_mem_monitor(&mon);
            printf("LVGL_MEM -> used: %6u (%3u %%), frag: %3u %%, biggest free: %6d, Max Used: %u\n", mon.total_size - mon.free_size, mon.used_pct, mon.frag_pct, (int)mon.free_biggest_size, mon.max_used);
            Display_lvgl_unlock();

I reverted to using the demo ‘squareline_wifi_clock’
i.e. its not my code (To take me out of the loop as much as possible)
It works in terms of bringing up an initial LVGL display, I can go into the connect to wifi screen - and as per my other tests…

As soon as I try to connect, and it runs WiFi.Begin…

Buffer allocation config from lvgl_v8_port.h
#define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) // Allocate LVGL buffer in SRAM
// #define LVGL_PORT_BUFFER_MALLOC_CAPS (MALLOC_CAP_SPIRAM) // Allocate LVGL buffer in PSRAM
#define LVGL_PORT_BUFFER_SIZE_HEIGHT (20)
#define LVGL_PORT_BUFFER_NUM (2)

The system crashes/restarts with error:
Guru Meditation Error: Core 1 panic’ed (Cache disabled but cached memory region accessed).

Core 1 register dump:
PC : 0x40056f64 PS : 0x00060034 A0 : 0x803793e1 A1 : 0x3fc9b400
A2 : 0x3fcc42bc A3 : 0x3c33dba0 A4 : 0x00007d00 A5 : 0x3fcc42bc
A6 : 0xbad00bad A7 : 0xbad00bad A8 : 0x00000000 A9 : 0x3fcc40f8
A10 : 0x01ffffff A11 : 0x00000003 A12 : 0x00060023 A13 : 0x00000000
A14 : 0x01ffffff A15 : 0x00000004 SAR : 0x00000018 EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x000007cf
Backtrace: 0x40056f61:0x3fc9b400 0x403793de:0x3fc9b410 0x4037958b:0x3fc9b430 0x4037ba3a:0x3fc9b450 0x40379a1d:0x3fc9b480 0x403767f7:0x3fcb12f0 0x40376a7b:0x3fcb1310 0x4037f64a:0x3fcb1340

This is the startup - including memory checks.
I was just trying out some different partitions with huge code areas 6MB in this case but that makes no difference.

Initializing board
[I][Panel]esp_lcd_touch_gt911.c:0067: version: 1.1.1
[W][Panel]esp_lcd_touch_gt911.c:0144: Unable to initialize the I2C address
[I][Panel]esp_lcd_touch_gt911.c:0401: TouchPad_ID:0x39,0x31,0x31
[I][Panel]esp_lcd_touch_gt911.c:0402: TouchPad_Config_Version:67
[I][Panel]esp_panel_board.cpp:0463: Board begin success
Initializing LVGL
[I][LvPort]lvgl_v8_port.cpp:0748: Avoid tearing is enabled, mode: 3, rotation: 0
[I][LvPort]lvgl_v8_port.cpp:0761: Initializing LVGL display driver
Creating UI
wifi_connected_flag: false
Free heap size: 6980256 bytes
Free internal heap size: 132732 bytes
Minimum free heap size: 6980124 bytes
Free RTOS Heap Size: 140208 bytes

If WiFi isn’t out of memory why is it putting ISRs in places they cant execute?
(edit - why am I inadvertently telling it to put ISRS in places they can’t execute somehow :slight_smile: )

Hi

Don’t you the panic handler fully decoded? With what function was being executed when it happened?

To my knowledge some of the Wifi functions are placed in IRAM, i don’t know it there is any setting to disable that.

I have had a somehow similar problem, my issue was that I had a callback for the SPI Driver that was being called in the ISR of SPI (that was being executed in IRAM) and had some issues with Wifi driver but at the time I suspected that was because of having NVS also enabled and it coincided with some access to NVS that stall the Flash. In my case the solution was to place that callback also in IRAM.

Hi, Re decode panic etc.
No I hadn’t - to be honest my hope was using the LCD + Wifi libraries wasn’t that esoteric and I would be able to find examples, even from the vendor, or LVGL where someone had done it before.

Debugging the vendor Wifi library is probably beyond my capability.

I’ve not found any public example where the wifi.h co-exists with event basic Espressif board->init() sucessfully. I guess no one is doing WIFI / LCD apps :frowning:

Sorry , but your info is as from Legoland. Version combinations for LVGL Arduino IDF panels libs etc. create more as 1000 variants and only 10% of it is bug free and relative usable for WiFi + Display.

1 Like