I had a memory corruption crash/reset loop that took me a couple of days of sifting through function by function on a fairly large project with Arduino Nano ESP32. I got it in the end String related...didn't use c_str() where needed! It had been lurking for a while, so backing out recent code changes didn't help
Reminds me of why I'm happy to use C# in my day job instead of C++ nowadays...
It occurred to me that in my old Unix C++ days (1990s) we used to get a core dump to analyse crashes.
From a bit of searching, it looks like the raw ESP32 does do a core dump, but I cannot find any info on how to get it on an Arduino Nano ESP32. Is it possible to do this/access the core dump on the Arduino?
Absolutely so
You have two options to get this info on the Nano ESP32:
- if you have a 3.3V (LVTTL) USB-to-serial adapter handy, you can connect it to the board's RX0 and TX1 pins. When such a crash happens, a lot of memory addresses will be printed there - that is the stack trace leading to the failure.
- you can get the same result without an USB-to-serial dongle by using the method described in the Debugging on the Nano ESP32 page to load your sketch. The reason is that enabling the 'hardware CDC' mode forces the backtrace to be output on the virtual USB (and be readable from the IDE's Serial Monitor).
Once you get that stack trace information, you can use addr2line or tools like the "ESP stack trace decoder" that will parse the compiled ELF file and output a readable backtrace with file:line information.
[quote="lburelli, post:2, topic:1364865"]
I managed to get and set up an ST232RL module and get some output from a deliberate error.
addr2line line worked a treat! Very useful. Wish I'd known about this earlier!
However, I couldn't really get anything useful from "readelf". Are there some magic options to get a mapping of address line to source code line at all? What is this command usually used for?
I did download a (windows) gui called ELFView to see what I could see, but looks like it doesn't support the processor (Xtensa)...
FYI I did dlownload the Exception Stack Trade Decoder, but it's just a jar file. I assume it's not windows friendly as all instructions were for linux by the look of it
Glad I could help! Yes, addr2line is quite old but still great for the task.
Something more modern could be this online page (I haven't tried it, but if it does what it says, it's great!
).
readelf and ELFView are very different tools. They don't really help you much with decoding a stack trace, but they will tell you all about what's inside the ELF file you give them. They are very useful for reverse engineering, quite literally - you can point them at a compiled binary and decode how it's made up! 
Looks interesting. I'm sure it won't be long before I will have use for that site!
Thanks again.