Chapter 4. API Guides
What is the meaning of debugger’s startup commands? On startup, debugger is issuing sequence of commands
to reset the chip and halt it at specific line of code. This sequence (shown below) is user defined to pick up at most
convenient / appropriate line and start debugging.
• set remote hardware-watchpoint-limit 2 —Restrict GDB to using two hardware watchpoints
supported by the chip, 2 for ESP32-S2. For more information see https://sourceware.org/gdb/onlinedocs/gdb/
Remote-Configuration.html.
• mon reset halt —reset the chip and keep the CPUs halted
• flushregs —monitor (mon) command can not inform GDB that the target state has changed. GDB will
assume that whatever stack the target had before mon reset halt will still be valid. In fact, after reset the
target state will change, and executing flushregs is a way to force GDB to get new state from the target.
• thb app_main —insert a temporary hardware breakpoint at app_main, put here another function name
if required
• c —resume the program. It will then stop at breakpoint inserted at app_main.
Configuration of OpenOCD for specific target There are several kinds of OpenOCD configuration files (*.
cfg). All configuration files are located in subdirectories of share/openocd/scripts directory of OpenOCD
distribution (or tcl/scripts directory of the source repository). For the purposes of this guide, the most impor-
tant ones are board, interface and target.
• interface configuration files describe the JTAG adapter. Examples of JTAG adapters are ESP-Prog and
J-Link.
• target configuration files describe specific chips, or in some cases, modules.
• board configuration files are provided for development boards with a built-in JTAG adapter. Such files in-
clude an interface configuration file to choose the adapter, and target configuration file to choose the
chip/module.
The following configuration files are available for ESP32-S2:
Table 5: OpenOCD configuration files for ESP32-S2
Name Description
board/esp32s2-
kaluga-1.cfg
Board configuration file for ESP32-S2-Kaluga-1, includes target and adapter config-
uration.
target/esp32s2.
cfg
ESP32-S2 target configuration file. Can be used together with one of the inter-
face/ configuration files.
interface/ftdi/
esp32s2_kaluga_v1.
cfg
JTAG adapter configuration file for ESP32-S2-Kaluga-1 board.
interface/ftdi/
esp32_devkitj_v1.
cfg
JTAG adapter configuration file for ESP-Prog boards.
If you are using one of the boards which have a pre-defined configuration file, you only need to pass one -f argument
to OpenOCD, specifying that file.
If you are using a board not listed here, you need to specify both the interface configuration file and target configuration
file.
Custom configuration files OpenOCD configuration files are written in TCL, and include a variety of choices for
customization and scripting. This can be useful for non-standard debugging situations. Please refer to OpenOCD
Manual for the TCL scripting reference.
OpenOCD configuration variables The following variables can be optionally set before including the ESP-specific
target configuration file. This can be done either in a custom configuration file, or from the command line.
The syntax for setting a variable in TCL is:
Espressif Systems 1384
Submit Document Feedback
Release v4.4