Dumping Variables On Demand; Running Espcoredump.py - Espressif ESP32-S2 Programming Manual

Table of Contents

Advertisement

Chapter 4. API Guides
broken with error message at the first ROM function. To overcome this issue you can use ROM ELF provided by
Espressif (https://dl.espressif.com/dl/esp32s2_rom.elf) and pass it to 'espcoredump.py'.

4.9.6 Dumping variables on demand

Sometimes you want to read the last value of a variable to understand the root cause of a crash. Core dump supports
retrieving variable data over GDB by attributing special notations declared variables.
Supported notations and RAM regions
• COREDUMP_DRAM_ATTR places variable into DRAM area which will be included into dump.
• COREDUMP_RTC_ATTR places variable into RTC area which will be included into dump.
• COREDUMP_RTC_FAST_ATTR places variable into RTC_FAST area which will be included into dump.
Example
1. In
Project Configuration
2. In your project, create a global variable in DRAM area as such as:
// uint8_t global_var;
COREDUMP_DRAM_ATTR uint8_t global_var;
3. In main application, set the variable to any value and assert(0) to cause a crash.
global_var
=
25;
assert(0);
4. Build, flash and run the application on a target device and wait for the dumping information.
5. Run the command below to start core dumping in GDB, where PORT is the device USB port:
espcoredump.py -p PORT dbg_corefile <path/to/elf>
6. In GDB shell, type p global_var to get the variable content:
(gdb)
p global_var
$1
=
25
'\031'

4.9.7 Running espcoredump.py

Generic command syntax: espcoredump.py [options] command [args]
Script Options
–chip {auto,esp32,esp32s2,esp32s3,esp32c3} Target chip type. Default value is "auto"
--port PORT, -p PORT Serial port device. Either"chip"or"port"need to be
--baud BAUD, -b BAUD Serial port baud rate used when flashing/reading
--gdb-timeout-sec GDB_TIMEOUT_SEC Overwrite the default internal delay
Commands dbg_corefile Starts GDB debugging session with specified corefile
info_corefile Print core dump info from file
Command Arguments
--debug DEBUG, -d DEBUG Log level (0..3)
--gdb GDB, -g GDB Path to gdb
--core CORE, -c CORE Path to core dump file (if skipped core dump will be
Espressif Systems
Menu, enable
COREDUMP TO
specified to determine the port when you have multi-target
connected at the same time.
for gdb responses
read from flash)
1329
Submit Document Feedback
FLASH, then save and exit.
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF