stack-chan / m5stack-avatar

An M5Stack library for rendering avatar faces
MIT License
173 stars 31 forks source link

Avatar library don't work with WiFi On #65

Open sweemeng opened 3 years ago

sweemeng commented 3 years ago

Describe the bug Code crash in setup() when Avatar library and WiFi is used together. There is no compilation error.

To Reproduce Compile the following source code, in platform IO, upload to M5Stack-fire. View the serial monitor.

#include <Arduino.h>
#include <M5Stack.h>
#include <WiFi.h>
#include <Avatar.h>

using namespace m5avatar;

const char* ssid = "ssid";
const char* password = "passwd";
Avatar avatar;

void setup_wifi(){
  delay(10);
  WiFi.begin(ssid, password);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  while(WiFi.status() != WL_CONNECTED){
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void setup() {
  M5.begin();
  Serial.begin(115200);
  Serial.println("Init wifi");
  setup_wifi();
  Serial.println("Init avatar");
  avatar.init();
  Serial.println("Done");
}

void loop() {
  // put your main code here, to run repeatedly:
}

Platformio config is here

[env:m5stack-fire]
platform = espressif32
board = m5stack-fire
framework = arduino
monitor_speed = 115200

lib_deps = meganetaaan/M5Stack-Avatar@^0.7.3

Expected behavior Code should work run on m5stack-fire. It should not cause the device to rebook.

Logs If any compile error occurs, add a full compile log.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context

This is run on M5Stack-fire

Output from serial monitor when running the code

Init wifi

Connecting to ssid
.....
WiFi connected
IP address:
192.168.0.149
Init avatar
Guru Meditation Error: Core  0 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (drawLoop)

ELF file SHA256: 0000000000000000

Backtrace: 0x4008bc54:0x3ffcc910 0x4008d212:0x3ffcc920 0x4008d391:0x3ffcc9f0 0x4008d675:0x3ffcca10 0x40089422:0x3ffcca30 0x4008d1d1:0x3ffccaf0 0x4008d44d:0x3ffccb10 0x4008918d:0x3ffccb30 0x400892b9:0x3ffccb60 0x400f5bef:0x3ffccb80 0x400f1efd:0x3ffcce40 0x400f1e98:0x3ffcce90 0x4008f475:0x3ffccec0 0x40091483:0x3ffccef0 0x40091abd:0x3ffccf10 0x40081f59:0x3ffccf30 0x40082130:0x3ffccf50 0x400815d7:0x3ffccf70 0x40142979:0x3ffccf90 0x401429fe:0x3ffccfb0 0x400d5eec:0x3ffccfd0 0x400d5243:0x3ffcd010 0x400d526f:0x3ffcd060 0x4008e452:0x3ffcd080

Rebooting...
sweemeng commented 3 years ago

I use EspExceptionDecoder. From the error. I think I really run out of memory. Unless I read the stacktrace wrongly


Decoding stack results
0x4008d1da: commonErrorHandler_dump at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 487
0x4008d359: commonErrorHandler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 582
0x4008d63d: xt_unhandled_exception at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 367
0x4008d199: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 154
0x4008d415: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 171
0x40089365: lock_acquire_generic at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/locks.c line 143
0x40089491: _lock_acquire_recursive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/locks.c line 171
0x400fae5f: _vfiprintf_r at ../../../.././newlib/libc/stdio/vfprintf.c line 860
0x400f6a05: fiprintf at ../../../.././newlib/libc/stdio/fiprintf.c line 50
0x400f691c: __assert_func at ../../../.././newlib/libc/stdlib/assert.c line 59
0x4008f43d: vTaskEnterCritical at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portmux_impl.inc.h line 105
0x4009144b: multi_heap_internal_lock at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap.c line 375
0x40091a85: multi_heap_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap_poisoning.c line 194
0x40082131: heap_caps_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c line 111
0x40082308: heap_caps_calloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c line 325
0x400815d7: ps_calloc at /home/sweemeng/.arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/esp32-hal-psram.c line 66
0x400d50da: TFT_eSprite::callocSprite(short, short, unsigned char) at /home/sweemeng/Arduino/libraries/M5Stack/src/utility/Sprite.cpp line 138
0x400d515e: TFT_eSprite::createSprite(short, short, unsigned char) at /home/sweemeng/Arduino/libraries/M5Stack/src/utility/Sprite.cpp line 71
0x400d99d8: m5avatar::Face::draw(m5avatar::DrawContext*) at /home/sweemeng/Arduino/libraries/M5Stack_Avatar/src/Face.cpp line 102
0x400d8a47: m5avatar::Avatar::draw() at /home/sweemeng/Arduino/libraries/M5Stack_Avatar/src/Avatar.cpp line 135
0x400d8a73: m5avatar::drawLoop(void*) at /home/sweemeng/Arduino/libraries/M5Stack_Avatar/src/Avatar.cpp line 32
0x4008e41a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143