espressif / esp-zigbee-sdk

Espressif Zigbee SDK
Apache License 2.0
132 stars 20 forks source link

Crash on HA_color_dimmable_light when pairing a remote. (TZ-617) #239

Open edmeme opened 5 months ago

edmeme commented 5 months ago

Answers checklist.

IDF version.

v5.3-dev-1724-ga5b261f699

esp-zigbee-lib version.

1.1.0

esp-zboss-lib version.

1.1.0

Espressif SoC revision.

ESP32-H2

What is the expected behavior?

Can connect a switch to the HA_color_dimmable_light example.

What is the actual behavior?

When a switch is connected (testing with an IKEA Trådfri switch) the example crashes

log.log stack.txt

Stack memory:
4081e130: 0x00000008 0x4081e168 0x4081e190 0x4080c7ba 0x00000000 0x0000001f 0x4081e1a0 0x4080e6b8
4081e150: 0x4081e194 0x4080e6d4 0x4081e190 0x726f6261 0x20292874 0x20736177 0x6c6c6163 0x61206465
4081e170: 0x43502074 0x34783020 0x63313032 0x20646465 0x63206e6f 0x2065726f 0x00000030 0x42020000
...

ELF file SHA256: 14dff145f

Rebooting...
ESP-ROM:esp32h2-20221101
Build:Nov  1 2022
rst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x400031b6
SPIWP:0xee
mode:DIO, clock div:1
load:0x408460e0,len:0x17ac
load:0x4083cad0,len:0xe88
load:0x4083efd0,len:0x2c94
entry 0x4083cada

Steps to reproduce.

  1. System upgrade (archlinux) # pacman -Suy

  2. update IDF and the examples cd esp-idf ; git pull ; git submodule update --init --recursive ; ./install.sh git describe --tags now reports v5.3-dev-1724-ga5b261f699 cd esp-zigbee-sdk ; git pull last commit is a5b261f699808efdacd287adbded5b718dffd14e

  3. build and flash

    source esp-idf/export.sh
    cd esp-zigbee-sdk/examples/esp_zigbee_HA_sample/HA_color_dimmable_light
    idf.py set-target esp32h2
    idf.py build
    touch main/esp_zb_light.c # The first time I build I do not get a valid program, for some reason.
    idf.py build
  4. plug-in my board (ESP Thread Border Router/ESP Gateway v1.2) idf.py flash --port=/dev/ttyACM0

  5. press 5 times the link button in my remote to pair.

  6. The following line appears in the log I (37373) ESP_ZB_COLOR_DIMM_LIGHT: ZDO signal: NWK Device Associated (0x12), status: ESP_OK Then the crash happens.

Full log and an attempt to identify all symbols in the stack trace are attached. log.log stack.txt

More Information.

No response

xieqinan commented 5 months ago

Hello,

The issue appears to be triggered by an error short address.

In the ESP_ZB_COLOR_DIMM_LIGHT example, which is a centralized router, the short address should not be 0x0000.

The indication of NWK Device Associated suggests that it received an association request that should have been received by the coordinator rather than the router.

Firstly, you should confirm the remote device type. Is it a coordinator?

Secondly, you can check the joining process in a sniffer to determine what short address is assigned to the router by the coordinator.

Thirdly, what is the role of ESP Thread Border Router/ESP Gateway v1.2 in your project?

edmeme commented 5 months ago

Thanks for the prompt answer!

I think that error could come from an improper initialization; I factory-resetted the device (calling esp_zb_factory_reset) and now it will simply not find a network to join ("Network steering was not successful"). Unfortunately I don't have proper tools to test, I ordered tools to sniff traffic now and I will continue troubleshooting then.

The board has a Router role, I think that's usual in ZLL? I am not familiar with Zigbee, ZLL or HA, I am learning it now.

xieqinan commented 3 months ago

@edmeme ,

The compatibility of Zigbee economics is a contentious issue. We are unsure of the methods employed by devices like the IKEA Trådfri switch to prevent unauthorized devices from joining their network, such as install codes, link keys, manufacturer codes, and so on. Therefore, a packet sniffer is necessary for us to investigate and address this issue.

xieqinan commented 2 weeks ago

@edmeme

Do you have any updates on this issue?