espressif / esp-zigbee-sdk

Espressif Zigbee SDK
Apache License 2.0
163 stars 26 forks source link

HA_color_dimmable_light crashing on ESP32-C6 (TZ-144) #35

Closed jayavanth closed 1 year ago

jayavanth commented 1 year ago

I (269) cpu_start: ESP-IDF:          v5.1-dev-5454-gdc016f5987-dirty
I (277) cpu_start: Min chip reRAM available for dynamic allocation:
I (298) heap_init: At 40814C80 len 00067990 (414 KiB):�ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875720,len:0x181c
load:0x4086c410,len:0xd44
load:0x4086e610,len:0x2dbc
entry 0x4086c41a
I (23) boot: ESP-IDF v5.1-dev-5454-gdc016f5987-dirty 2nd stage bootloader
I (24) boot: compile time Jun 11 2023 16:01:07
I (25) boot: chip revision: v0.0
I (29) boot.esp32c6: SPI Speed      : 40MHz
I (33) boot.esp32c6: SPI Mode       : DIO
I (38) boot.esp32c6: SPI Flash Size : 2MB
I (43) boot: Enabling RNG early entropy source...
I (49) boot: Partition Table:
I (52) boot: ## Label            Usage          Type ST Offset   Length
I (59) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (67) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (74) boot:  2 factory          factory app      00 00 00010000 00089800
I (82) boot:  3 zb_storage       Unknown data     01 81 0009a000 00004000
I (89) boot:  4 zb_fct           Unknown data     01 81 0009e000 00000400
I (97) boot: End of partition table
I (101) esp_image: segment 0: paddr=00010020 vaddr=42060020 size=0dca0h ( 56480) map
I (120) esp_image: segment 1: paddr=0001dcc8 vaddr=40800000 size=02350h (  9040) load
I (123) esp_image: segment 2: paddr=00020020 vaddr=42000020 size=5d22ch (381484) map
I (201) esp_image: segment 3: paddr=0007d254 vaddr=40802350 size=0c5fch ( 50684) load
I (216) boot: Loaded app from partition at offset 0x10000
I (217) boot: Disabling RNG early entropy source...
I (228) cpu_start: Unicore app
I (228) cpu_start: Pro cpu up.
W (237) clk: esp_perip_clk_init() has not been implemented yet
I (244) cpu_start: Pro cpu start user code
I (244) cpu_start: cpu freq: 160000000 Hz
I (244) cpu_start: Application information:
I (247) cpu_start: Project name:     color_light_bulb
I (253) cpu_start: App version:      3e3654b-dirty
I (258) cpu_start: Compile time:     Jun 11 2023 16:01:00
I (264) cpu_start: ELF file SHA256:  19c7d83f4...
I (269) cpu_start: ESP-IDF:          v5.1-dev-5454-gdc016f5987-dirty
I (277) cpu_start: Min chip rev:     v0.0
I (281) cpu_start: Max chip rev:     v0.99 
I (286) cpu_start: Chip rev:         v0.0
I (291) heap_init: Initializing. RAM available for dynamic allocation:
I (298) heap_init: At 40814C80 len 00067990 (414 KiB): D/IRAM
I (304) heap_init: At 4087C610 len 00002F54 (11 KiB): STACK/DIRAM
I (311) heap_init: At 50000010 len 00003FF0 (15 KiB): RTCRAM
I (318) spi_flash: detected chip: generic
I (322) spi_flash: flash io: dio
W (326) spi_flash: Detected size(8192k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (339) sleep: Configure to isolate all GPIO pins in sleep state
I (346) sleep: Enable automatic switching of GPIO sleep configuration
I (364) coexist: coexist adapter function magic error! Magic deadbeaf is expected, but it is 0
I (365) coexist: coex firmware version: 5315623
Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.

Core  0 register dump:
Stack dump detected
MEPC    : 0x42051046  RA      : 0x42001362  SP      : 0x4087e170  GP      : 0x4080d770  
0x42051046: coex_core_pre_init at ??:?

0x42001362: __esp_system_init_fn_init_components0 at /Users/jay/Documents/workspace/onu/esp/esp-idf-latest/components/esp_system/startup.c:515

TP      : 0x00000000  T0      : 0x40028192  T1      : 0x30000000  T2      : 0x00000000  
S0/FP   : 0x40880000  S1      : 0x4080d9ac  A0      : 0x00000001  A1      : 0x00000001  
A2      : 0x000fffff  A3      : 0x00000004  A4      : 0x00000000  A5      : 0x00000000  
A6      : 0x00000001  A7      : 0x0000000a  S2      : 0x4080d9ac  S3      : 0x42000000  
S4      : 0x42060000  S5      : 0x42000000  S6      : 0x40800264  S7      : 0x0005d22c  
0x40800264: call_start_cpu0 at /Users/jay/Documents/workspace/onu/esp/esp-idf-latest/components/esp_system/port/cpu_start.c:294

S8      : 0x0000dca0  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00800000  
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000005  MTVAL   : 0x00000008  
0x40800001: _vector_table at ??:?

MHARTID : 0x00000000  

Backtrace:

/Library/Developer/CommandLineTools/usr/bin/install_name_tool: warning: changes being made to the file will invalidate the code signature in: /Users/jay/.espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb-3.7.ADuC7p3
0x42051046 in coex_core_pre_init ()
#0  0x42051046 in coex_core_pre_init ()
#1  0x42001362 in __esp_system_init_fn_init_components0 () at /Users/jay/Documents/workspace/onu/esp/esp-idf-latest/components/esp_system/startup.c:505
#2  0x00000000 in ?? ()
Backtrace stopped: frame did not save the PC
ELF file SHA256: 19c7d83f4

Rebooting...
ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x4001975a
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875720,len:0x181c
load:0x4086c410,len:0xd44
load:0x4086e610,len:0x2dbc
entry 0x4086c41a

This example seems to work with ESP32-H2 but not on the C6

xieqinan commented 1 year ago

Hi, @jayavanth After analyzing the log you provided, it appears that the problem is occurring due to the coexistence feature between WiFi and Zigbee. If we can confirm the following issues related to your project, the problem can be resolved quickly.

Firstly, could you please provide the version of the esp-idf that you are using as the base?

Secondly, does your project require the WiFi-Zigbee coexistence support?

Thirdly, if both CONFIG_SW_COEXIST_ENABLE and CONFIG_EXTERNAL_COEX_ENABLE are enabled, the WiFi-Zigbee coexistence feature will be enabled. However, based on the log, it seems that the value of COEX_ADAPTER_MAGIC is zero instead of the expected value 0xDEADBEAF. Could you please explain the reason for modifying this value?

jayavanth commented 1 year ago
  1. I'm on commit dc016f59877d13e6e7d4fc193aa5aa764547f16d (Jun 4, 2023)
  2. No, I only need Zigbee
  3. I didn't modify this value actually. When I grep for the directive on esp-idf, I get this
    ✗ grep -RnIi COEX_ADAPTER_MAGIC
    ./components/esp_coex/esp32c2/esp_coex_adapter.c:164:    ._magic = COEX_ADAPTER_MAGIC,
    ./components/esp_coex/esp32c3/esp_coex_adapter.c:168:    ._magic = COEX_ADAPTER_MAGIC,
    ./components/esp_coex/include/esp_coexist_adapter.h:17:#define COEX_ADAPTER_MAGIC    0xDEADBEAF
    ./components/esp_coex/esp32/esp_coex_adapter.c:230:    ._magic = COEX_ADAPTER_MAGIC,
    ./components/esp_coex/esp32c6/esp_coex_adapter.c:163:    ._magic = COEX_ADAPTER_MAGIC,
    ./components/esp_coex/esp32h2/esp_coex_adapter.c:155:    ._magic = COEX_ADAPTER_MAGIC,
    ./components/esp_coex/esp32s3/esp_coex_adapter.c:242:    ._magic = COEX_ADAPTER_MAGIC,
    ./components/esp_coex/esp32s2/esp_coex_adapter.c:236:    ._magic = COEX_ADAPTER_MAGIC,
kelin6 commented 1 year ago

@jayavanth I have reproduced the issue you described, and it is caused by a mismatch in the esp-idf/components/esp_coex/lib directory. Based on your esp-idf (commit: dc016f5987), the submodule esp_coex/lib is at commit 67ba5893b08 (coex firmware version: 5315623), but in a normal esp-idf (commit: dc016f5987), the submodule esp_coex/lib commit is 28e28582 (coex firmware version: ebddf304). Therefore, it is due to the outdated esp-idf submodule.

To resolve this, please navigate to your esp-idf directory and execute the command git submodule update --init. This will update the esp-idf submodule, and After running this command, you will see that the esp-idf/component/esp_coex/lib commit will be 28e28582.

If you don't need to use the coexistence functionality, you can disable coexistence. Using idf.py menuconfig, then select Component config --> Wire Coexistence --> Software control WIFI/Bluetooth coexistence.

jayavanth commented 1 year ago

@kelin6 ok that seems to work. It's not crashing anymore and I was able to get HA_on_off_light and HA_color_dimmable_light working. Thank you! 🙌