Created
December 18, 2019 16:12
-
-
Save HollisTech/18f7bd2963e9c33fc8b630ff414e13a9 to your computer and use it in GitHub Desktop.
espdecode: decode raw esp32 backtrace data from a log file. Requires PlatformIO.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Decode raw esp32 backtraces in a log file. | |
Requires PlatformIO build environment. | |
.DESCRIPTION | |
Capture a log file with raw 'Backtrace:' data and pass it to this script. | |
The script filters the file, replacing the raw backtrace entries with decoded entries. | |
The filtered data is written to stdout. | |
.PARAMETER firmwarePath | |
The path to the elf firmware for the device, typically sometyhing like: .pio/build/featheresp32/firmware.elf | |
Your path will be specific your device type and configureation. | |
.PARAMETER file | |
The path to your logfile. | |
.PARAMETER pioRoot | |
If you installed PlatformIO in a non standard location, (not $env:USERPROFILE) you need to remedy that here. | |
.EXAMPLE | |
espdecode -file ".\espdecodetest.txt" -firmwarePath ".\.pio\build\featheresp32\firmware.elf" > log.txt | |
#> | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$firmwarePath, | |
[Parameter(Mandatory=$true)] | |
[string]$file, | |
[string]$pioRoot=$env:USERPROFILE | |
) | |
$decode = "$pioRoot/.platformio/packages/toolchain-xtensa32\bin\xtensa-esp32-elf-addr2line.exe" | |
function decodeStack | |
{ | |
param( | |
[string] $stackline | |
) | |
$stackline -split ' ' | foreach-object { | |
& $decode -fp -e $firmwarePath $_ | |
} | |
} | |
try { | |
$content = get-content -LiteralPath $file | |
foreach ($line in $content) { | |
if ($line -match '^Backtrace:.*') { | |
$b = $line -split "Backtrace:" | |
"Backtrace:" | |
decodeStack $b[1].trim() | |
} else { | |
$line | |
} | |
} | |
} | |
catch { | |
Write-Host ($_.Exception.Message -split ' For')[0] -ForegroundColor Red | |
} |
This is more or less obsolete as you can use the built in esp32_exception_decoder if you use platformio's monitor (serial terminal) support.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't have toolchain-xtensa32. I changed it to toolchain-xtensa-esp32 and this script works fine.