espressif / esp-zigbee-sdk

Espressif Zigbee SDK
Apache License 2.0
165 stars 28 forks source link

Crash in esp_zb_zcl_set_attribute_val (TZ-266) #97

Closed lmahmutov closed 1 year ago

lmahmutov commented 1 year ago

`/ Measurement value / float temp = 30;

/ Convert to correct attribute format / int16_t attr_temp = (int16_t)(temp * 100);

/ Write to local temperature attribute / esp_zb_zcl_status_t state = esp_zb_zcl_set_attribute_val(1, ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, &attr_temp, false);

/ Check for error / if(state != ESP_ZB_ZCL_STATUS_SUCCESS) { ESP_LOGE(TAG, "Setting temperature attribute failed!"); }`

After runnig crash on this function Crash log `Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.

Core 0 register dump: MEPC : 0x4203fb8c RA : 0x4203fb8c SP : 0x4087ef20 GP : 0x4080eb00 0x4203fb8c: check_value_temp_measurement_server at ??:?

0x4203fb8c: check_value_temp_measurement_server at ??:?

TP : 0x4086dc90 T0 : 0x40022494 T1 : 0x4081f39a T2 : 0xffffffff 0x40022494: multi_heap_internal_unlock in ROM

S0/FP : 0x00000000 S1 : 0x00000bb8 A0 : 0x00000000 A1 : 0x00000001 A2 : 0x0000ffff A3 : 0x0000ffff A4 : 0x00000003 A5 : 0x00000003 A6 : 0x00000000 A7 : 0x00000003 S2 : 0x00000001 S3 : 0x00000001 S4 : 0x00000000 S5 : 0x4087efae S6 : 0x00000001 S7 : 0x00000000 S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000 T3 : 0x00000001 T4 : 0x4081887c T5 : 0x00000000 T6 : 0x00000000 MSTATUS : 0x00001881 MTVEC : 0x40800001 MCAUSE : 0x00000005 MTVAL : 0x00000006 0x40800001: _vector_table at ??:?

MHARTID : 0x00000000

Stack memory: 4087ef20: 0x00000402 0x00000001 0xffffffbb 0x4205554e 0x00000000 0x00000000 0x00000402 0x00000001 0x4205554e: zb_zcl_check_attr_value_manuf at ??:?

4087ef40: 0x4087efae 0x00000000 0x4081f1d6 0x42038834 0x4207bbc8 0x4207b5a0 0x00000003 0x4203920e 0x42038834: zb_zcl_check_attribute_writable at ??:?

0x4203920e: zb_zcl_set_attr_val at ??:?

4087ef60: 0x4081a086 0x4081a080 0x40818848 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087ef80: 0x00000000 0x00000000 0x40816000 0x4200b24e 0x4087f018 0x00000045 0x00000000 0x42007cf6 0x4200b24e: esp_zb_zcl_set_attribute_val at ??:?

0x42007cf6: test_ha at C:/Users/Lenz/esp/esp32_c6_co2_sensor/main/esp_zigbee_co2.c:162

4087efa0: 0x00000000 0x00000000 0x40816000 0x0bb808bc 0x4207b5a0 0x0000001c 0x00000004 0x420080f2 0x420080f2: lcd_task at C:/Users/Lenz/esp/esp32_c6_co2_sensor/main/esp_zigbee_co2.c:277 (discriminator 15)

4087efc0: 0xa5a5a5a5 0xa5a5a5a5 0x20324f43 0x3637203a 0x00000035 0x00000000 0x706d6554 0x2e30203a 4087efe0: 0x00003030 0x00000000 0xa5a5a5a5 0x73657250 0x2e30203a 0x00000030 0x00000000 0x4080eb00 4087f000: 0x4086dc90 0x00000000 0x00000000 0x00000000 0x206d7548 0x2e30203a 0x00000030 0x00000000 4087f020: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f040: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x4080a4f6 0x4080a4f6: vPortTaskWrapper at C:/Users/Lenz/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:205

4087f060: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f080: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000154 4087f0a0: 0x4087ee90 0x0000010f 0x4080fe30 0x4080fe30 0x4087f0a0 0x4080fe28 0x00000018 0x4087cf34 4087f0c0: 0x4087cf34 0x4087f0a0 0x00000000 0x00000001 0x4087e09c 0x5f64636c 0x6b736174 0x00000000 4087f0e0: 0x00000000 0x00000000 0x4087f090 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000 4087f100: 0x40817008 0x40817070 0x408170d8 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 4087f120: 0x40818834 0x42070528 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x42070528: _cleanup_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/riscv32-esp-elf/src/newlib/newlib/libc/stdio/findfp.c:229

4087f140: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f160: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f180: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f1a0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f1c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f1e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x40000000 0x00000074 0x00000000 0x00000000 0x40000000: _start in ROM

4087f200: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f220: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 4087f240: 0x00000000 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000 4087f260: 0x00000000 0x00000000 0x4087f1f0 0x00000154 0x4081b360 0x000000d7 0x4087f400 0x4081d4b4 4087f280: 0x4087f270 0x4080fe00 0x00000017 0x4087cf34 0x4087cf34 0x4087f270 0x00000000 0x00000002 4087f2a0: 0x4081a48c 0x32786d62 0x745f3038 0x006b7361 0x00000000 0x00000000 0x4081b480 0x00000002 4087f2c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x40817008 0x40817070 0x408170d8 0x00000000 4087f2e0: 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x42070528 0x00000000 0x00000000 0x42070528: _cleanup_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/riscv32-esp-elf/src/newlib/newlib/libc/stdio/findfp.c:229

4087f300: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000

ELF file SHA256: 6ec8d03d8036d3fc

Rebooting... ESP-ROM:esp32c6-20220919 Build:Sep 19 2022`

xieqinan commented 1 year ago

Hello, I believe the issue may be triggered by the absence of attributes in the temperature measurement cluster.

Have you registered the attributes ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_ID and ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_ID to the temperature measurement cluster, as mandated by the Zigbee specification?

lmahmutov commented 1 year ago

I register only ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID. I'll check. Thanks for the tip

lmahmutov commented 1 year ago

Work!