Page 1 of 1

esp32 debugging. GDB and single stepping.

Posted: Fri Aug 21, 2026 11:33 am
by mnfisher
An advanced experiment for anyone with a little time to kill!

I came across the esp-prog-2 device - and noticing that it is an esp32-s3, wondered if a similar setup would be possible.

You'll need an esp32-s3 (I used a zero) and a target device to debug (I used an esp32-wroom-32)

Open a command prompt and run framework\export (where framework is the directory of your espressif toolset (I used v5.5 at C:\Espressif\frameworks\esp-idf-v5.5)) and get the usb-bridge source using:

Code: Select all

git clone https://github.com/espressif/esp-usb-bridge.git
cd esp-usb-bridge
Set the target to be esp32-s3 using

Code: Select all

idf.py set-target esp32s3
using

Code: Select all

idf.py menuconfig
make a note of the pins used by the s3 to connect - these are under component config->debug probe configuration and serial handler configuration (nearly at end of the component config section)

Then upload the program to the s3 (put into boot by holding the boot button and pressing reset)

Code: Select all

idf.py -p COMn -b 921600 flash
- note set COMn to the correct COM port (or leave out and it will auto detect, by trying all the com ports)

Now reset the s3 (press reset) - and it will show in windows as a flash drive...


Breath...


Wire the s3 to the esp32 (or your target):

TDO → GPIO 15 on an ESP32=WROOM
TCK → GPIO 13
TDI → GPIO 12
TMS → GPIO 14
BOOT -> GPIO 0
RESET -> EN
TxD -> RxD
RxD to TxD

Power and Ground - I used 5V from the S3 to the 5V pin of the esp32.

Create a simple Flowcode test program - I had a UART - and a local .i incrementing and printing in a loop with a delay...
Compile your test program.

At the command line:

Code: Select all

openocd -f interface/esp_usb_bridge.cfg -f target/esp32.cfg
Which should run openocd

Open a second command prompt and run framework/export as above

cd to your test program directory and upload the test program (the s3 acts a programmer):

Code: Select all

idf.py flash


And run gdb

Code: Select all

xtensa-esp32-elf-gdb -ex "target extended-remote :3333" build/your_project.elf
Set your_project to the name of your test program (eg gdb_test.elf)

gdb is a powerful debugger - and I can't list all the commands here but:

hbreak app_main // Set a (hardware assisted) breakpoint at the start of your program
c // continue - run to a breakpoint
n // next line (step over in FC simulation)
s // step into
info locals // display local variables
monitor reset halt // Stop and reset the target

help all // see all the commands

Good luck and enjoy!

Martin

Re: esp32 debugging. GDB and single stepping.

Posted: Fri Aug 21, 2026 11:40 am
by mnfisher

Re: esp32 debugging. GDB and single stepping.

Posted: Fri Aug 21, 2026 12:05 pm
by mnfisher
To start debugging I found I needed to do:

monitor reset halt
bh app_main
c


It 'should' be possible to flash the target device by dropping a file into the flash drive shown by the esp32-s3. To do this it must be converted to a uf2 file (idf.py uf2) - though my first attempt didn't work (idf.py flash did)

Re: esp32 debugging. GDB and single stepping.

Posted: Sat Aug 22, 2026 5:26 pm
by mnfisher
It's also possible to 'monitor' the UART output - fire up the two cmd prompts as above (and run openocd and gdb) - then run a third (export as above)

idf.py -p COMn monitor - or use PuTTY (or other terminal program)

Note that specifying the COM port is much quicker than allowing the 'auto-detect' mode.

Similarly for flashing the Flowcode program to the target - use:

idf.py -p COMn -b 921600 flash

the monitor / terminal program needs to be shut before attempting to reflash.

Martin