janLo / EspArduinoExceptionDecoder

Python Script to decode ESP8266 Exceptions.
GNU General Public License v3.0
59 stars 25 forks source link

Use for ESP32 backtrace #8

Open brightproject opened 1 year ago

brightproject commented 1 year ago

Tell me, can this tool decode backtrace? Backtrace: 0x400837c1:0x3ffb1f10 0x4008cca1:0x3ffb1f30 0x40092749:0x3ffb1f50 0x40083cfe:0x3ffb2080 0x40092779:0x3ffb20a0 0x400ea0be:0x3ffb20c0 0x400ea0cd:0x3ffb20e0 0x400d3905:0x3ffb2100 0x400dc8a6:0x3ffb2210 0x400ec659:0x3ffb2290 And in general, can I use the tool without a toolchain? I am using arduino IDE with arduino cli. I tried to "feed" a line to your script, but got an error.

C:\Users\Admin\Documents\Arduino\tools\EspArduinoExceptionDecoder-master>decoder.py -p ESP32 -e ELF {PATH}\esp32_test.ino.elf
usage: decoder.py [-h] [-p {ESP8266,ESP32}] [-t TOOL] -e ELF [-f] [-s] file
decoder.py: error: the following arguments are required: file

In {PATH} my path in Windows 10 to arduino *eif file.

Error:

ERROR: addr2line not found (C:\Users\Admin\.platformio\packages\toolchain-xtensa\bin/xtensa-esp32-elf-addr2line)
ERROR: elf file not found (C:\Users\Admin\Documents\Arduino\tools\EspArduinoExceptionDecoder-master\ELF)
Traceback (most recent call last):
  File "C:\Users\Admin\Documents\Arduino\tools\EspArduinoExceptionDecoder-master\decoder.py", line 304, in <module>
    parser.parse_file(file, args.stack_only)
  File "C:\Users\Admin\Documents\Arduino\tools\EspArduinoExceptionDecoder-master\decoder.py", line 142, in parse_file
    for line in file:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\encodings\cp1251.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 5847: character maps to <undefined>
janLo commented 1 year ago

Unfortunately I haven't used this tool in a long time because my spare-time budget is eaten up by the family (which isn't a bad thing though ;) ). So my answer here is based on rusty memory.

It definitely needs the toolchain available. The Arduino IDE should ship with the toolchain as it needs to compile the code. You probably just need to find the right path. Unfortunately I've never used the Arduino IDE myself and I don't own a windows license so I cannot guide you here. By the way: I've always used platformio and found it much more convenient.

The file argument the script is complaining about is a file with the backtrace content. You can use a simple dash to indicate that you feed it via stdin.

With --elf you should specify the path to the compiled unstripped elf binary of your code. I think the addr2line tool needs this to translate offsets to code positions.

The path to the toolchain is given via --tool and you should specify --platform ESP32 if you want to decode ESP32 traces.

For more information you might need to look at the README or read the script itself. It doesn't do any black magic if I remember correctly 😉