Yacubane / esp32-arduino-matter

Matter IoT protocol library for ESP32 working on Arduino framework
Apache License 2.0
314 stars 31 forks source link

Crash after wifi init attempt #29

Closed richievos closed 1 year ago

richievos commented 1 year ago

I'm getting the following error when attempting to run the two endpoints example. I am using an ESP32 (WROOM) under platformio. I downloaded v1.0.0-beta.3, unzipped it, and copied all of src into lib/esp32-arduino-matter.

I then put all the code from that example into main-matter.cpp and disabled my existing main.cpp. There should be no other code really getting built.

Any pointers on if this an issue on my end would be appreciated. I'm also rebuilding the library myself in case there's any config settings I need to tune.

Error

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13104
load:0x40080400,len:3036
entry 0x400805e4
E (98) wifi:invalid magic number 7, call WIFI_INIT_CONFIG_DEFAULT to init config
E (99) esp_matter_core: Error initializing Wi-Fi stack

abort() was called at PC 0x400d32ec on core 1

Backtrace: 0x40083b89:0x3ffd8470 0x40093ced:0x3ffd8490 0x400994dd:0x3ffd84b0 0x400d32ec:0x3ffd8530 0x400d2df6:0x3ffd8550 0x400d31a1:0x3ffd8580 0x400d2d19:0x3ffd85b0 0x400f9e36:0x3ffd8650

ELF file SHA256: 12f6421243296673

Rebooting...

Platformio.ini

[env]
lib_deps =

build_unflags =
    '-std=gnu++11'

build_flags =
    '-std=gnu++17'

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

monitor_speed = 115200

board_build.partitions=min_spiffs.csv # I'm not really sure if this is a file I was supposed to create or copy-down or if it's just a magic file name

lib_deps =
    ${env.lib_deps}

build_unflags =
    ${env.build_unflags}

build_flags =
    ${env.build_flags}

esptool.py output

--> esptool.py  --chip esp32 flash_id
esptool.py v4.3
Found 4 serial ports
Serial port /dev/cu.usbserial-0001
Connecting......................
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: cc:db:a7:16:18:14
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...
richievos commented 1 year ago

Debugging further, the matter start lines are what trigger the wifi error message:

void setup() {
...
  // Start Matter device
  esp_matter::start(on_device_event);

The lines that actually cause the fault are the ones immediately after that start call:

void setup() {
...
   PrintOnboardingCodes(
     chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));
richievos commented 1 year ago

I figured it out. It turned out the default espressif32 platform version was something like 6.0.1 whereas this needs 6.1.0. I didn't catch that until just now after a series of debugging steps. The fix is update your platformio.ini to look like:

[env:esp32devarduino]
platform = espressif32@6.1.0
board = esp32dev
framework = arduino

board_build.partitions=min_spiffs.csv

I'll discuss long-term documentation for in #31.