Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESP crash trace decoding to monitor #3383

Merged
merged 2 commits into from
Mar 11, 2020

Conversation

Tasssadar
Copy link
Contributor

@Tasssadar Tasssadar commented Feb 15, 2020

TODO:

  • Test on Windows
  • Test with unicode in paths & Python 2

This PR has been split into three parts, this one implements an interface to add more filters into miniterm and more in in platform repos, adding filters to decode the traces:

Original text below:
I've implemented automatic ESP crash trace decoding in the device monitor in platform.io. It is using a miniterm filter, add --filter=esp_exception_decoder to monitor_flags to use it.

It looks like this with a debug build (the indented part is new): Screenshot_20200215_190846

This is pretty much just a proof of concept, I've got some questions:

  1. It's pretty short implementation, but brings device-specific code into platformio-core, and it's rather hard to do it some other way because it has to edit the miniterm.TRANSFORMATIONS dict. I wasn't sure where to put it, so I just kind kept it in the device monitor, figured I'd ask you.
  2. Is there some nicer way to find the path to addr2line and to the built firmware file?
  3. Do you think some kind of automatic device detection is feasible, so that people don't have to add the --filter=esp_exception_decoder? Or perhaps we could include that flag in board configs for ESP devices?

Looking forward to your response!

Updates platformio/platform-espressif32#105
Updates platformio/platform-espressif8266#31

@claassistantio
Copy link

claassistantio commented Feb 15, 2020

CLA assistant check
All committers have signed the CLA.

@ivankravets
Copy link
Member

Wow!!! Great PR! Thank you so much!!!

I like your questions and the answers are the next:

  1. Yes, you are right. The PIO Core is not a place for dev-platform related code. How about if we create a new folder monitor in dev-platform root? https://github.com/platformio/platform-espressif32
    So, PIO Core will look for filter_xxx.py files in this folder. If it finds, it will try to find classes that inherit miniterm.Transform. The XXXFilter.NAME will be used as filter name. Then we can easily maintain this filter and publish bug fixes to it. We do not release PIO Core so often. We try to keep it independent from dev-platform and provides only APIs (for building, debugging, monitoring, etc)

  2. "firmware" = prog_path, the add2line - you do everything correct. See other variables https://github.com/platformio/platformio-core/blob/develop/platformio/builder/tools/pioide.py#L156

  3. It's already implemented. See https://docs.platformio.org/en/latest/projectconf/section_env_monitor.html#monitor-flags

Users can pass multiple filters using platformio.ini

[env:myenv]
board = ...
monitor_flags = 
   -f
   esp_exception_decoder

Each argument in a new line.

@Tasssadar
Copy link
Contributor Author

I have split it as you suggested, thanks for quick response!

As for 3., what I meant was if there was some good way to make it enabled by default, so that people don't have to add that to their platform.ini.

@@ -58,7 +58,7 @@ def is_bytes(x):
def path_to_unicode(path):
Copy link
Contributor Author

@Tasssadar Tasssadar Feb 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns unicode if it already is unicode, but string if it isn't? Seemed like a bug to me, and it doesn't seem to be used anywhere yet, so I changed it to always return unicode (I needed it in the filter in plaftorm-espressif32).

@Tasssadar
Copy link
Contributor Author

Hi, just bumping this, anything I can do to make it easier to merge/review for you?

@ivankravets
Copy link
Member

Hi @Tasssadar ,

Sorry for the delay! I think about this PR each day! I remember. Thank you so much for your contribution. We need some changes on the PlatformIO Core side with extending API for dev-platforms. I'll back soon here.

@ivankravets ivankravets merged commit 8c3de60 into platformio:develop Mar 11, 2020
@ivankravets
Copy link
Member

Great work! Let me finalize documentation and we will release it in the upcoming PlatformIO Core 4.3. It's planned to be released this week in pair with support for official JetBrain's extension for CLion: https://plugins.jetbrains.com/plugin/13922-platformio-for-clion

@greg-wood
Copy link

Is there any documentation on how to set this up and to use it?

@valeros
Copy link
Member

valeros commented Apr 15, 2020

Hi @greg-wood ! Have you seen this doc page? Just add the following line to your environment in platformio.ini

[env:myenv]
...
monitor_filters = esp32_exception_decoder

@wotupfoo
Copy link

wotupfoo commented May 5, 2021

I'm not seeing a difference.
I did a "pio upgrade --dev" and added "monitor_filter = esp32_exception_decoder" to my platformio.ini but am not seeing any backtrace decode.
Did I update to the wrong platformio toolchain?

PLATFORMIO.INI:
platform = espressif32
; Panic Backtrace decode
monitor_filter = esp32_exception_decoder
board = esp32dev

SERIAL:
Guru Meditation Error: Core  1 panic'ed (Coprocessor exception)
Core 1 register dump:
PC      : 0x400d35dd  PS      : 0x00060031  A0      : 0x800d3970  A1      : 0x3ffbe9d0
A2      : 0x3ffb85e0  A3      : 0x00000001  A4      : 0x3ffb866c  A5      : 0x00000000
A6      : 0x000000a5  A7      : 0x00000050  A8      : 0x00000023  A9      : 0x3ffb87ac
A10     : 0x00000001  A11     : 0x66666667  A12     : 0x00000023  A13     : 0x3ffb8794
A14     : 0x0000bffc  A15     : 0x00000000  SAR     : 0x00000019  EXCCAUSE: 0x00000004  
EXCVADDR: 0x00000000  LBEG    : 0x400d35c1  LEND    : 0x400d35e5  LCOUNT  : 0x0000004f  
Core 1 was running in ISR context:
EPC1    : 0x400d35dd  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x4008466f

ELF file SHA256: 0000000000000000

Backtrace: 0x400d35dd:0x3ffbe9d0 0x400d396d:0x3ffbead0 0x400d3a4f:0x3ffbeb10 0x400d2abd:0x3ffbeb50 0x40081203:0x3ffbeb70 0x40081285:0x3ffbeba0 0x40084455:0x3ffbebc0 0x400eebb9:0x3ffb1fb0 0x40086e1d:0x3ffb1fd0

Rebooting...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants