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

Backtrace decoder for ESP32 #105

Closed
me21 opened this issue Jul 3, 2018 · 29 comments · Fixed by #286
Closed

Backtrace decoder for ESP32 #105

me21 opened this issue Jul 3, 2018 · 29 comments · Fixed by #286
Assignees
Labels

Comments

@me21
Copy link

me21 commented Jul 3, 2018

There is a backtrace decoder for ESP32 which is installed in Arduino IDE: https://github.com/me-no-dev/EspExceptionDecoder

And another CLI backtrace decoder written in Python: https://github.com/janLo/EspArduinoExceptionDecoder

It would be nice to use it from Platformio IDE somehow. Serial port monitor is already there, it should be possible to copy&paste the backtrace.

@KrrishnaShah
Copy link

is there any way to back-trace in ESP-IDF

@yaqwsx
Copy link

yaqwsx commented Oct 14, 2018

idf_monitor.py in ESP-IDF provides this feature. It scans the serial monitor for addresses a translates them with addr2line. The functionality should be only few lines of code, however:

  • platformIO does not ship addr2line in the espressif32 package
  • the serial monitor is not per-platform (mistake me if I am wrong).

I would greatly appreciate this functionality!

@yaqwsx
Copy link

yaqwsx commented Nov 16, 2018

I briefly looked at the implementation of monitor in PlatformIO. It uses miniterm from PySerial, therefore, it is not easy to extend it by post-processing of the output unless we change PySerial or PlatformIO ships its own monitor.

@vallettea
Copy link

would also be interested

@baggior
Copy link

baggior commented Mar 15, 2019

me too

@gaelj
Copy link

gaelj commented Oct 28, 2019

2 years later and this issue is still open... Oh well I guess I wiill have to keep on using the horrible Arduino IDE to debug my ESP32 Guru Meditations.

@pierreverbakel
Copy link

It keeps amazing me how the Arduino IDE keeps ahead on PlatformIO on some vital points, like this one. I do edit en Visual Code editor with PlatformIO Plugin, try to compile and run in PlatformIO, but then revert to Arduino IDE to understand those crashes. So one could call this IIDDEE-Platform development. Almost like Turbo, but really it feels like using the bird in the Flintstones putting its beak on the rock-record since I know it will do the job... It feels backward indeed ...

@louislewis2
Copy link

Guys, again this is ridiculous that such an important feature is simply left untouched.

@yaqwsx
Copy link

yaqwsx commented Nov 10, 2019

It is, but it would require a significant change to the PIO Serial (e.g. hack the MiniTerm or implement a custom one), so I understand it can take a while to implement.

However, I don't understand why there is no reaction from the PIO maintainers for over a year...

@louislewis2
Copy link

I would honestly settle for a copy and paste solution, even that initially would be useful.

@pfeerick
Copy link
Contributor

pfeerick commented Nov 14, 2019

Try janLo/EspArduinoExceptionDecoder... (actually, the me21 fork is supposed to be better for ESP32) if you copy the stacktrace to a file as suggested in the readme, and then run decoder.py from the PIO command line, it should 'just work'. Plus, since it is python based, it should work anywhere PlatformIO does.

I have used luffykesh/EspExceptionDecoder-CLI in the past, but it needs java.

@yaqwsx
Copy link

yaqwsx commented Nov 15, 2019

Since PlatformIO currently uses Python3, it should be possible to use contextlib.redirect_stdout around the call of miniterm in the PlatformIO core. Then a custom file-like object could do the translation. However, this requires a change to the platform API - it has to be able to provide a custom post-processor. Who should I contact with such a request/consultation?

@rohansingh
Copy link
Contributor

rohansingh commented Jan 10, 2020

It's super-annoying but here's what I use as a workaround:

~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-addr2line \
  -pfiaC \
  -e .pio/build/$ENV/$PROJECT.elf \
  $ADDRESS

Replace $ENV, $PROJECT, and $ADDRESS with appropriate values.

@g01d10x
Copy link

g01d10x commented Feb 26, 2020

I personally, and suspect many others would also be very interested in having this added to PlatformIO :D thanks for the great work so far !!

@ivankravets
Copy link
Member

Thanks to @Tasssadar 's great contribution this issue has been finally resolved! We need some feedback/testing before making the final release of PlatformIO Core 4.3 and this dev-platform. Please re-test:

  1. Open PlatformIO IDE Terminal and run pio upgrade --dev.
  2. Use the upstream version of this dev-platform. See docs https://docs.platformio.org/en/latest/platforms/espressif32.html#upstream
  3. Run pio update.

See documentation https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#filters

@LeedanJohnson
Copy link

This works a treat when the upstream dev-platform doesn't break things. On a small demo script, everything went off without a hitch, but when compiling and flashing a larger project (that works fine on the stable platform) something goes wrong. I get a bootloop with garbage coming over the serial line.

@valeros
Copy link
Member

valeros commented Mar 18, 2020

Hi @LeedanJohnson ! The upstream should work as well, could you please provide more details or even open a new issue?

@LeedanJohnson
Copy link

LeedanJohnson commented Mar 18, 2020

EDIT

I tried to replicate the issue after writing the below, so that I could give more details and context, but it worked now. Perhaps there was something I had configured incorrectly. If the issue manifests again, I will make another reply to the thread. Thanks!

Initial Comment

I'd love to supply more details here, but I really don't know what details to provide.
While I have "platform = espressif32" in my platformio.ini file, my full project compiles and runs without a problem (Except for an exception occasionally getting thrown that I'm trying to track down).

If I change that to 'platform = https://github.com/platformio/platform-espressif32.git', the project still compiles and will upload, but will bootloop and spit garbage over the serial line.

Interestingly enough, if I purposefully introduce an exception early on in the program, the same project will start up and run as intended (hitting the exception, and dumping the registers before restarting).

@LeedanJohnson
Copy link

The issue is back again, with the same behaviour, although I'm not getting the garbled text over serial now. The following is what comes over serial. The second type of boot loops forever.
`rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
`

@valeros
Copy link
Member

valeros commented Mar 18, 2020

@LeedanJohnson What framework/board do you use?

@LeedanJohnson
Copy link

I think this will answer those questions, if not let me know.

[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32dev
framework = arduino
monitor_speed = 115200
upload_speed = 921600
build_flags = -DCORE_DEBUG_LEVEL=5

@bakwc
Copy link

bakwc commented Jun 7, 2021

I have the same issue.

Version:

$ platformio --version
PlatformIO Core, version 5.1.1

Config:

[env:esp32dev]
platform = espressif32
board = esp32cam
framework = arduino
board_build.f_cpu = 240000000L
upload_protocol = esptool

lib_extra_dirs = lib

build_flags = -DCORE_DEBUG_LEVEL=5

monitor_port = /dev/cu.usbserial-1450
monitor_speed = 115200
platformio device monitor

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on /dev/cu.usbserial-1450  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

...

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d1437  PS      : 0x00060130  A0      : 0x800d153a  A1      : 0x3ffe9de0
A2      : 0xfecd2c98  A3      : 0x3ffc28f0  A4      : 0x3ffc2cf4  A5      : 0x3ffda948
A6      : 0x3ffe9d9c  A7      : 0x3ffe9d9c  A8      : 0x800d1437  A9      : 0x3ffe9dc0
A10     : 0x00000064  A11     : 0xd4063a52  A12     : 0xd4063a52  A13     : 0x3ffda948
A14     : 0x3ffe9d7c  A15     : 0x3ffe9d7c  SAR     : 0x00000004  EXCCAUSE: 0x0000001c
EXCVADDR: 0xfecd2c9c  LBEG    : 0x4008cb31  LEND    : 0x4008cb41  LCOUNT  : 0xffffffff

ELF file SHA256: 0000000000000000

Backtrace: 0x400d1437:0x3ffe9de0 0x400d1537:0x3ffe9e00 0x4008153f:0x3ffe9e20 0x4008f102:0x3ffe9e50

Rebooting...

Any ideas?

@ivankravets
Copy link
Member

pio device monitor -f esp32_exception_decoder. See https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#filters

@wezzix
Copy link

wezzix commented Oct 17, 2021

TL; DR, Basically just add one line to your platform.ini

[env:your_device]
monitor_filters = esp32_exception_decoder

Wouldn't it be fantastic if this could somehow be the default...

@tablatronix
Copy link

tablatronix commented Nov 9, 2021

What would cause
Error: (25, 'Inappropriate ioctl for device')
on osx

@ivankravets
Copy link
Member

@tablatronix what is your macOS version? Try to remove ~/.platformio/python3 and ~/.platformio/penv folders, restart VSCode.

@tablatronix
Copy link

I am not using vscode, cli, but I will poke around a bit in python

@ivankravets
Copy link
Member

You don't need VSCode, just remove those folders and use installer script https://docs.platformio.org/en/latest/core/installation.html#super-quick-mac-linux.

It seems you installed PlatformIO Core globally where there is an outdated pyserial package.

@egnor
Copy link
Contributor

egnor commented Jun 30, 2022

As a breadcrumb for others, if you're adding the filter and it's not doing anything, make sure you have build_type = debug in your platformio.ini (#393)

dhebbeker added a commit to Task-Tracker-Systems/Task-Tracker-Device that referenced this issue Apr 28, 2023
dhebbeker added a commit to Task-Tracker-Systems/Task-Tracker-Device that referenced this issue Apr 30, 2023
See [comment][1].

Do not forget to build in debug-mode. For example in PlatformIO IDE, select as project task 'Advanced' → 'Pre-Debug'. See also [here][2].

To decode backtraces from the Wokwi serial monitor, one can use [this python script][3].

[1]: platformio/platform-espressif32#105 (comment)
[2]: https://docs.platformio.org/en/latest/projectconf/build_configurations.html#build-configurations
[3]: https://github.com/me21/EspArduinoExceptionDecoder
dhebbeker added a commit to Task-Tracker-Systems/Task-Tracker-Device that referenced this issue May 16, 2023
See [comment][1].

Do not forget to build in debug-mode. For example in PlatformIO IDE, select as project task 'Advanced' → 'Pre-Debug'. See also [here][2].

To decode backtraces from the Wokwi serial monitor, one can use [this python script][3].

[1]: platformio/platform-espressif32#105 (comment)
[2]: https://docs.platformio.org/en/latest/projectconf/build_configurations.html#build-configurations
[3]: https://github.com/me21/EspArduinoExceptionDecoder
dhebbeker added a commit to Task-Tracker-Systems/Task-Tracker-Device that referenced this issue May 16, 2023
See [comment][1].

Do not forget to build in debug-mode. For example in PlatformIO IDE, select as project task 'Advanced' → 'Pre-Debug'. See also [here][2].

To decode backtraces from the Wokwi serial monitor, one can use [this python script][3].

[1]: platformio/platform-espressif32#105 (comment)
[2]: https://docs.platformio.org/en/latest/projectconf/build_configurations.html#build-configurations
[3]: https://github.com/me21/EspArduinoExceptionDecoder
dhebbeker added a commit to Task-Tracker-Systems/Task-Tracker-Device that referenced this issue May 16, 2023
See [comment][1].

Do not forget to build in debug-mode. For example in PlatformIO IDE, select as project task 'Advanced' → 'Pre-Debug'. See also [here][2].

To decode backtraces from the Wokwi serial monitor, one can use [this python script][3].

[1]: platformio/platform-espressif32#105 (comment)
[2]: https://docs.platformio.org/en/latest/projectconf/build_configurations.html#build-configurations
[3]: https://github.com/me21/EspArduinoExceptionDecoder
dhebbeker added a commit to Task-Tracker-Systems/Task-Tracker-Device that referenced this issue May 19, 2023
See [comment][1].

Do not forget to build in debug-mode. For example in PlatformIO IDE, select as project task 'Advanced' → 'Pre-Debug'. See also [here][2].

To decode backtraces from the Wokwi serial monitor, one can use [this python script][3].

[1]: platformio/platform-espressif32#105 (comment)
[2]: https://docs.platformio.org/en/latest/projectconf/build_configurations.html#build-configurations
[3]: https://github.com/me21/EspArduinoExceptionDecoder
dhebbeker added a commit to Task-Tracker-Systems/Task-Tracker-Device that referenced this issue May 27, 2023
See [comment][1].

Do not forget to build in debug-mode. For example in PlatformIO IDE, select as project task 'Advanced' → 'Pre-Debug'. See also [here][2].

To decode backtraces from the Wokwi serial monitor, one can use [this python script][3].

[1]: platformio/platform-espressif32#105 (comment)
[2]: https://docs.platformio.org/en/latest/projectconf/build_configurations.html#build-configurations
[3]: https://github.com/me21/EspArduinoExceptionDecoder
Jason2866 added a commit to Jason2866/platform-espressif32 that referenced this issue Apr 11, 2024
fix for extracting LittleFS image content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.