i have an esp32 and an st-link and i want to know how to debug the esp32 with the stlink
Do you have the cheap one where only SWDIO+SWDCLK are exposed or the genuine one that has all JTAG signals exposed?
Okay, then let’s make an experiment first. First of all, stlink is not currently supported in platform-espressif32, however it looks to me like OpenOCD actually supports it.
First of all, update your ST-Link V2 firmware to the latest using STSW-LINK007 - ST-LINK, ST-LINK/V2, ST-LINK/V2-1, STLINK-V3 boards firmware upgrade - STMicroelectronics due to this note.
Then, connect the ST-Link’s JTAG signals to the ESP32’s JTAG signals. See the pinouts for them here page 12+13, or more easily here and here for the ESP32.
Then try and establish a connection to the ESP32 with OpenOCD. For that download the latest binary distribution for OpenOCD at Releases · espressif/openocd-esp32 · GitHub.
Then, open a commandline (assuming Windows: Windows+R → cmd.exe
), cd
into the downloaded + extracted OpenOCD directory and execute OpenOCD as follows
bin\openocd.exe -s share\openocd\scripts -f interface\stlink-dap.cfg -c "transport select dapdirect_jtag" -f board\esp32-wrover.cfg
Can it establish a connection?
is it also possible in linux
and is this firmware the right one:
Sure, why not. Download the latest OpenOCD linux release (from the same page) and adapt the paths and filenames (no .exe
, forward slash instead of backslash).
i downloaded it replaced the \ with / and ran it (of course deleteng .exe in the command) and it threw this error:
[hannes@Hannes-GUSCHTAV openocd-esp32]$ bin/openocd -s share/openocd/scripts -f interface/stlink-dap.cfg -c “transport select dapdirect_jtag” -f target/esp32-wrover.cfg
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
dapdirect_jtag
embedded:startup.tcl:26: Error: Can’t find target/esp32-wrover.cfg
in procedure ‘script’
at file “embedded:startup.tcl”, line 26
My bad, must be board/esp32-wrover.cfg
, not target/...
. I corrected the initial command.
Delete the -c "transport select dapdirect_jtag"
part of the command, or if that does not work, remove the
transport select jtag
line in target/esp32.cfg
.
3.13V target voltage seems a bit low. Are you powering your ESP32 board with its USB cable properly? (VTarget should still be connected even if the board is externally powered)
Double checked all JTAG connections linked above?
Using the original transport select jtag
does not work at all?
is vcc on the programmer pinout vtarget?
i have connected the power to the esp32 vie the micro usb plug
still doesnt connect i tried swapping tdi and tdo no luck
it still does the same thing
please post a connection diagram between the st-link and the esp32 wemos d1 mini
I don’t have further information than what I referenced in here:
Please open an issue at Issues · espressif/openocd-esp32 · GitHub for further help.
i saw this:
but i have an esp32-wroom on the wemos d1 mini esp32
maybe thats the problem?
Using -f board/esp-wroom-32.cfg
makes a difference?
sadly no diference
but i posted a issue on github: ESP32 jtag with st-link not working (OCD-646) · Issue #254 · espressif/openocd-esp32 · GitHub
if i should change something then write
Just as a last guess, does it help in any way to hold down the reset button and release it when OpenOCD starts up? Timing might be tricky. There may be missing OpenOCD config lines to use the hardware-reset of the ST-Link. On the other hand, I’ve also seen people explicitly not making this connection it worked (TRST).