Debugging Problems

I have been trying for several days now to set up debugging for esp32 boards. I have tried both an ftdi mini-module and an esp-prog board. I have changed computers and tried and tried different combinations of esp32 (pico and wroom-32) and jtag (ftdi and esp-prog) boards. This would suggest a setup error. I’ve searched the community forum. I’ve done all the usual checks. I have: checked, rechecked and re-setup the wiring numerous times and verified against several tutorials and the original datasheets. TCK - IO13, TDI-IO12, TDO - IO15, TMS - IO14; plus GND - GND; set up winusb on the ftdi and esp-prog channel 0; tried shorter cables, reduced the adapter speed etc., tried different configuration files etc; used different laptops but all to no avail, checked the debug-tool setting in platform.ini. So I am really at a loss of what to try next.

Any thoughts would be very much appreciated.

Below is a short extract of the error log:

Info : FreeRTOS creation
adapter speed: 20000 kHz

Info : tcl server disabled
Info : telnet server disabled
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 20000 kHz
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Info : accepting 'gdb' connection from pipe
Warn : No symbols for FreeRTOS!
Error: Target not examined yet
Error executing event gdb-attach on target esp32.cpu0:

Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Error: error during select: Unknown error
.pioinit:11: Error in sourced command file:
Remote communication error.  Target disconnected.: No error.

It’s still at 20MHz here.

Last time it was a bit fiddly to change the adapter speed – I’ll have a look again. Newer platform-espressif32 versions ignore the value written in the .cfg file because they issue an explicit -c set adapter_khz .. command in the openocd invocation.

I’ve opened Make adapter_speed changable in platformio.ini · Issue #459 · platformio/platform-espressif32 · GitHub to make this dynamically changable.

The only way to change it right now would be to modify the board’s JSON manifest file. E.g., when I use the platformio.ini

platform = espressif32
board = esp32dev
framework = arduino
upload_protocol = esp-prog

it uses C:\Users\<user>\.platformio\platforms\espressif32\boards\esp32dev.json and the debug attributes

Must be expanded with an entry "adapter_speed": 200" (to e.g. set it to 200kHz), while adding a comma to the entry before it.

  "debug": {
    "openocd_board": "esp-wroom-32.cfg",
    "adapter_speed" : 200

Then the openocd invocations are changed accordingly, example

openocd -d2 -s C:/Users/Max/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp-wroom-32.cfg -c “adapter_khz 200” -c "program_esp {{.pio\build\esp32dev\firmware.bin}} 0x1000