ESP32dev - PIO Unified Debugger - setup problem

Make sure the debug lines (TDI,TDO,TMS,TCK,TRST, GND) are connected correctly.
You can try the console command"pio debug --interface gdb -x .pioinit" to start gdb and connect to target.

I don’t seem to be able to make any further progress. I’m using an ESP32 dev board based on the WROOM32 package. I’ve double checked the wiring and it seems to be correct. I’ve tried all 4 ports as listed in device manager and get the same results for each. Tried the layout value you have suggested. Only other thing I can think is to run up the logic analyser tomorrow and take a look at the signals to see what is happening.

Andy.

Managed to set up debug

With the following in platformio,ini:

debug_tool = custom
#debug_init_break=
debug_server =
$PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/bin/openocd
-d
3
-s
$PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/share/openocd/scripts/
-f
$PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/share/openocd/scripts/interface/ftdi/esp32_devkitj_v1.cfg
-f
$PLATFORMIO_HOME_DIR/packages/tool-openocd-esp32/share/openocd/scripts/board/esp-wroom-32.cfg
-c ‘ftdi_vid_pid 0x0403 0x6011’

Here is the tail of the debug messages

Debug: 121 26018 tcl.c:573 jim_newtap_cmd(): Processing option: -expected-id
Debug: 122 26018 core.c:1304 jtag_tap_init(): Created Tap: esp32.cpu0 @ abs position 0, irlen 5, capture: 0x1 mask: 0x3
Debug: 123 26019 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_target create esp32 esp32 -endian little -chain-position esp32.cpu0 -rtos FreeRTOS
Debug: 124 26020 command.c:143 script_debug(): command - ocd_target ocd_target create esp32 esp32 -endian little -chain-position esp32.cpu0 -rtos FreeRTOS
Debug: 125 26020 target.c:1973 target_free_all_working_areas_restore(): freeing all working areas
Debug: 126 26021 target.c:1973 target_free_all_working_areas_restore(): freeing all working areas
Debug: 127 27020 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 128 27021 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 129 27021 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 130 27022 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 131 27022 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 132 27022 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 133 28022 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 134 28023 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 135 28023 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 136 28023 command.c:364 register_command_handler(): registering ‘ocd_set_permissive’…
Debug: 137 29025 core.c:1304 jtag_tap_init(): Created Tap: esp32.cpu1 @ abs position 1, irlen 5, capture: 0x1 mask: 0x3
Debug: 138 29026 command.c:399 register_command(): command ‘esp32’ is already registered in ‘’ context
Debug: 139 29026 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 140 29027 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 141 30027 command.c:364 register_command_handler(): registering ‘ocd_esp32’…
Debug: 142 30027 command.c:364 register_command_handler(): registering ‘ocd_esp32’…

Yep.
That’s it :slight_smile:
I think will be much easier to edit the “ftdi_vid_pid 0x0403 0x6010” line on esp32_devkitj_v1.cfg
Then you won’t need fancy options on platformio.ini

I can debug esp32 project with ftdi based jtag using just this options on platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

I meant debug on openocd itself. I still don’t seem to have it working as it just seems to stall at that point and never halts the program at any breakpoint I’ve added and doesn’t display anu of the debug info. I’ve ordered a different interface in case this one is a problem

I think I have a driver issue.

I’m getting the following message in the event log.

!Device USB\VID_0403&PID_6011&MI_00\7&296dc3c5&0&0000 was not migrated due to partial or ambiguous match."

Ok, I finally have it working. I missed one set of power loop connections on the miniboard that are more clearly documented here:

Missing these connections has the bizarre result that the FT2232H miniboard is detected as an FT4232H miniboard! So, it really leads you up the garden path. Now I have these loop cables in place, the driver correctly identifes the 2 ports and my config is now very simple. Thanks for your help, I’ve learnt a lot more about how this stuff all hooks together :slight_smile:

1 Like

The 3.3v VIO should be router on the minimodule board… At least they are routed on the ft4232 minimodule that i got my hands on…

Anyway. good that you finally got it working.
Can you please check if the VID/PID was changed too ?

It’s back to what it should be - 6010, so it would have worked right away had I not missed those wires.

This is awesome, by the way. I’m used to debugging with nothing more than the serial port…

I was also mistakenly wiring the FT2232H minimodule.
As wired as documented, the driver correctly recognized FT2232H(vid 0403,pid6010).
I replaced the driver with zadig, but an same error occurred.

Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description ‘Dual RS232-HS’, serial ‘’ at bus location '’

However, the error was solved by the following procedure.

・confirm driver name when using zadig

・Replace the “Dual RS232-HS” in the following directory with the driver name displayed by zadig(“FT2232H MiniModule”) with grep.(recommend back up directory)

%HOMEPATH%/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/interface

・then press F5!!

With the latest FTDI driver, vid and pid of FT2232H do not change, but I think that it is a error caused by different display names of drivers.

2 Likes

This is a bug in platformio.py, see my Pull Request

Thanks! Should be fixed in the latest ESP32 dev/platform.

1 Like

Maybe one of you here can help me out since it seems that this thread already has the attention of some FT2232H users… :slight_smile:
I asked this earlier: Debugging non-funct [OSX | VSC | ESP32 | Minimodule/FT2232H]

tl;dr:
Could any of you share a working demo project with the ESP32 and FT2232H debugging?
I am especially interested in the platformio.ini and any other edited presets (openOCD should have some too?) and the factory/working EEP/config for the FT2232H since I bought another board, not the original minimodule.
Perfect case: a dump of a working FT_prog.exe .xml config file.

Use Mprog to write the default settings on ft2232 eeprom and you are good to go.
No special configuration needed.
Don’t matter if is the “original” minimodule or some re purposed scrap board with a FTDI2232 on it.

Alright, so openOCD just uses an internal (non-system) driver to talk to the FT2232 and changes the settings on the fly?
Anything in/besides the platformio.ini I need to change?
This is what I currently have and it’s not working.

[env:mhetesp32minikit]
platform = espressif32
board = mhetesp32minikit
framework = arduino
monitor_speed = 2000000
monitor_port = /dev/cu.SLAB_USBtoUART
upload_port = /dev/cu.usbserial-13303DRXB
upload_protocol = minimodule
debug_port = /dev/cu.usbserial-13303DRXB
debug_tool = minimodule

monitor_speed = 2000000 ???
The FTDI may support that speed but the serial port standard max speed is 921600

debug_port = /dev/cu.usbserial-13303DRXB ???
I used openOCD and on Windows and Linux until now and i NEVER had to select the debug port.
The OpenOCD found the port by itself.

This is my debug setup and it work’s perfectly on Windows and Linux:

[env:mhetesp32minikit]
platform = espressif32
board = mhetesp32minikit
framework = arduino
monitor_speed = 115200
debug_tool = minimodule

I see you specified the same port for upload and debug. That is WRONG!
The FT2232H has 2 channels: Channel 0 is used for debug and Channel 1 can be used for upload.

That monitor speed works great with all the ESP(32) boards I own.
I defined the debug_port port at some point - but you are right, it its found automatically, doesn’t work either way tho :slight_smile:
And yeah upload / debug port should be different, but firmware in on there anyway, just that debugging session won’t start.
Will try again tomorrow, thanks for the help!

But how would I connect that?
CH1 would be a serial upload to RX/TX, as CH0 is already on the JTAG pins.

But CH0 can upload via JTAG - I just got that working now.
I can clearly spot the JTAG commands here.
But starting debugging still does not work. Although now it just tries for 10 seconds, then stops. Before it kept trying.

Executing task: platformio run --target upload <

Processing mhetesp32minikit (framework: arduino; platform: espressif32; board: mhetesp32minikit)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Espressif 32 > MH ET LIVE ESP32MiniKit
HARDWARE: ESP32 240MHz 320KB RAM (4MB Flash)
DEBUG: CURRENT(minimodule) EXTERNAL(esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 32 compatible libraries
Scanning dependencies…
No dependencies
Retrieving maximum program size .pioenvs/mhetesp32minikit/firmware.elf
Checking size .pioenvs/mhetesp32minikit/firmware.elf
Memory Usage → Redirecting...
DATA: [ ] 4.3% (used 14052 bytes from 327680 bytes)
PROGRAM: [== ] 15.6% (used 204843 bytes from 1310720 bytes)
Configuring upload protocol…
AVAILABLE: esp-prog, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = minimodule
Uploading .pioenvs/mhetesp32minikit/firmware.bin
Open On-Chip Debugger 0.10.0-dev (2018-11-05-04:08)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
WARNING!
This file was not tested with real interface, it is based on code in ft2232.c.
Please report your experience with this file to openocd-devel mailing list,
so it could be marked as working or fixed.
adapter speed: 20000 kHz
esp32 interrupt mask on
Info : ftdi: if you experience problems at higher adapter clocks, try the command “ftdi_tdo_sample_edge falling”
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Detected debug stubs @ 3ffc32bc on core0 of target ‘esp32’
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : Target halted. PRO_CPU: PC=0x400E9ED6 (active) APP_CPU: PC=0x400E9ED6
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Flash mapping 0: 0x10020 → 0x3f400020, 43 KB
Info : Flash mapping 1: 0x20018 → 0x400d0018, 105 KB
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Auto-detected flash size 4096 KB
Info : Using flash size 4096 KB
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 208896 bytes from file .pioenvs/mhetesp32minikit/firmware.bin in 2.936409s (69.473 KiB/s)
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 204976 bytes from file .pioenvs/mhetesp32minikit/firmware.bin and flash bank 0 at offset 0x00010000 in 0.884574s (226.292 KiB/s)
contents match
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 16384 bytes from file /Users/macmaster2/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin in 0.756462s (21.151 KiB/s)
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 15088 bytes from file /Users/macmaster2/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin and flash bank 0 at offset 0x00001000 in 0.276250s (53.337 KiB/s)
contents match
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 4096 bytes from file /Users/macmaster2/Documents/PlatformIO/Projects/debugger_3/.pioenvs/mhetesp32minikit/partitions.bin in 0.545739s (7.330 KiB/s)
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 3072 bytes from file /Users/macmaster2/Documents/PlatformIO/Projects/debugger_3/.pioenvs/mhetesp32minikit/partitions.bin and flash bank 0 at offset 0x00008000 in 0.244253s (12.282 KiB/s)
contents match
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x40000400 (active) APP_CPU: PC=0x40000400
** Programming Started **
auto erase enabled
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
wrote 8192 bytes from file /Users/macmaster2/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin in 0.599838s (13.337 KiB/s)
** Programming Finished **
** Verify Started **
Info : Target halted. PRO_CPU: PC=0x4009171A (active) APP_CPU: PC=0x40000400
read 8192 bytes from file /Users/macmaster2/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin and flash bank 0 at offset 0x0000e000 in 0.256499s (31.189 KiB/s)
contents match
** Verified OK **
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 0 was reset (pwrstat=0x5F, after clear 0x0F).
Info : Target halted. PRO_CPU: PC=0x5000004B (active) APP_CPU: PC=0x00000000
Info : esp32: Core 0 was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32: Debug controller 1 was reset (pwrstat=0x5F, after clear 0x0F).
Info : esp32: Core 1 was reset (pwrstat=0x5F, after clear 0x0F).
shutdown command invoked

OK, so apparently THIS is the solution to my problem:

Adding
[env:debug]
infront of my debugging options in platformio.ini made it work now!

Thanks everyone!

For further reference I will document what I have / did here now:

You can also use env_default option.