paveldn / HaierProtocol

Haier communication protocol library
MIT License
15 stars 1 forks source link

Core dump when using component on ESPHome #3

Open marcriera opened 1 month ago

marcriera commented 1 month ago

Hello,

I am having issues using this component on ESPHome. Immediately after the first frame, I get a core dump and constant reboots. I am running it on an MH ET LIVE ESP32MiniKit.

Things I have tried:

ESPHome config

esphome:
  name: aire-dormitori
  friendly_name: Aire Dormitori
  libraries:
    - HaierProtocol=https://github.com/paveldn/HaierProtocol.git#0.9.30

esp32:
  board: mhetesp32minikit
  framework:
    type: arduino
    version: latest

# Enable logging
logger:
  level: VERBOSE

wifi:
  ssid: "<REDACTED>"
  password: "<REDACTED>"

uart:
  id: ac_port
  tx_pin: GPIO9
  rx_pin: GPIO10
  baud_rate: 9600

climate:
- platform: haier
  id: haier_ac
  name: Haier AC
  protocol: hon
  uart_id: ac_port
  wifi_signal: true
  beeper: true
  display: true
  visual:
    min_temperature: 16 °C
    max_temperature: 30 °C
    temperature_step: 1 °C
  supported_modes:
    - 'OFF'
    - HEAT_COOL
    - COOL
    - HEAT
    - DRY
    - FAN_ONLY
  supported_swing_modes:
    - 'OFF'
    - VERTICAL
  supported_presets:
    - AWAY
    - ECO
    - BOOST
    - SLEEP
  on_alarm_start:
    then:
      - logger.log:
          level: WARN
          format: "Alarm activated. Code: %d. Message: \"%s\""
          args: [ code, message]
  on_alarm_end:
    then:
      - logger.log:
          level: INFO
          format: "Alarm deactivated. Code: %d. Message: \"%s\""
          args: [ code, message]
  on_status_message:
    then:
      - logger.log:
          level: INFO
          format: "New status message received, size=%d, subcmd=%02X%02X"
          args: [ 'data_size', 'data[0]', 'data[1]' ]

ESP32 logs

INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyACM0 with baud rate 115200
[10:07:43]\x97\x82\xc2\xc10
[10:07:43]mode:DIO, clock div:2
[10:07:43]load:0x3fff0030,len:1184
[10:07:43]load:0x40078000,len:13192
[10:07:43]load:0x40080400,len:3028
[10:07:43]entry 0x400805e4
[10:07:44]E (386) esp_core_dump_flash: No core dum\x82\x85\xc9ѥѥ\xbd\xb9\x81found!
[10:07:44]E (386) esp_core_dump_flash: No core dump partition found!
[10:07:44][     9][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[10:07:44][I][logger:156]: Log initialized
[10:07:44][C][safe_mode:079]: There have been 9 suspected unsuccessful boot attempts
[10:07:44][D][esp32.preferences:114]: Saving 1 preferences to flash...
[10:07:44][V][esp32.preferences:126]: sync: key: 233825507, len: 4
[10:07:44][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[10:07:44][I][app:029]: Running through setup()...
[10:07:44][V][app:030]: Sorting components by setup priority...
[10:07:44][C][uart.arduino_esp32:077]: Setting up UART...
[10:07:44][I][haier.climate:234]: Haier initialization...
[10:07:44][V][esp32.preferences:059]: nvs_get_blob('3483230335'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[10:07:44][C][wifi:048]: Setting up WiFi...
[10:07:44][C][wifi:061]: Starting WiFi...
[10:07:44][C][wifi:062]:   Local MAC: <REDACTED>
[10:07:44][V][esp32.preferences:059]: nvs_get_blob('2563874274'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[10:07:44][V][wifi_esp32:067]: Enabling STA.
[10:07:44][   131][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 0 - WIFI_READY
[10:07:44][V][wifi_esp32:486][arduino_events]: Event: WiFi ready
[10:07:44][   229][V][WiFiGeneric.cpp:340] _arduino_event_cb(): STA Started
[10:07:44][   229][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 2 - STA_START
[10:07:44][V][wifi_esp32:497][arduino_events]: Event: WiFi STA start
[10:07:50][  6456][V][WiFiGeneric.cpp:383] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 28
[10:07:50][  6457][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 1 - SCAN_DONE
<REDACTED, WIFI CONNECTION SUCCESSFUL>
[10:07:52][C][api:025]: Setting up Home Assistant API server...
[10:07:52][I][app:062]: setup() finished successfully!
[10:07:52][W][component:170]: Component wifi cleared Warning flag
[10:07:52][W][component:157]: Component api set Warning flag: unspecified
[10:07:52][I][app:100]: ESPHome version 2024.9.1 compiled on Sep 30 2024, 10:07:22
[10:07:52][C][logger:185]: Logger:
[10:07:52][C][logger:186]:   Level: VERBOSE
[10:07:52][C][logger:188]:   Log Baud Rate: 115200
[10:07:52][C][logger:189]:   Hardware UART: UART0
[10:07:52][C][uart.arduino_esp32:151]: UART Bus 1:
[10:07:52][C][uart.arduino_esp32:152]:   TX Pin: GPIO9
[10:07:52][C][uart.arduino_esp32:153]:   RX Pin: GPIO10
[10:07:52][C][uart.arduino_esp32:155]:   RX Buffer Size: 256
[10:07:52][C][uart.arduino_esp32:157]:   Baud Rate: 9600 baud
[10:07:52][C][uart.arduino_esp32:158]:   Data Bits: 8
[10:07:52][C][uart.arduino_esp32:159]:   Parity: NONE
[10:07:52][C][uart.arduino_esp32:160]:   Stop bits: 1
[10:07:52][C][haier.climate:245]: Haier Climate 'Haier AC'
[10:07:52][C][haier.climate:246]:   Device communication status: none
[10:07:52][C][haier.climate:310]:   Protocol version: hOn
[10:07:52][C][haier.climate:311]:   Control method: 1
[10:07:52][C][mdns:116]: mDNS:
[10:07:52][C][mdns:117]:   Hostname: aire-dormitori
[10:07:52][V][mdns:118]:   Services:
[10:07:52][V][mdns:120]:   - _esphomelib, _tcp, 6053
[10:07:52][V][mdns:122]:     TXT: friendly_name = Aire Dormitori
[10:07:52][V][mdns:122]:     TXT: version = 2024.9.1
[10:07:52][V][mdns:122]:     TXT: mac = <REDACTED>
[10:07:52][V][mdns:122]:     TXT: platform = ESP32
[10:07:53][V][mdns:122]:     TXT: board = mhetesp32minikit
[10:07:53][V][mdns:122]:     TXT: network = wifi
[10:07:53][C][esphome.ota:073]: Over-The-Air updates:
[10:07:53][C][esphome.ota:074]:   Address: aire-dormitori.local:3232
[10:07:53][C][esphome.ota:075]:   Version: 2
[10:07:53][C][esphome.ota:078]:   Password configured
[10:07:53][C][safe_mode:018]: Safe Mode:
[10:07:53][C][safe_mode:020]:   Boot considered successful after 60 seconds
[10:07:53][C][safe_mode:021]:   Invoke after 10 boot attempts
[10:07:53][C][safe_mode:023]:   Remain in safe mode for 300 seconds
[10:07:53][W][safe_mode:029]: Last reset occurred too quickly; safe mode will be invoked in 1 restarts
[10:07:53][C][api:139]: API Server:
[10:07:53][C][api:140]:   Address: aire-dormitori.local:6053
[10:07:53][C][api:144]:   Using noise encryption: NO
[10:07:53][D][api:102]: Accepted 192.168.2.100
[10:07:53][V][api.connection:1427]: Hello from client: 'Home Assistant 2024.9.3' | <REDACTED> | API Version 1.10
[10:07:53][W][component:170]: Component api cleared Warning flag
[10:07:53][D][api.connection:1445]: Home Assistant 2024.9.3 (<REDACTED>): Connected successfully
[10:07:54][D][haier.protocol:019]: Sending frame: type 61, data: 00 07
[10:07:54][V][haier.protocol:022]: Sending data: FF FF 0A 00 00 00 00 00 00 61 00 07 72
[10:07:54]
[10:07:54]assert failed: heap_caps_free heap_caps.c:360 (heap != NULL && "free() target pointer is outside heap areas")
[10:07:54]
[10:07:54]
[10:07:54]Backtrace: 0x400837bd:0x3ffb4550 0x4008b911:0x3ffb4570 0x400914ad:0x3ffb4590 0x40083c7a:0x3ffb46c0 0x400914dd:0x3ffb46e0 0x401025bb:0x3ffb4700 0x40102617:0x3ffb4720 0x4010264b:0x3ffb4740 0x401088dd:0x3ffb4760 0x40102111:0x3ffb4780
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x400837bd: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
WARNING Decoded 0x4008b911: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:137
WARNING Decoded 0x400914ad: __assert_func at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/assert.c:85
WARNING Decoded 0x40083c7a: heap_caps_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:360
 (inlined by) heap_caps_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:345
WARNING Decoded 0x400914dd: free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/heap.c:39
WARNING Decoded 0x401025bb: mem_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/mem.c:264 (discriminator 2)
WARNING Decoded 0x40102617: do_memp_free_pool at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/memp.c:383
WARNING Decoded 0x4010264b: memp_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/memp.c:440
WARNING Decoded 0x401088dd: sys_check_timeouts at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/core/timeouts.c:409
WARNING Decoded 0x40102111: tcpip_timeouts_mbox_fetch at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:104
 (inlined by) tcpip_thread at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/lwip/lwip/src/api/tcpip.c:148
[10:07:54]
[10:07:54]
[10:07:54]
[10:07:54]
[10:07:54]ELF file SHA256: c710174e1b1933e7
[10:07:54]
[10:07:54]E (10394) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
[10:07:54]Rebooting...

Thanks in advance!

paveldn commented 1 month ago

Hi @marcriera,

I will take a look. It is not normal to get faults in any case. But why do you need to use the HaierProtocol library and ESPHome Haier climate component at the same time? Haier Climate already using 0.9.31 version of the library. I suppose it is caused by the fact that the component tries to use both libraries' static objects but one of them is not initialized properly. I will check. But can you explain to me why you need this library alongside with ESPHome Haier component to better understand your use case?

marcriera commented 1 month ago

Thanks for the quick reply.

Sorry, I manually especified the library in the config to check whether an older version was working. That doesn't load the library twice, it just changes the version of HaierProtocol used by ESPHome. Removing that part entirely makes it use version 0.9.31 and the issue is present (that's what led my to try an older version). I saw HaierProtocol mentioned in the build logs and I assumed the problem was here, that's all I know.

Is there anything I'm missing? I just installed ESPHome (version 2024.9.1), created a config file from what I read in https://github.com/paveldn/haier-esphome and ran esphome run aire-dormitori.yaml. Thank you.

paveldn commented 1 month ago

@marcriera Oh, I was sure it was a way to load the library not to use an older version. Anyway, I will take a look. But I don't think there was a significant change recently in this library. Just a small one. If you have problems ESPHome protocol it is better to create an issue here https://github.com/paveldn/haier-esphome and I will take a look 😄