esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

ESP32+esp32_ble_tracker+Mqtt --> Backtrace:0x40083829:0x3ffd7dc00x4009491d:0x3ffd7de0 Crash ! #4901

Open zibous opened 9 months ago

zibous commented 9 months ago

The problem

If esp32_ble_tracker and mqtt is enabled, application crashes with backtrace. API Component (w/o mqtt) is working !

Version 2022.12.8 Feb 10 2023 is working !

Compiling with PIP, Docker - does not make a difference.

Which version of ESPHome has the issue?

2023.9.0b2, 2023.10.0-dev, 2023.8.3 ...

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32

Board

az-delivery-devkit-v4 and any other ESP32 Board

Component causing the issue

MQTT

Example YAML snippet

## ---------------------------------------------------
# ESP32 MQTT TESTCASE
## ---------------------------------------------------
substitutions:
  ## device settings
  device_name_short: "mqtt-test"
  device_description: "Testdevice: ESP32 MQTT Testcase"
  projectname: "MQTT-TEST.ESP32"
  appversion: "2.0.0"
  domain: !secret domain

## ---------------------------------------------------
## BOARD
## ---------------------------------------------------
esp32:
  board: az-delivery-devkit-v4

## ---------------------------------------------------
## ESPHOME APPLICATION
## ---------------------------------------------------
esphome:
  name: ${device_name_short}
  friendly_name: ${device_name_short}
  comment: ${device_description}
  project:
    name: ${projectname}
    version: ${appversion}
  build_path: ./build/${device_name_short}
  platformio_options:
    platform: espressif32
    board: az-delivery-devkit-v4
    board_build.mcu: esp32
    board_build.f_cpu: 240000000L
  on_boot:
    then:
      - logger.log:
          level: WARN
          tag: "system"
          format: "BOOTMESSAGE: ${device_name_short} API is connected, Device ready!"
      - globals.set:
          id: boot_counter
          value: !lambda "return id(boot_counter)+=1;"
      - component.update: bootcounter
  on_shutdown:
    then:
      - logger.log:
          level: ERROR
          tag: "system"
          format: "BOOTMESSAGE: ${device_name_short} is down!"    

## ---------------------------------------------------
## COMPONENT Logger
## ---------------------------------------------------
logger:

## ---------------------------------------------------
## GLOBALS VARIABLES
## ---------------------------------------------------
globals:
  - id: boot_counter
    type: int
    restore_value: yes
    initial_value: "0"

## ---------------------------------------------------
## COMPONENT OTA
## ---------------------------------------------------
ota:
  password: "****************"
  on_begin:
    then:
      - logger.log:
          format: "OTA Start"
          tag: "OTA"
          level: WARN
  on_progress:
    then:
      - logger.log:
          level: WARN
          tag: "OTA"
          format: "OTA progress %0.1f%%"
          args: ["x"]
  on_end:
    then:
      - logger.log:
          format: "OTA End"
          tag: "OTA"
          level: WARN
  on_error:
    then:
      - logger.log:
          format: "OTA update error %d"
          tag: "OTA"
          level: ERROR
          args: ["x"]

## ---------------------------------------------------
## COMPONENT WIFI
## ---------------------------------------------------
wifi:
  networks:

    # apple capsulate accesspoint 2.4Ghz
    - ssid: !secret ssid2_name
      password: !secret ssid2_pswd

    # capsulate accesspoint 2.4Ghz
    - ssid: !secret ssid3_name
      password: !secret ssid3_pswd

    # unifi accesspoint 2.4Ghz
    - ssid: !secret ssid4_name
      password: !secret ssid4_pswd

  domain: !secret domain

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap: {}

## ---------------------------------------------------
## COMPONENT CAPTIVE PORTAL
## ---------------------------------------------------
captive_portal:

# ---------------------------------------
# COMPONENT MQTT Brocker
# ---------------------------------------
mqtt:
  broker: !secret mqtt_broker1
  port: !secret mqtt_port1
  username: !secret mqtt_username1
  password: !secret mqtt_password1
  topic_prefix: $(topic_prefix)
  discovery: true
  birth_message:
    topic: tele/${device_name_short}/LWT
    payload: online
  will_message:
    topic: tele/${device_name_short}/LWT
    payload: offline

## ---------------------------------------------------
## COMPONENT WEBSERVER LOCAL
## ---------------------------------------------------
web_server:
  port: 80
  version: 2
  js_url: !secret webserver_jsurl

## ---------------------------------------------------
## COMPONENT SNTP Time server
## ---------------------------------------------------
time:
  - platform: sntp
    id: time_sntp
    timezone: Europe/Berlin
    on_time_sync:
         # Components should trigger on_time_sync when they update the system clock.
         then:
           - if:
               condition:
                 lambda: 'return id(device_lastBoot_time).state == "";'
               then:
                 - text_sensor.template.publish:
                     id: device_lastBoot_time
                     state: !lambda return id(time_sntp).now().strftime("%Y-%m-%dT%H:%M:%S %Z");
           - logger.log:
               level: WARN
               tag: "system"
               format: "Synchronized sntp clock"

## ---------------------------------------------------
## BLE TRACKER
## ---------------------------------------------------
esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

## ---------------------------------------------------
## switches
## ---------------------------------------------------
switch:

  # reset boot counter
  - platform: template
    name: Boot Counter reset
    turn_on_action:
      then:
        - lambda: |-
            id(boot_counter) = 0; id(bootcounter).publish_state(id(boot_counter));
        - logger.log:
            level: WARN
            tag: "system"
            format: "${device_name_short}reset boot counter o.k!"
        - component.update: bootcounter

  # restart button
  # The restart switch platform allows you to restart
  # your node remotely through Home Assistant.
  - platform: restart
    id: restart_device
    name: Restart
    disabled_by_default: true
    icon: mdi:restart

  # restart save button
  # The safe_mode switch allows you to remotely reboot your node into Safe Mode.
  # This is useful in certain situations where a misbehaving component,
  # or low memory state is preventing Over-The-Air updates
  # from completing successfully.
  - platform: safe_mode
    name: Restart Save Mode
    disabled_by_default: true
    icon: mdi:restart

  # restart device factory settings button
  # The factory_reset switch allows you to remotely invalidate (reset) all ESPHome preferences
  # stored in flash memory and reboot your node. After reboot all states,
  # parameters and variables will be reinitialized with their default values. This is useful:
  - platform: factory_reset
    name:  Restart Factory
    disabled_by_default: true
    icon: mdi:restart

## ---------------------------------------------------
## binary sensors
## ---------------------------------------------------
binary_sensor:

  # connected to mqtt / api state
  - platform: status
    name: Device Status
    id: Devicestat
    disabled_by_default: true # no mqtt message

## ---------------------------------------------------
## SENSOR COMPONENTS
## ---------------------------------------------------
sensor:

  # Wifi quality RSSI (%)
  - platform: wifi_signal
    name: "Device WLAN Signal"
    id: wifisignaldb
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    entity_category: "diagnostic"
    unit_of_measurement: "%"

  # device internal temperature (only webserver)
  - platform: internal_temperature
    name: Internal Temperature
    id: device_internal_temperature
    icon: mdi:thermometer-lines
    update_interval: 60s
    entity_category: "diagnostic"
    disabled_by_default: true

  # Device uptime in hours
  - platform: uptime
    name: Online seit
    filters:
      - lambda: return x / 3600;
    unit_of_measurement: "h"
    entity_category: "diagnostic"
    state_class: "measurement"
    accuracy_decimals: 2
    icon: mdi:clock-start

  # number of boots
  - platform: template
    name: "Boot Counter"
    id: bootcounter
    accuracy_decimals: 0
    entity_category: "diagnostic"
    state_class: "measurement"
    icon: mdi:counter
    lambda: return (id(boot_counter));

## ---------------------------------------------------
## TEXT SENSORS
## ---------------------------------------------------
text_sensor:

   # Last boot timestamp (only on webserver)
  - platform: template
    name: "Last Boot Time"
    id: device_lastBoot_time
    disabled_by_default: true
    icon: mdi:clock-start

  # Device timestamp
  - platform: template
    name: Device Timestamp
    id: systime
    entity_category: "diagnostic"
    lambda: return id(time_sntp).now().strftime("%Y-%m-%dT%H:%M:%S %Z");

  # Current ESPHome Version
  - platform: version
    name: Device ESPHome Version
    id: appver
    hide_timestamp: true
    entity_category: "diagnostic"
    disabled_by_default: true

  # connected to ssid
  - platform: wifi_info
    ssid:
      name: "Device WLAN SSID"
      id: Devicessid
      entity_category: "diagnostic"
      disabled_by_default: true # no mqtt message

Anything in the logs that might be useful for us?

Processing mqtt-test (board: az-delivery-devkit-v4; framework: arduino; platform: espressif32)
HARDWARE: ESP32 240MHz, 520KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- ArduinoJson @ 6.18.5
Compiling .pioenvs/mqtt-test/src/esphome/components/restart/switch/restart_switch.cpp.o
Compiling .pioenvs/mqtt-test/src/esphome/components/safe_mode/switch/safe_mode_switch.cpp.o
Compiling .pioenvs/mqtt-test/src/esphome/components/template/sensor/template_sensor.cpp.o
Compiling .pioenvs/mqtt-test/src/esphome/components/template/switch/template_switch.cpp.o
Compiling .pioenvs/mqtt-test/src/main.cpp.o
Linking .pioenvs/mqtt-test/firmware.elf
RAM:   [=         ]  10.3% (used 55072 bytes from 532480 bytes)
Flash: [========= ]  94.2% (used 1728593 bytes from 1835008 bytes)

Building .pioenvs/mqtt-test/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/mqtt-test/firmware.bin"], [".pioenvs/mqtt-test/firmware.elf"])
Wrote 0x1b76e0 bytes to file /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.pioenvs/mqtt-test/firmware-factory.bin, ready to flash to offset 0x0
======================================================================= [SUCCESS] Took 33.40 seconds =======================================================================
INFO Successfully compiled program.
Found multiple options for uploading, please choose one:
  [1] /dev/cu.SLAB_USBtoUART (CP2102 USB to UART Bridge Controller)
  [2] Over The Air (mqtt-test.local)
(number): 1

esptool.py v4.6.2
Serial port /dev/cu.SLAB_USBtoUART
Connecting....
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 08:3a:f2:ac:d8:1c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00010000 to 0x001b7fff...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Compressed 1734368 bytes to 1140762...
Wrote 1734368 bytes (1140762 compressed) at 0x00010000 in 26.6 seconds (effective 522.0 kbit/s)...
Hash of data verified.
Compressed 17440 bytes to 12128...
Wrote 17440 bytes (12128 compressed) at 0x00001000 in 0.6 seconds (effective 240.1 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 144...
Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.1 seconds (effective 324.6 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 540.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/cu.SLAB_USBtoUART with baud rate 115200

[15:37:06][I][logger:268]: Log initialized
[15:37:06][C][ota:473]: There have been 2 suspected unsuccessful boot attempts.
[15:37:06][D][esp32.preferences:114]: Saving 1 preferences to flash...
[15:37:06][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[15:37:06][I][app:029]: Running through setup()...
[15:37:06][D][template.switch:046]:   Restored state OFF
[15:37:06][D][switch:016]: 'Boot Counter reset' Turning OFF.
[15:37:06][W][system:415]: BOOTMESSAGE: mqtt-test API is connected, Device ready!
[15:37:06][D][sensor:094]: 'Boot Counter': Sending state 2.00000  with 0 decimals of accuracy
[15:37:06][D][binary_sensor:034]: 'Device Status': Sending initial state OFF
[15:37:06][D][text_sensor:064]: 'Device ESPHome Version': Sending state '2023.9.0b2'
[15:37:06][C][esp32_ble:027]: Setting up BLE...
[15:37:07][D][esp32_ble:043]: BLE setup complete
[15:37:07][D][esp32_ble_tracker:246]: Starting scan...
[15:37:07][C][wifi:038]: Setting up WiFi...
[15:37:07][C][wifi:051]: Starting WiFi...
[15:37:07][C][wifi:052]:   Local MAC: 08:3A:F2:AC:D8:1C
[15:37:07][D][wifi:428]: Starting scan...
[15:37:07][D][sensor:094]: 'Boot Counter': Sending state 2.00000  with 0 decimals of accuracy
[15:37:07][D][text_sensor:064]: 'Device Timestamp': Sending state '1970-01-01T00:00:00 GMT'
[15:37:07][D][sensor:094]: 'Online seit': Sending state 0.00025 h with 2 decimals of accuracy
[15:37:07][D][sensor:094]: 'Internal Temperature': Sending state 47.77778 °C with 1 decimals of accuracy
[15:37:10][D][wifi:443]: Found networks:
[15:37:10][I][wifi:487]: - 'McYoda' (*******) ▂▄▆█
[15:37:10][D][wifi:488]:     Channel: 1
[15:37:10][D][wifi:489]:     RSSI: -49 dB
[15:37:10][I][wifi:487]: - 'Lan Solo' ((*******)) ▂▄▆█
[15:37:10][D][wifi:488]:     Channel: 11
[15:37:10][D][wifi:489]:     RSSI: -62 dB
[15:37:10][I][wifi:487]: - 'McNessi' ((*******)) ▂▄▆█
[15:37:10][D][wifi:488]:     Channel: 6
[15:37:10][D][wifi:489]:     RSSI: -73 dB
[15:37:10][I][wifi:487]: - 'Lan Solo' ((*******)) ▂▄▆█
[15:37:10][D][wifi:488]:     Channel: 1
[15:37:10][D][wifi:489]:     RSSI: -95 dB
[15:37:10][D][wifi:492]: - 'DuDuDuNet' ((*******)) ▂▄▆█
[15:37:10][D][wifi:492]: - 'Honeypot' ((*******)) ▂▄▆█
[15:37:10][D][wifi:492]: - 'Microwelle' ((*******)) ▂▄▆█
[15:37:10][D][wifi:492]: - '' ((*******)) ▂▄▆█
[15:37:10][D][wifi:492]: - '' ((*******)) ▂▄▆█
[15:37:10][D][wifi:492]: - 'Ludwig' ((*******)) ▂▄▆█
[15:37:10][I][wifi:277]: WiFi Connecting to 'McYoda'...
[15:37:11][I][wifi:560]: WiFi Connected!
[15:37:11][C][wifi:382]:   Local MAC: *************
[15:37:11][C][wifi:383]:   SSID: 'McYoda'
[15:37:11][C][wifi:384]:   IP Address: ***********
[15:37:11][C][wifi:386]:   BSSID: ***********
[15:37:11][C][wifi:387]:   Hostname: 'mqtt-test'
[15:37:11][C][wifi:389]:   Signal strength: -53 dB ▂▄▆█
[15:37:11][C][wifi:393]:   Channel: 1
[15:37:11][C][wifi:394]:   Subnet: 255.255.255.0
[15:37:11][C][wifi:395]:   Gateway: ***********
[15:37:11][C][wifi:396]:   DNS1: ***********
[15:37:11][C][wifi:397]:   DNS2: ***********
[15:37:11][D][wifi:569]: Disabling AP...
[15:37:11][C][web_server:116]: Setting up web server...
[15:37:11][C][sntp:028]: Setting up SNTP...
[15:37:11][C][ota:097]: Over-The-Air Updates:
[15:37:11][C][ota:098]:   Address: mqtt-test.local:3232
[15:37:11][C][ota:101]:   Using Password.
[15:37:11][W][ota:107]: Last Boot was an unhandled reset, will proceed to safe mode in 8 restarts
[15:37:11][C][mqtt:037]: Setting up MQTT...
[15:37:11][I][mqtt:239]: Connecting to MQTT...
[15:37:11][I][mqtt:279]: MQTT Connected!
[15:37:14]
[15:37:14]abort() was called at PC 0x401fccbf on core 0
[15:37:14]
[15:37:14]
[15:37:14]Backtrace:0x40083829:0x3ffd7dc00x4009491d:0x3ffd7de0 0x40099ee1:0x3ffd7e00 0x401fccbf:0x3ffd7e80 0x401fcd06:0x3ffd7ea0 0x401fcc67:0x3ffd7ec0 0x401fb95e:0x3ffd7ee0 0x400d4c19:0x3ffd7f00 0x4011ed59:0x3ffd7f20 0x40145d1d:0x3ffd7f40 0x40147b77:0x3ffd7f60
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x40083829: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
WARNING Decoded 0x4009491d: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
WARNING Decoded 0x40099ee1: abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46
WARNING Decoded 0x401fccbf: __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
WARNING Decoded 0x401fcd06: std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
WARNING Decoded 0x401fcc67: __cxa_throw at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
WARNING Decoded 0x401fb95e: operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54
WARNING Decoded 0x400d4c19: esphome::esp32_ble::ESP32BLE::gap_event_handler(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t*) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/components/esp32_ble/ble.cpp:173
WARNING Decoded 0x4011ed59: btc_gap_ble_cb_to_app at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c:55
 (inlined by) btc_gap_ble_cb_handler at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c:1156
WARNING Decoded 0x40145d1d: btc_thread_handler at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/common/btc/core/btc_task.c:196
WARNING Decoded 0x40147b77: osi_thread_run at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/common/osi/thread.c:68
[15:37:15]
[15:37:15]
[15:37:15]
[15:37:15]
[15:37:15]ELF file SHA256: 0000000000000000
[15:37:15]
[15:37:15]Rebooting...
[15:37:15]ets Jun  8 2016 00:22:57
[15:37:15]
[15:37:15]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[15:37:15]configsip: 0, SPIWP:0xee
[15:37:15]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[15:37:15]mode:DIO, clock div:2
[15:37:15]load:0x3fff0030,len:1184
[15:37:15]load:0x40078000,len:13132
[15:37:15]load:0x40080400,len:3036
[15:37:15]entry 0x400805e4
....
15:43:24]Backtrace:0x40083829:0x3ffd7dc00x4009491d:0x3ffd7de0 0x40099ee1:0x3ffd7e00 0x401fccbf:0x3ffd7e80 0x401fcd06:0x3ffd7ea0 0x401fcc67:0x3ffd7ec0 0x401fb95e:0x3ffd7ee0 0x400d4c19:0x3ffd7f00 0x4011ed59:0x3ffd7f20 0x40145d1d:0x3ffd7f40 0x40147b77:0x3ffd7f60
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x40083829: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
WARNING Decoded 0x4009491d: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
WARNING Decoded 0x40099ee1: abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46
WARNING Decoded 0x401fccbf: __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
WARNING Decoded 0x401fcd06: std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
WARNING Decoded 0x401fcc67: __cxa_throw at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
WARNING Decoded 0x401fb95e: operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54
WARNING Decoded 0x400d4c19: esphome::esp32_ble::ESP32BLE::gap_event_handler(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t*) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/components/esp32_ble/ble.cpp:173
WARNING Decoded 0x4011ed59: btc_gap_ble_cb_to_app at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c:55
 (inlined by) btc_gap_ble_cb_handler at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c:1156
WARNING Decoded 0x40145d1d: btc_thread_handler at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/common/btc/core/btc_task.c:196
WARNING Decoded 0x40147b77: osi_thread_run at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/bt/common/osi/thread.c:68
[15:43:24]
....
[15:43:30]
[15:43:30]Backtrace:0x40083829:0x3ffcdc500x4009491d:0x3ffcdc70 0x40099ee1:0x3ffcdc90 0x401fccbf:0x3ffcdd10 0x401fcd06:0x3ffcdd30 0x401fcc67:0x3ffcdd50 0x401fb95e:0x3ffcdd70 0x401fc159:0x3ffcdd90 0x401fc29c:0x3ffcddb0 0x401fc419:0x3ffcddf0 0x400d631f:0x3ffcde10 0x400d636c:0x3ffcde30 0x400d6570:0x3ffcde50 0x400d66d3:0x3ffcde70 0x400d8fdb:0x3ffcdef0 0x400d9b87:0x3ffcdf30 0x400d9bcf:0x3ffcdf80 0x40215b1d:0x3ffcdfa0 0x400e31e8:0x3ffcdfc0 0x400e6eea:0x3ffcdff0 0x400f0c52:0x3ffce110
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x40083829: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
WARNING Decoded 0x4009491d: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
WARNING Decoded 0x40099ee1: abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46
WARNING Decoded 0x401fccbf: __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
WARNING Decoded 0x401fcd06: std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
WARNING Decoded 0x401fcc67: __cxa_throw at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
WARNING Decoded 0x401fb95e: operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54
WARNING Decoded 0x401fc159: __gnu_cxx::new_allocator<char>::allocate(unsigned int, void const*) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/ext/new_allocator.h:111
 (inlined by) std::allocator_traits<std::allocator<char> >::allocate(std::allocator<char>&, unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/alloc_traits.h:436
 (inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned int&, unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.tcc:153
WARNING Decoded 0x401fc29c: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned int, unsigned int, char const*, unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.tcc:317
WARNING Decoded 0x401fc419: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::push_back(char) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/no-rtti/libstdc++-v3/include/bits/basic_string.h:1353
WARNING Decoded 0x400d631f: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator+=(char) at /Users/petsie1612/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.h:1188
 (inlined by) ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void>::write(unsigned char) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Serialization/Writers/StdStringWriter.hpp:28
 (inlined by) ArduinoJson6185_D1::CountingDecorator<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::write(unsigned char) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp:17
WARNING Decoded 0x400d636c: ArduinoJson6185_D1::TextFormatter<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::writeRaw(char) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp:153
 (inlined by) ArduinoJson6185_D1::TextFormatter<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::writeString(char const*) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp:41
WARNING Decoded 0x400d6570: ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::visitObject(ArduinoJson6185_D1::CollectionData const&) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp:46
 (inlined by) ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::result_type ArduinoJson6185_D1::VariantData::accept<ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> > >(ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >&) const at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Variant/VariantData.hpp:49
WARNING Decoded 0x400d66d3: ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::result_type ArduinoJson6185_D1::variantAccept<ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> > >(ArduinoJson6185_D1::VariantData const*, ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >&) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Variant/VariantFunctions.hpp:16
 (inlined by) ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::result_type ArduinoJson6185_D1::VariantConstRef::accept<ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> > >(ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >&) const at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Variant/VariantRef.hpp:245
 (inlined by) ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >::result_type ArduinoJson6185_D1::JsonDocument::accept<ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> > >(ArduinoJson6185_D1::JsonSerializer<ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >&) const at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp:20
 (inlined by) unsigned int ArduinoJson6185_D1::doSerialize<ArduinoJson6185_D1::JsonSerializer, ArduinoJson6185_D1::BasicJsonDocument<ArduinoJson6185_D1::DefaultAllocator>, ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void> >(ArduinoJson6185_D1::BasicJsonDocument<ArduinoJson6185_D1::DefaultAllocator> const&, ArduinoJson6185_D1::Writer<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void>) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp:15
 (inlined by) unsigned int ArduinoJson6185_D1::serialize<ArduinoJson6185_D1::JsonSerializer, ArduinoJson6185_D1::BasicJsonDocument<ArduinoJson6185_D1::DefaultAllocator>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(ArduinoJson6185_D1::BasicJsonDocument<ArduinoJson6185_D1::DefaultAllocator> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Serialization/serialize.hpp:22
 (inlined by) unsigned int ArduinoJson6185_D1::serializeJson<ArduinoJson6185_D1::BasicJsonDocument<ArduinoJson6185_D1::DefaultAllocator>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(ArduinoJson6185_D1::BasicJsonDocument<ArduinoJson6185_D1::DefaultAllocator> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/.piolibdeps/mqtt-test/ArduinoJson/src/ArduinoJson/Json/JsonSerializer.hpp:115
 (inlined by) esphome::json::build_json[abi:cxx11](std::function<void (ArduinoJson6185_D1::ObjectRef)> const&) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/components/json/json_util.cpp:60
WARNING Decoded 0x400d8fdb: esphome::mqtt::MQTTClientComponent::publish_json(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void (ArduinoJson6185_D1::ObjectRef)> const&, unsigned char, bool) at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/components/mqtt/mqtt_client.cpp:490
WARNING Decoded 0x400d9b87: esphome::mqtt::MQTTComponent::send_discovery_() at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/components/mqtt/mqtt_component.cpp:64
WARNING Decoded 0x400d9bcf: esphome::mqtt::MQTTComponent::call_setup() at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/components/mqtt/mqtt_component.cpp:200
 (inlined by) esphome::mqtt::MQTTComponent::call_setup() at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/components/mqtt/mqtt_component.cpp:188
WARNING Decoded 0x40215b1d: esphome::Component::call() at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/core/component.cpp:98
WARNING Decoded 0x400e31e8: esphome::Application::setup() at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/src/esphome/core/application.cpp:38
WARNING Decoded 0x400e6eea: setup() at /Users/petsie1612/ips_apps/esphome-lab/.esphome/build/mqtt-test/mqtt-test.yaml:55 (discriminator 1)
WARNING Decoded 0x400f0c52: loopTask(void*) at /Users/petsie1612/.platformio/packages/framework-arduinoespressif32@3.20005.220925/cores/esp32/main.cpp:42
[15:43:31]
[15:43:31]
[15:43:31]
[15:43:31]
[15:43:31]ELF file SHA256: 0000000000000000
[15:43:31]
[15:43:31]Rebooting...
[15:43:31]ets Jun  8 2016 00:22:57
[15:43:31]
[15:43:31]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[15:43:31]configsip: 0, SPIWP:0xee
[15:43:31]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[15:43:31]mode:DIO, clock div:2
[15:43:31]load:0x3fff0030,len:1184
[15:43:31]load:0x40078000,len:13132
[15:43:31]load:0x40080400,len:3036
[15:43:31]entry 0x400805e4

Additional information

Linking .pioenvs/mqtt-test/firmware.elf RAM: [= ] 10.3% (used 55072 bytes from 532480 bytes) Flash: [========= ] 94.2% (used 1728593 bytes from 1835008 bytes) ???

zibous commented 9 months ago

Device

Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
Auto-detected Flash size: 4MB

Testcases

MQTT API ESP32_BLE_TRACKER RAM FLASH STATE
✔︎ yes ✘ no ✔︎ yes 10.30% 94.20% ✘ ERROR !!
✔︎ yes ✘ no ✘ no 8.00% 56.60% ✔︎ WORKING
✘ no ✔︎ yes ✔︎ yes 10.20% 90.50% ✔︎ WORKING
✘ no ✔︎ yes ✘ no 7.90% 52.90% ✔︎ WORKING

Result: mqtt + esp32_ble_tracker do not work !!!

esphome:2022.12.8 mqtt + ESP32_BLE_TRACKER

docker run --rm -v "${PWD}":/config -it esphome/esphome:2022.12.8 compile mqtt-test.yaml

RAM:   [=         ]  10.2% (used 54380 bytes from 532480 bytes)
Flash: [========= ]  86.6% (used 1589513 bytes from 1835008 bytes)

Is working w/o any errors.

michaelscl commented 6 months ago

I have the same chip. Today I accidentally found out that my ESP has been malfunctioning for a few months. The problem is the same.The kernel crashes and ESP reboots constantly. I had to do a downgrade to 2022.12.8 where everything really works. What can I do to get the bug fixed in the latest version 2023.12.3 ?

Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
Auto-detected Flash size: 4MB

esp32:
  board: "denky32"
ssieb commented 6 months ago

If it's the same error as pasted earlier, it's running out of RAM.

michaelscl commented 6 months ago

Today, I found some more information and set it up:

esp32:
  board: esp32dev
  framework:
    type: arduino

With this setting it is now OK. ESP is not resetting!

And if someone has a problem with BLE + MQTT, you need to disable web_server.

Now everything is working.

davidsarkany commented 4 months ago

Same issue with 2024.2.1, I got panic with enabled web_server I don't have problem with 2023.4.1.

My config:

esphome:
  name: esp

esp32:
  board: lolin32_lite
  framework:
    type: arduino

captive_portal:

logger:

api:
  password: !secret ApiPassword

wifi:
  ssid: !secret WifiSsid
  password: !secret WifiPassword
  ap:
    ssid: !secret FallbackWifiSsid
    password: !secret FallbackWifiPassword

mqtt:
  broker: !secret MqttBroker
  username: !secret MqttUsername
  password: !secret MqttPassword
  port: !secret MqttPort

ota:
  password: !secret OtaPassword

esp32_ble_tracker:

sensor:
  - platform: atc_mithermometer
    mac_address: "XX:XX:XX:XX:XX:XX"
    temperature:
      id: livingroom_temperature
      name: "Livingroom temperature"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/livingroom_temperature"
            payload: !lambda |-
              return to_string(id(livingroom_temperature).state);
    humidity:
      id: livingroom_humidity
      name: "Livingroom humidity"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/livingroom_humidity"
            payload: !lambda |-
              return to_string(id(livingroom_humidity).state);
    battery_level:
      id: livingroom_battery
      name: "Livingroom battery"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/livingroom_battery"
            payload: !lambda |-
              return to_string(id(livingroom_battery).state);

  - platform: atc_mithermometer
    mac_address: "XX:XX:XX:XX:XX:XX"
    temperature:
      id: bed_room_temperature
      name: "Bed room temperature"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/bed_room_temperature"
            payload: !lambda |-
              return to_string(id(bed_room_temperature).state);
    humidity:
      id: bed_room_humidity
      name: "Bed room humidity"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/bed_room_humidity"
            payload: !lambda |-
              return to_string(id(bed_room_humidity).state);
    battery_level:
      id: bed_room_battery
      name: "Bed room battery"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/bed_room_battery"
            payload: !lambda |-
              return to_string(id(bed_room_battery).state);

  - platform: atc_mithermometer
    mac_address: "XX:XX:XX:XX:XX:XX"
    temperature:
      id: outdoor_temperature
      name: "Outdoor temperature"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/outdoor_temperature"
            payload: !lambda |-
              return to_string(id(outdoor_temperature).state);
    humidity:
      id: outdoor_humidity
      name: "Outdoor humidity"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/outdoor_humidity"
            payload: !lambda |-
              return to_string(id(outdoor_humidity).state);
    battery_level:
      id: outdoor_battery
      name: "Outdoor battery"
      filters:
        - throttle: 1s
        - heartbeat: 30s
        - debounce: 0.1s
      on_value:
        - mqtt.publish:
            topic: "sensor/outdoor_battery"
            payload: !lambda |-
              return to_string(id(outdoor_battery).state);

button:
  - platform: wake_on_lan
    id: "start_pc_button"
    name: "Start PC"
    target_mac_address: XX:XX:XX:XX:XX:XX
ssieb commented 4 months ago

@davidsarkany the answers have already been given.