Arduino ESP32 Guru冥想错误/堆栈溢出

问题描述 投票:0回答:1

我有一个 Arduino 脚本已经运行了几年了。最近我想做一些小的更新,但从那以后我一直遇到问题。即使当我运行旧版本(稳定运行几个月的版本)时,我也会收到loopTask-stackOverflow和Guru Meditation错误(取决于调试级别设置)。

该脚本创建 WSfx 库的八个实例来控制 WS2812b LED。根据我定义的像素数量(更大的缓冲区),我会出现错误。所以看来我调用的内存多于可用内存。但事实真的是这样吗?我无法想象 ESP32 Arduino 核心更新或库更新会对核心和库的内存使用产生如此大的影响。我曾经能够创建 8 个实例,每个实例至少有 500 像素。现在我总共很难得到 400 像素。这很奇怪,因为编译时它指出: Sketch 使用 318133 字节 (24%) 的程序存储空间。最大值为 1310720 字节。 全局变量使用 23080 字节 (7%) 的动态内存,为局部变量留下 304600 字节。最大值为 327680 字节。 人们预计 304kB 足以运行 8(实例)* 500(像素)* 3(RGB 颜色)= 12kB 的缓冲区

我删除了脚本中的所有其他功能,以确保问题不在其他地方。

硬件:AZ-delivery Dev kit C V4(ESP32 D0WD-Q5,带 0.5MB 内存) IDE:适用于 Mac 的 Arduino IDE,带有 ESP32 Arduino Core 3

我已经考虑这个问题好几天了。但我无法弄清楚串行输出和异常解码的情况。什么是“大师冥想错误:核心 1 恐慌 (LoadStoreError)。异常未处理。”错误?谁能根据异常解码得出结论并为我指明正确的方向?

此外我想知道是否有一种方法可以跟踪运行时内存的使用情况,以查看动态内存的分配?确定它是否实际上是堆栈溢出或完全是其他原因。如果是这样,找出是什么任务导致了这种过度使用。

非常感谢任何有助于理解正在发生的事情的帮助。

最诚挚的问候, 保罗

剥离的脚本:

#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();
}

调试级别设置为“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 -> 

异常解码器输出:

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

调试级别设置为“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 -> 
stack-overflow dynamic-memory-allocation arduino-esp32
1个回答
0
投票

我能够将问题追溯到 Adafruit NeoPixel 库,显然 Ws2812FX 库正在使用该库来实际生成数据流。当我访问 Adafruit GitHub 时,我发现了几个关于我遇到的相同问题的问题报告。 ESP32 Arduino Core 3 和 Adafruit 库之间确实存在一些不兼容性,尤其是在缓冲区分配方面。恢复 Adafruit 库和 Arduino Core 会产生稳定的版本,这对我来说很好,直到 Adafruit 更新库为止。

© www.soinside.com 2019 - 2024. All rights reserved.