Reputation: 11
I have a Arduino script running for a few years now. Recently I wanted do some minor updates, but I've been running into problems ever since. Even when I run the older version (the version running stable for a few months), i get loopTask-stackOverflow and Guru Meditation errors (depending on debug-level setting).
The script creates eight instances of the WSfx-library to control WS2812b led's. Depending on how many pixels I define (larger buffer) I get there errors. So it seems to be that I call more memory than available. But is that actually what is going on? I can't imagine a ESP32 Arduino Core update or library update makes such a difference in the memory usage of the core and library. I used to be able to create eight instances with each at least 500 pixels. Now I hardly get 400 pixels in total. Which is weird because when compiling it states: Sketch uses 318133 bytes (24%) of program storage space. Maximum is 1310720 bytes. Global variables use 23080 bytes (7%) of dynamic memory, leaving 304600 bytes for local variables. Maximum is 327680 bytes. One would expect 304kB to be enough to run a buffer of 8 (instances) * 500 (pixels) * 3 (RGB colors) = 12kB
I stripped the script of all other functions to make sure the problem isn't anywhere else.
Hardware: AZ-delivery Dev kit C V4 (ESP32 D0WD-Q5 with 0.5MB internal memory) IDE: Arduino IDE for Mac with ESP32 Arduino Core 3
I've been going over this for days. But I can't make heads or tails of the Serial output and the exception decoding. What is a "Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled."-error? And can anyone draw a conclusion based on the exception decoding and point me in the right direction?
Furthermore I'm wondering if there's a way to trace runtime memory usages, to see the allocation of dynamic memory? To determine if it is actually a stack overflow or something else entirely. And if so, find out what task is causing this excessive usage.
Any help in understanding what is going one is much appreciated.
Best regards, Paul
The stripped script:
#include <WS2812FX.h>
#define LedPin1 32
#define LedPin2 33
#define LedPin3 25
#define LedPin4 26
#define LedPin5 27
#define LedPin6 14
#define LedPin7 17
#define LedPin8 16
#define ledCount 100
#define LedCount1 ledCount
#define LedCount2 ledCount
#define LedCount3 ledCount
#define LedCount4 ledCount
#define LedCount5 ledCount
#define LedCount6 ledCount
#define LedCount7 ledCount
#define LedCount8 ledCount
WS2812FX WSfx1 = WS2812FX(LedCount1, LedPin1, NEO_BGR + NEO_KHZ800);
WS2812FX WSfx2 = WS2812FX(LedCount2, LedPin2, NEO_RGB + NEO_KHZ800);
WS2812FX WSfx3 = WS2812FX(LedCount3, LedPin3, NEO_RGB + NEO_KHZ800);
WS2812FX WSfx4 = WS2812FX(LedCount4, LedPin4, NEO_RGB + NEO_KHZ800);
WS2812FX WSfx5 = WS2812FX(LedCount5, LedPin5, NEO_RGB + NEO_KHZ800);
WS2812FX WSfx6 = WS2812FX(LedCount6, LedPin6, NEO_RGB + NEO_KHZ800);
WS2812FX WSfx7 = WS2812FX(LedCount7, LedPin7, NEO_RGB + NEO_KHZ800);
WS2812FX WSfx8 = WS2812FX(LedCount8, LedPin8, NEO_RGB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("Booting");
// WS2812fx
WSfx1.init();
WSfx2.init();
WSfx3.init();
WSfx4.init();
WSfx5.init();
WSfx6.init();
WSfx7.init();
WSfx8.init();
WSfx1.setBrightness(255);
WSfx2.setBrightness(255);
WSfx3.setBrightness(255);
WSfx4.setBrightness(255);
WSfx5.setBrightness(255);
WSfx6.setBrightness(255);
WSfx7.setBrightness(255);
WSfx8.setBrightness(255);
WSfx1.setColor(0x0000FF);
WSfx2.setColor(0x0000FF);
WSfx3.setColor(0x0000FF);
WSfx4.setColor(0x0000FF);
WSfx5.setColor(0x0000FF);
WSfx6.setColor(0x0000FF);
WSfx7.setColor(0x0000FF);
WSfx8.setColor(0x0000FF);
WSfx1.setMode(0x00);
WSfx2.setMode(0x00);
WSfx3.setMode(0x00);
WSfx4.setMode(0x00);
WSfx5.setMode(0x00);
WSfx6.setMode(0x00);
WSfx7.setMode(0x00);
WSfx8.setMode(0x00);
WSfx1.start();
WSfx2.start();
WSfx3.start();
WSfx4.start();
WSfx5.start();
WSfx6.start();
WSfx7.start();
WSfx8.start();
Serial.println("end setup");
}
void loop() {
WSfx1.service();
WSfx2.service();
WSfx3.service();
WSfx4.service();
WSfx5.service();
WSfx6.service();
WSfx7.service();
WSfx8.service();
}
The Serial output after upload with debug-level set to "none":
20:28:24.115 -> ets Jul 29 2019 12:21:46
20:28:24.115 ->
20:28:24.115 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
20:28:24.115 -> configsip: 0, SPIWP:0xee
20:28:24.115 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
20:28:24.147 -> mode:DIO, clock div:1
20:28:24.147 -> load:0x3fff0030,len:4832
20:28:24.147 -> load:0x40078000,len:16460
20:28:24.147 -> load:0x40080400,len:4
20:28:24.147 -> load:0x40080404,len:3504
20:28:24.147 -> entry 0x400805cc
20:28:26.524 -> Booting
20:28:31.663 -> Ready
20:28:31.663 -> IP address: 192.168.0.44
20:28:31.663 -> TX power:78
20:28:31.695 -> Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled.
20:28:31.695 ->
20:28:31.695 -> Core 1 register dump:
20:28:31.695 -> PC : 0x40091fa2 PS : 0x00060233 A0 : 0x8009180c A1 : 0x3ffb00d0
20:28:31.695 -> A2 : 0x3ffb0014 A3 : 0x3f4098bc A4 : 0x3f409938 A5 : 0x0000000b
20:28:31.695 -> A6 : 0xb33fffff A7 : 0xb33fffff A8 : 0x6f633e2c A9 : 0x3f409930
20:28:31.695 -> A10 : 0x6f633dba A11 : 0x00000070 A12 : 0x3f4098c4 A13 : 0x3ffb0038
20:28:31.727 -> A14 : 0x3ffb0060 A15 : 0xfffffffc SAR : 0x00000014 EXCCAUSE: 0x00000003
20:28:31.727 -> EXCVADDR: 0x3f409934 LBEG : 0x4008a474 LEND : 0x4008a48a LCOUNT : 0xffffffff
20:28:31.727 ->
20:28:31.727 ->
20:28:31.727 -> Backtrace: 0x40091f9f:0x3ffb00d0 0x40091809:0x3ffb00f0 0x40091940:0x3ffb0110 0x400843a2:0x3ffb0130 0x400844d4:0x3ffb0160 0x40084254:0x3ffb0180 0x400e20bb:0x3ffb01a0 0x400e31e0:0x3ffb01c0 0x400de483:0x3ffb0220 0x400dac61:0x3ffb0270 0x400dabc3:0x3ffb2110 0x400d855c:0x3ffb2130 0x400d8638:0x3ffb2150 0x400d3261:0x3ffb2170 0x400df5a3:0x3ffb2270 0x4008f96a:0x3ffb2290
20:28:31.760 ->
20:28:31.760 ->
20:28:31.760 ->
20:28:31.760 ->
20:28:31.760 -> ELF file SHA256: effdc3b6e5804644
20:28:31.760 ->
The Exception Decoder output:
20:28:15.780 -> Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled.
20:28:15.780 ->
20:28:15.780 -> Core 1 register dump:
20:28:15.780 -> PC : 0x40091fa2 PS : 0x00060233 A0 : 0x8009180c A1 : 0x3ffb00d0
20:28:15.811 -> A2 : 0x3ffb0014 A3 : 0x3f4098bc A4 : 0x3f409938 A5 : 0x0000000b
20:28:15.811 -> A6 : 0xb33fffff A7 : 0xb33fffff A8 : 0x6f633e2c A9 : 0x3f409930
20:28:15.811 -> A10 : 0x6f633dba A11 : 0x00000070 A12 : 0x3f4098c4 A13 : 0x3ffb0038
20:28:15.811 -> A14 : 0x3ffb0060 A15 : 0xfffffffc SAR : 0x00000014 EXCCAUSE: 0x00000003
20:28:15.843 -> EXCVADDR: 0x3f409934 LBEG : 0x4008a474 LEND : 0x4008a48a LCOUNT : 0xffffffff
20:28:15.843 ->
20:28:15.843 ->
20:28:15.843 -> Backtrace: 0x40091f9f:0x3ffb00d0 0x40091809:0x3ffb00f0 0x40091940:0x3ffb0110 0x400843a2:0x3ffb0130 0x400844d4:0x3ffb0160 0x40084254:0x3ffb0180 0x400e20bb:0x3ffb01a0 0x400e31e0:0x3ffb01c0 0x400de483:0x3ffb0220 0x400dac61:0x3ffb0270 0x400dabc3:0x3ffb2110 0x400d855c:0x3ffb2130 0x400d8638:0x3ffb2150 0x400d3261:0x3ffb2170 0x400df5a3:0x3ffb2270 0x4008f96a:0x3ffb2290
20:28:15.877 ->
PC: 0x40091fa2: tlsf_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/tlsf/tlsf_block_functions.h:26
EXCVADDR: 0x3f409934
Decoding stack results
0x40091f9f: tlsf_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/tlsf/tlsf_block_functions.h:26
0x40091809: multi_heap_malloc_impl at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap.c:207
0x40091940: multi_heap_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap_poisoning.c:251
0x400843a2: heap_caps_malloc_base at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps_base.c:128
0x400844d4: heap_caps_calloc_base at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps_base.c:235
0x40084254: heap_caps_calloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c:255
0x400e20bb: rmt_acquire_group_handle at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/driver/rmt/rmt_common.c:42
0x400e31e0: rmt_new_tx_channel at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/driver/rmt/rmt_tx.c:108
0x400de483: rmtInit at /Users/paul/Library/Arduino15/packages/esp32/hardware/esp32/3.0.6/cores/esp32/esp32-hal-rmt.c:547
0x400dac61: espShow at /Users/paul/Dropbox/Apps/Arduino IDE/libraries/Adafruit_NeoPixel/esp.c:40
0x400dabc3: Adafruit_NeoPixel::show() at /Users/paul/Dropbox/Apps/Arduino IDE/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:3163
0x400d855c: WS2812FX::execShow() at /Users/paul/Dropbox/Apps/Arduino IDE/libraries/WS2812FX/src/WS2812FX.cpp:165
0x400d8638: is in WS2812FX::setBrightness(unsigned char) (/Users/paul/Dropbox/Apps/Arduino IDE/libraries/WS2812FX/src/WS2812FX.cpp:246).
0x400d3261: setup() at /Users/paul/Dropbox/Apps/Arduino IDE/PDCP gen 2/ClientWS_02/ClientWS_02.ino:323
0x400df5a3: loopTask(void*) at /Users/paul/Library/Arduino15/packages/esp32/hardware/esp32/3.0.6/cores/esp32/main.cpp:59
0x4008f96a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162
The Serial output after upload with debug-level set to "debug":
21:45:39.954 -> Rebooting...
21:45:39.954 -> ets Jul 29 2019 12:21:46
21:45:39.954 ->
21:45:39.954 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
21:45:39.954 -> configsip: 0, SPIWP:0xee
21:45:39.954 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
21:45:39.987 -> mode:DIO, clock div:1
21:45:39.987 -> load:0x3fff0030,len:4832
21:45:39.987 -> load:0x40078000,len:16460
21:45:39.987 -> load:0x40080400,len:4
21:45:39.987 -> load:0x40080404,len:3504
21:45:39.987 -> entry 0x400805cc
21:45:42.128 -> Booting
21:45:42.128 ->
21:45:42.128 -> ***ERROR*** A stack overflow in task loopTask has been detected.
21:45:42.128 ->
21:45:42.128 ->
21:45:42.128 -> Backtrace: 0x400829cd:0x3ffaf9c0 0x40088a55:0x3ffaf9e0 0x4008b705:0x3ffafa00 0x40089dc6:0x3ffafa80 0x4008b8c0:0x3ffafab0 0x4008b870:0x3ffafad0 0x400845f2:0x00000001 |<-CORRUPTED
21:45:42.162 ->
21:45:42.162 ->
21:45:42.162 ->
21:45:42.162 ->
21:45:42.162 -> ELF file SHA256: f956b468f5fc4f8b
21:45:42.162 ->
Upvotes: 0
Views: 153
Reputation: 11
I was able to trace the problem back to the Adafruit NeoPixel library, which apparently is being used by the Ws2812FX-library to actually generate the data stream. Once I was on the Adafruit GitHub I found several issue-reports regarding the same problem I'm having. Some incompatibility between ESP32 Arduino Core 3 and the Adafruit library, indeed regarding buffer allocation. Reverting both Adafruit-library and the Arduino Core results in a stable build, which is fine for me until Adafruit updates the library.
Upvotes: 0