Giter Club home page Giter Club logo

Comments (8)

OttoWinter avatar OttoWinter commented on July 20, 2024

Oh noes... I'm using a cover myself, but on an ESP8266 - I'll try to reproduce the issue on my ESP32

So decoding the backtrace for the ESP32 is relatively simple (in fact, I even wanted to create a helper for esphomeyaml at one point, but now fortunately there are much less panics in esphomelib 😅).

Note that this is for *nix systems, I have no idea how this would be done on windows.

First, identify the platformio packages folder for the xtensa toolchain. In my case, this is ~/.platformio/packages/toolchain-xtensa32/bin. In that folder, there are a bunch of binaries used for compiling and debugging, for example xtensa-esp32-elf-g++ and xtensa-esp32-elf-gdb.

Now put this path in your global PATH variable:

export PATH=$PATH:/Users/ottowinter/.platformio/packages/toolchain-xtensa32/bin

Next, navigate to the platformio project folder. In this folder there should be a file called platformio.ini. In this folder, execture xtensa-esp32-elf-gdb .pioenvs/<NODE_NAME>/firmware.elf. Now the GDB interactive terminal should open.

Once in there, you basically have access to all gdb commands (and if you're using JTAG, even the step support). But for looking up what's at an address, simply type:

(gdb) list *0x4014c0d6
...
(gdb) list *0x400d2e7b
...
(gdb) list *0x4014c0da
...
(gdb) list *0x400d2e8b
...

You will see the lines surrounding the statement at the given address. Hope it helps :)

from esphome-core.

brandond avatar brandond commented on July 20, 2024

Not sure if I'm doing this wrong, or maybe I need to recompile with some additional options to not strip the binary?

user@host:~/repos/hass-esphome$ /home/user/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb nodes/garage/.pioenvs/garage/firmware.elf
GNU gdb (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from nodes/garage/.pioenvs/garage/firmware.elf...done.
(gdb) list *0x4014c0d6
(gdb) list *0x400d2e7b
(gdb) list *0x4014c0da
(gdb) list *0x400d2e8b
(gdb) list *0x400d5041
(gdb) list *0x400d5131
(gdb) list *0x400d2fb5
(gdb) list *0x400d2482
(gdb) list *0x400fc3a6

from esphome-core.

OttoWinter avatar OttoWinter commented on July 20, 2024

Hmm, I could have sworn that that worked before... but I'm seeing the same issue (should have checked before 😅)

A "workaround" is to dump the entire instruction table:

xtensa-esp32-elf-objdump -x livingroom/.pioenvs/livingroom/firmware.elf -d >symbols.txt

In the file symbols.txt you will then be able to examine all the code, and at the top of each label there is a comment where that symbol can be found in the source. In the meantime I'll try to get gdb working...

from esphome-core.

brandond avatar brandond commented on July 20, 2024

I found this: http://esp-idf.readthedocs.io/en/latest/get-started/idf-monitor.html
Looks like idf_monitor just parses the serial output and calls xtensa-esp32-elf-addr2line with the firmware and address. That's easy enough to do:

0x4014c0d6: esphomelib::Action<bool>::play_next(bool) at ??:?
0x400d2e7b: esphomelib::switch_::TurnOffAction<bool>::play(bool) at ??:?
0x4014c0da: esphomelib::Action<bool>::play_next(bool) at ??:?
0x400d2e8b: std::_Function_handler<void (), esphomelib::DelayAction<bool>::play(bool)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at ??:?
0x400d5041: esphomelib::Component::loop_internal() at ??:?
0x400d5131: esphomelib::Component::loop_() at ??:?
0x400d2fb5: esphomelib::Application::loop() at ??:?
0x400d2482: loop() at ??:?
0x400fc3a6: loopTask(void*) at ??:?

from esphome-core.

brandond avatar brandond commented on July 20, 2024

Even better, I found idf_monitor.py and let it catch a few tests:

/home/user/repos/esp-idf/tools/idf_monitor.py --port /dev/ttyUSB0 --toolchain-prefix /home/user/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf- nodes/garage/.pioenvs/garage/firmware.elf

They all seem to blow up at the same place:

[D][cover.mqtt:045]: 'Garage Door Opener': Closing cover...
[D][binary_sensor.mqtt:066]: 'Garage Door Switch': Sending state ON
[D][cover.mqtt:037]: 'Garage Door Opener': Sending state closed
[D][binary_sensor.mqtt:066]: 'Garage Door Switch': Sending state OFF
[D][binary_sensor.mqtt:066]: 'Garage Door Switch': Sending state ON
[D][binary_sensor.mqtt:066]: 'Garage Door Switch': Sending state OFF
Guru Meditation Error: Core  1 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 1 register dump:
PC      : 0x4014c0d6  PS      : 0x00060f30  A0      : 0x800d2e7e  A1      : 0x3ffd2450
0x4014c0d6: esphomelib::Action<bool>::play_next(bool) at ??:?

A2      : 0x3ffcdee8  A3      : 0x00000000  A4      : 0x00000050  A5      : 0x3ffd2430
A6      : 0x00000000  A7      : 0x00000000  A8      : 0x8014c772  A9      : 0x3ffd2430
A10     : 0xa5a5a5a5  A11     : 0x00000000  A12     : 0x00000005  A13     : 0x00000020
A14     : 0x00000020  A15     : 0x3ffcdf04  SAR     : 0x0000001b  EXCCAUSE: 0x0000001c
EXCVADDR: 0xa5a5a5a5  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff
Backtrace: 0x4014c0d6:0x3ffd2450 0x400d2e7b:0x3ffd2470 0x4014c0da:0x3ffd2490 0x400d2e8b:0x3ffd24b0 0x400d5041:0x3ffd24d0 0x400d5131:0x3ffd24f0 0x400d2fb5:0x3ffd2510 0x400d2482:0x3ffd2530 0x400fc3a6:0x3ffd2550

0x4014c0d6: esphomelib::Action<bool>::play_next(bool) at ??:?
0x400d2e7b: esphomelib::switch_::TurnOffAction<bool>::play(bool) at ??:?
0x4014c0da: esphomelib::Action<bool>::play_next(bool) at ??:?
0x400d2e8b: std::_Function_handler<void (), esphomelib::DelayAction<bool>::play(bool)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at ??:?
0x400d5041: esphomelib::Component::loop_internal() at ??:?
0x400d5131: esphomelib::Component::loop_() at ??:?
0x400d2fb5: esphomelib::Application::loop() at ??:?
0x400d2482: loop() at ??:?
0x400fc3a6: loopTask(void*) at ??:?

It seems to be running off the end of the action list. Here's what the code looks like for that cover:

  auto template_cover = App.make_template_cover("Garage Door Opener");
  auto gpio_switch = App.make_gpio_switch("Garage Door Switch", GPIOOutputPin(17, OUTPUT));
  auto *garage_door_switch = gpio_switch.switch_;

  auto *action_4 = garage_door_switch->make_turn_on_action<NoArg>();
  auto *action_5 = App.register_component(new DelayAction<NoArg>());
  action_5->set_delay(1000);
  auto *action_6 = garage_door_switch->make_turn_off_action<NoArg>();
  template_cover.template_->add_open_actions({
      action_4,
      action_5,
      action_6,
  });

  auto *action_7 = garage_door_switch->make_turn_on_action<NoArg>();
  auto *action_8 = App.register_component(new DelayAction<NoArg>());
  action_8->set_delay(1000);
  auto *action_9 = garage_door_switch->make_turn_off_action<NoArg>();
  auto *action_10 = App.register_component(new DelayAction<NoArg>());
  action_10->set_delay(1000);
  auto *action_11 = garage_door_switch->make_turn_on_action<NoArg>();
  auto *action_12 = App.register_component(new DelayAction<NoArg>());
  action_12->set_delay(1000);
  auto *action_13 = garage_door_switch->make_turn_off_action<NoArg>();
  template_cover.template_->add_close_actions({
      action_7,
      action_8,
      action_9,
      action_10,
      action_11,
      action_12,
      action_13,
  });

  auto *action = garage_door_switch->make_turn_on_action<NoArg>();
  auto *action_2 = App.register_component(new DelayAction<NoArg>());
  action_2->set_delay(1000);
  auto *action_3 = garage_door_switch->make_turn_off_action<NoArg>();
  template_cover.template_->add_stop_actions({
      action,
      action_2,
      action_3,
  });
  template_cover.template_->set_optimistic(true);

from esphome-core.

brandond avatar brandond commented on July 20, 2024

Simple fix. I wonder if maybe ESP8266 zeroes all memory, and ESP32 does not?

from esphome-core.

OttoWinter avatar OttoWinter commented on July 20, 2024

Oh thanks very much!

I don't think the ESP8266 zeros all memory or that there would be a difference, but who knows.

Maybe one reason might be that your close action is quite long... Mine is quite short:

cover:
  - platform: template
    name: "Wohnzimmer Jalousie"
    id: jalousie
    optimistic: True
    open_action:
      - switch.turn_off:
          id: jalousie_runter
      - switch.turn_on:
          id: jalousie_hoch
    close_action:
      - switch.turn_off:
          id: jalousie_hoch
      - switch.turn_on:
          id: jalousie_runter
    stop_action:
      - switch.turn_off:
          id: jalousie_hoch
      - switch.turn_off:
          id: jalousie_runter

binary_sensor:
  - platform: gpio
    pin: D5
    name: "Jalousie Überstrom"
    inverted: True
    id: uberstrom
    on_press:
      then:
        - delay: 100ms
        - lambda:
            if (id(uberstrom).value) {
              id(jalousie).stop();
            }

from esphome-core.

OttoWinter avatar OttoWinter commented on July 20, 2024

That esp-idf monitor is just genius! I will try to add it into the native esphomeyaml logs monitor when I get time - the only real issue will be getting the path for the xtensa-esp32-elf-addr2line executable from platformio.

from esphome-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.