esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
292 stars 36 forks source link

ESP32-C6 crashes at runtime while using I2C #6365

Open rvalitov opened 1 month ago

rvalitov commented 1 month ago

The problem

I'm using ESP32-C6 with bh1750 sensor. It needs I2C. Enabling I2C leads to regular continuous runtime crashes. The watchdog restarts the device, but it crashes again.

Which version of ESPHome has the issue?

2024.10.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32-IDF

Board

esp32-c6-devkitc-1

Component causing the issue

i2c

Example YAML snippet

esphome:
  name: garage_sensors
  friendly_name: Garage Sensors
  platformio_options:
    board_build.flash_mode: dio 

esp32:
  board: esp32-c6-devkitc-1
  variant: ESP32C6
  flash_size: 8MB
  framework:
    type: esp-idf
    version: 5.3.1
    platform_version: 6.9.0
    sdkconfig_options:
      CONFIG_ESPTOOLPY_FLASHSIZE_8MB: y
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
      CONFIG_ESP_TASK_WDT: y
      CONFIG_ESP_TASK_WDT_TIMEOUT_S: "10"
      CONFIG_OPENTHREAD_ENABLED: n
      CONFIG_ENABLE_WIFI_STATION: y
      CONFIG_USE_MINIMAL_MDNS: y

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: ""

wifi:
  ssid: ""
  password: ""

i2c:
  sda: 6
  scl: 7
  scan: true

sensor:
  - platform: bh1750
    name: "Illuminance"
    address: 0x23
    update_interval: 30s

Anything in the logs that might be useful for us?

esptool.py v4.7.0
Serial port COM7
Connecting...
Chip is ESP32-C6 (QFN40) (revision v0.1)
Features: WiFi 6, BT 5, IEEE802.15.4
Crystal is 40MHz
MAC: f0:f5:bd:ff:fe:0b:f2:24
BASE MAC: f0:f5:bd:0b:f2:24
MAC_EXT: ff:fe
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 16MB
Flash will be erased from 0x00010000 to 0x0011dfff...
Flash will be erased from 0x00000000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00009000 to 0x0000afff...
Compressed 1104480 bytes to 679397...
Wrote 1104480 bytes (679397 compressed) at 0x00010000 in 7.0 seconds (effective 1264.0 kbit/s)...
Hash of data verified.
Warning: Image file at 0x0 is protected with a hash checksum, so not changing the flash size setting. Use the --flash_size=keep option instead of --flash_size=16MB in order to remove this warning, or use the --dont-append-digest option for the elf2image command in order to generate an image file without a hash checksum
Compressed 21728 bytes to 13094...
Wrote 21728 bytes (13094 compressed) at 0x00000000 in 0.5 seconds (effective 355.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 134...
Wrote 3072 bytes (134 compressed) at 0x00008000 in 0.1 seconds (effective 325.9 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 31...
Wrote 8192 bytes (31 compressed) at 0x00009000 in 0.1 seconds (effective 498.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from COM7 with baud rate 115200
[18:43:24] (103) esp_image: segment 0: paddr=00010020 vaddr=420c0020 size=350ach (217260) map
[18:43:24]I (156) esp_image: segment 1: paddr=000450d4 vaddr=40800000 size=0af44h ( 44868) load
[18:43:24]I (167) esp_image: segment 2: paddr=00050020 vaddr=42000020 size=bc1b8h (770488) map
[18:43:24]I (327) esp_image: segment 3: paddr=0010c1e0 vaddr=4080af44 size=0dc48h ( 56392) load
[18:43:24]I (341) esp_image: segment 4: paddr=00119e30 vaddr=40818b90 size=03c0ch ( 15372) load
[18:43:24]I (352) boot: Loaded app from partition at offset 0x10000
[18:43:24]I (410) boot: Set actual ota_seq=1 in otadata[0]
[18:43:24]I (410) boot: Disabling RNG early entropy source...
[18:43:24]I (421) cpu_start: Unicore app
[18:43:24]I (429) cpu_start: Pro cpu start user code
[18:43:24]I (430) cpu_start: cpu freq: 160000000 Hz
[18:43:24]I (430) app_init: Application information:
[18:43:24]I (432) app_init: Project name:     garage_sensors
[18:43:24]I (438) app_init: App version:      2024.10.1
[18:43:24]I (443) app_init: Compile time:     Oct 22 2024 18:38:27
[18:43:24]I (449) app_init: ELF file SHA256:  5bf088987...
[18:43:24]I (454) app_init: ESP-IDF:          5.3.1
[18:43:24]I (459) efuse_init: Min chip rev:     v0.0
[18:43:24]I (464) efuse_init: Max chip rev:     v0.99
[18:43:24]I (469) efuse_init: Chip rev:         v0.1
[18:43:24]I (473) heap_init: Initializing. RAM available for dynamic allocation:
[18:43:24]I (481) heap_init: At 40821FF0 len 0005A620 (361 KiB): RAM
[18:43:24]I (487) heap_init: At 4087C610 len 00002F54 (11 KiB): RAM
[18:43:24]I (493) heap_init: At 50000000 len 00003FE8 (15 KiB): RTCRAM
[18:43:24]I (500) spi_flash: detected chip: generic
[18:43:24]I (504) spi_flash: flash io: dio
[18:43:24]W (508) spi_flash: Detected size(16384k) larger than the size in the binary image header(8192k). Using the size in the binary image header.
[18:43:24]W (521) tsens: legacy driver is deprecated, please migrate to `driver/temperature_sensor.h`
[18:43:24]W (530) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
[18:43:24]W (541) i2c: This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`
[18:43:24]I (551) sleep: Configure to isolate all GPIO pins in sleep state
[18:43:24]I (558) sleep: Enable automatic switching of GPIO sleep configuration
[18:43:24]I (565) coexist: coex firmware version: 4482466
[18:43:24]I (571) coexist: coexist rom version 5b8dcfa
[18:43:24]I (576) main_task: Started on CPU0
[18:43:24]I (579) main_task: Calling app_main()
[18:43:24]I (683) main_task: Returned from app_main()
[18:43:34]E (10697) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
[18:43:34]E (10697) task_wdt:  - loopTask (CPU 0)
[18:43:34]E (10697) task_wdt: Tasks currently running:
[18:43:34]E (10697) task_wdt: CPU 0: loopTask
[18:43:34]E (10697) task_wdt: Aborting.
[18:43:34]
[18:43:34]
[18:43:34]Core  0 register dump:
[18:43:34]MEPC    : 0x420311dc  RA      : 0x420322ea  SP      : 0x4082a450  GP      : 0x40819394
WARNING Decoded 0x420311dc: i2c_ll_master_clr_bus at C:\Users\Ram\.platformio\packages\framework-espidf\components\hal\esp32c6\include/hal/i2c_ll.h:767 (discriminator 1)
 (inlined by) i2c_master_clear_bus at C:\Users\Ram\.platformio\packages\framework-espidf\components\driver\i2c/i2c.c:687 (discriminator 1)
 (inlined by) i2c_hw_fsm_reset at C:\Users\Ram\.platformio\packages\framework-espidf\components\driver\i2c/i2c.c:719 (discriminator 1)
WARNING Decoded 0x420311dc: i2c_ll_master_clr_bus at C:\Users\Ram\.platformio\packages\framework-espidf\components\hal\esp32c6\include/hal/i2c_ll.h:767 (discriminator 1)
 (inlined by) i2c_master_clear_bus at C:\Users\Ram\.platformio\packages\framework-espidf\components\driver\i2c/i2c.c:687 (discriminator 1)
 (inlined by) i2c_hw_fsm_reset at C:\Users\Ram\.platformio\packages\framework-espidf\components\driver\i2c/i2c.c:719 (discriminator 1)
[18:43:35]TP      : 0x4082a570  T0      : 0x00000000  T1      : 0x400005d0  T2      : 0x3b305b1b
[18:43:35]S0/FP   : 0x00000000  S1      : 0x4082b980  A0      : 0x00000000  A1      : 0x40824de4
[18:43:35]A2      : 0x00000001  A3      : 0x00000800  A4      : 0x00000013  A5      : 0x60004000
[18:43:35]A6      : 0x00000004  A7      : 0x00000014  S2      : 0x00000000  S3      : 0x000000b8
[18:43:35]S4      : 0x00000014  S5      : 0x000000a4  S6      : 0x000003e8  S7      : 0x00000002
[18:43:35]S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000
[18:43:35]T3      : 0x40822000  T4      : 0x00000001  T5      : 0x40822000  T6      : 0x00000001
[18:43:35]MSTATUS : 0x00000000  MTVEC   : 0x00000000  MCAUSE  : 0x4082baa0  MTVAL   : 0x00000001
[18:43:35]MHARTID : 0x420d9000
[18:43:35]
[18:43:35]Stack memory:
[18:43:35]4082a450: 0x00000000 0x00000000 0x4082baa0 0x00000001 0x420d9000 0x00000000 0x00000001 0x40824780
[18:43:35]4082a470: 0x00000000 0x00000000 0x4082baa0 0x4200ce34 0x00000000 0x00000001 0x00000006 0x00000078
[18:43:35]4082a490: 0x40824784 0x40824780 0x00000011 0x4200cfb0 0x00000001 0x40821cb4 0x40818c7c 0x4011a4c0
[18:43:35]4082a4b0: 0x420d9000 0x00000008 0x420c4000 0x40824794 0x00000001 0x420c2000 0x40824780 0x4200d2ea
[18:43:35]4082a4d0: 0x4081c7b8 0x00000001 0x00000006 0x00000007 0x00000101 0x0000c350 0x00000000 0x00000000
[18:43:35]4082a4f0: 0x00000001 0x40824df0 0x4081c7b8 0x42020e02 0x00000000 0x0000000f 0x0000000f 0x4082b980
[18:43:35]4082a510: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a530: 0x00000000 0x00000000 0x00000000 0x4200a40e 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a550: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
[18:43:35]4082a570: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000150 0x4082a3d0 0x000000b8 0x4081d248
[18:43:35]4082a590: 0x4081d248 0x4082a584 0x4081d240 0x00000018 0x4082ba74 0x4082ba74 0x4082a584 0x00000000
[18:43:35]4082a5b0: 0x00000001 0x40828580 0x706f6f6c 0x6b736154 0x00000000 0x00000000 0x4082a570 0x00000001
[18:43:35]4082a5d0: 0x00000001 0x00000000 0x00000000 0x00000000 0x40822aec 0x40822b54 0x40822bbc 0x00000000
[18:43:35]4082a5f0: 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x42058152 0x00000000 0x00000000
[18:43:35]4082a610: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a630: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a650: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a670: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a690: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a6b0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a6d0: 0x00000000 0x00000010 0x00000000 0x4082a584 0x00000000 0x00000000 0x00000048 0x420d88e8
[18:43:35]4082a6f0: 0x00000001 0x7fc00000 0x420c2960 0x0001c200 0x4082a738 0x00000043 0x00000200 0x00000000
[18:43:35]4082a710: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
[18:43:35]4082a730: 0x4082a584 0x00000204 0x3b305b1b 0x5b6d3733 0x695b5d56 0x692e6332 0x303a6664 0x3a5d3037
[18:43:35]4082a750: 0x61635320 0x6e696e6e 0x32692067 0x75622063 0x6f662073 0x63612072 0x65766974 0x76656420
[18:43:35]4082a770: 0x73656369 0x1b2e2e2e 0x006d305b 0x75707475 0x3a6e4574 0x207c3120 0x6e65704f 0x69617244
[18:43:35]4082a790: 0x31203a6e 0x7550207c 0x70756c6c 0x7c31203a 0x6c755020 0x776f646c 0x30203a6e 0x6e49207c
[18:43:35]4082a7b0: 0x303a7274 0x305b1b20 0x5b1b0a6d 0x3b006d30 0x5b6d3633 0x655b5d44 0x32337073 0x6572702e
[18:43:35]4082a7d0: 0x65726566 0x7365636e 0x3234313a 0x53203a5d 0x6e697661 0x20312067 0x66657270 0x6e657265
[18:43:35]4082a7f0: 0x20736563 0x66206f74 0x6873616c 0x2031203a 0x68636163 0x202c6465 0x72772030 0x65747469
[18:43:35]4082a810: 0x30202c6e 0x69616620 0x1b64656c 0x006d305b 0x34312e32 0x6d202c38 0x3a6b7361 0x35353220
[18:43:35]4082a830: 0x3535322e 0x3535322e 0x202c302e 0x203a7767 0x2e323931 0x2e383631 0x1b312e32 0x0a6d305b
[18:43:35]
[18:43:35]
[18:43:35]
[18:43:35]ELF file SHA256: 5bf088987
[18:43:35]
[18:43:35]Rebooting...
[18:43:35]ESP-ROM:esp32c6-20220919
[18:43:35]Build:Sep 19 2022
[18:43:35]rst:0xc (SW_CPU),boot:0x3e (SPI_FAST_FLASH_BOOT)
[18:43:35]Saved PC:0x4001975a
[18:43:35]SPIWP:0xee
[18:43:35]mode:DIO, clock div:2
[18:43:35]load:0x4086c110,len:0xe2c
[18:43:35]load:0x4086e610,len:0x2e58
[18:43:35]load:0x40875720,len:0x1804
[18:43:35]entry 0x4086c110
[18:43:35]I (22) boot: ESP-IDF 5.3.1 2nd stage bootloader
[18:43:35]I (22) boot: compile time Oct 22 2024 18:39:44
[18:43:35]I (24) boot: chip revision: v0.1
[18:43:35]I (25) boot.esp32c6: SPI Speed      : 80MHz
[18:43:35]I (29) boot.esp32c6: SPI Mode       : DIO
[18:43:35]I (34) boot.esp32c6: SPI Flash Size : 8MB
[18:43:35]I (39) boot: Enabling RNG early entropy source...
[18:43:35]I (44) boot: Partition Table:
[18:43:35]I (48) boot: ## Label            Usage          Type ST Offset   Length
[18:43:35]I (55) boot:  0 otadata          OTA data         01 00 00009000 00002000
[18:43:35]I (63) boot:  1 phy_init         RF data          01 01 0000b000 00001000
[18:43:35]I (70) boot:  2 app0             OTA app          00 10 00010000 003c0000
[18:43:35]I (78) boot:  3 app1             OTA app          00 11 003d0000 003c0000
[18:43:35]I (85) boot:  4 nvs              WiFi data        01 02 00790000 0006d000
[18:43:35]I (93) boot: End of partition table
[18:43:35]I (97) esp_image: segment 0: paddr=00010020 vaddr=420c0020 size=350ach (217260) map
[18:43:35]I (194) esp_image: segment 1: paddr=000450d4 vaddr=40800000 size=0af44h ( 44868) load
[18:43:35]I (216) esp_image: segment 2: paddr=00050020 vaddr=42000020 size=bc1b8h (770488) map
[18:43:35]I (531) esp_image: segment 3: paddr=0010c1e0 vaddr=4080af44 size=0dc48h ( 56392) load
[18:43:35]I (559) esp_image: segment 4: paddr=00119e30 vaddr=40818b90 size=03c0ch ( 15372) load
[18:43:35]I (579) boot: Loaded app from partition at offset 0x10000
[18:43:35]I (580) boot: Disabling RNG early entropy source...
[18:43:35]I (592) cpu_start: Unicore app
[18:43:35]I (601) cpu_start: Pro cpu start user code
[18:43:35]I (601) cpu_start: cpu freq: 160000000 Hz
[18:43:35]I (601) app_init: Application information:
[18:43:35]I (604) app_init: Project name:     garage_sensors
[18:43:35]I (609) app_init: App version:      2024.10.1
[18:43:35]I (614) app_init: Compile time:     Oct 22 2024 18:38:27
[18:43:35]I (620) app_init: ELF file SHA256:  5bf088987...
[18:43:35]I (625) app_init: ESP-IDF:          5.3.1
[18:43:35]I (630) efuse_init: Min chip rev:     v0.0
[18:43:35]I (635) efuse_init: Max chip rev:     v0.99
[18:43:35]I (640) efuse_init: Chip rev:         v0.1
[18:43:35]I (645) heap_init: Initializing. RAM available for dynamic allocation:
[18:43:35]I (652) heap_init: At 40821FF0 len 0005A620 (361 KiB): RAM
[18:43:35]I (658) heap_init: At 4087C610 len 00002F54 (11 KiB): RAM
[18:43:35]I (664) heap_init: At 50000000 len 00003FE8 (15 KiB): RTCRAM
[18:43:35]I (671) spi_flash: detected chip: generic
[18:43:35]I (675) spi_flash: flash io: dio
[18:43:35]W (679) spi_flash: Detected size(16384k) larger than the size in the binary image header(8192k). Using the size in the binary image header.
[18:43:35]W (692) tsens: legacy driver is deprecated, please migrate to `driver/temperature_sensor.h`
[18:43:35]W (701) rmt(legacy): legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`
[18:43:35]W (712) i2c: This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`
[18:43:35]I (723) sleep: Configure to isolate all GPIO pins in sleep state
[18:43:35]I (729) sleep: Enable automatic switching of GPIO sleep configuration
[18:43:35]I (737) coexist: coex firmware version: 4482466
[18:43:35]I (742) coexist: coexist rom version 5b8dcfa
[18:43:35]I (747) main_task: Started on CPU0
[18:43:35]I (750) main_task: Calling app_main()
[18:43:35]I (854) main_task: Returned from app_main()
[18:43:45]E (10868) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
[18:43:45]E (10868) task_wdt:  - loopTask (CPU 0)
[18:43:45]E (10868) task_wdt: Tasks currently running:
[18:43:45]E (10868) task_wdt: CPU 0: loopTask
[18:43:45]E (10868) task_wdt: Aborting.

Additional information

https://github.com/esphome/esphome/discussions/6957

rvalitov commented 1 month ago

Setting scan: false helps to avoid the crash.

luca-angemi commented 1 month ago

I'm not sure this is related but my muse luxe uses i2c and keeps crashing in 2024.10.1 (works fine in 2024.10.0 or 2024.9.2)

I see logs in esphome crashing when starting the microphone.

2024-10-22 08:11:28.745 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
File "aioesphomeapi/connection.py", line 833, in aioesphomeapi.connection.APIConnection.send_messages_await_response_complex
TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/esphome/assist_satellite.py", line 183, in _update_satellite_config
config = await self.cli.get_voice_assistant_configuration(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aioesphomeapi/client.py", line 1469, in get_voice_assistant_configuration
resp = await self._get_connection().send_message_await_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "aioesphomeapi/connection.py", line 851, in send_message_await_response
File "aioesphomeapi/connection.py", line 837, in send_messages_await_response_complex
aioesphomeapi.core.TimeoutAPIError: Timeout waiting for VoiceAssistantConfigurationResponse after 5s
rvalitov commented 2 weeks ago

Perhaps related to #6366

CamronBorealis commented 6 days ago

I am getting the same issue on the ESP32-C6-DEVKITC-1 when attempting to connect to a BMP390 sensor