PlatformIO Community

ESP32 debugging does not work with Monterey on MacOS

On my Macbook I just moved to Monterey from Catalina, and ESP32 debugging does not work anymore.
Since it was working before, I assume that the wiring is correct but the new OS has changed the naming of the USB serial interfaces and the overall setup does no start anymore.
I am using an esp32-devkit which is connected and powered by it’s own usb cable, and and ESP-prog board, which is also using it’s own usb cable.
This is my platformio.ini file. It is identical to the version running under Catalina, with the new names of the USB serial interfaces.

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
upload_speed = 921600
upload_port = /dev/cu.usbserial-0001
monitor_port = /dev/cu.usbserial-0001
lib_deps = fastled/FastLED@^3.5.0
board_build.partitions = partitions.csv

debug_port = /dev/cu.usbserial-1414100
debug_tool = esp-prog
debug_init_break = tbreak setup
upload_protocol = esp-prog

the ESP-prog interface is visible 4 times(!).
image

When I upload the code I see the following in terminal:
RAM: [= ] 13.0% (used 42452 bytes from 327680 bytes)
Flash: [==== ] 35.5% (used 698065 bytes from 1966080 bytes)
Building .pio/build/esp32doit-devkit-v1/firmware.bin
esptool.py v3.3
Creating esp32 image…
Merged 25 ELF sections
Successfully created esp32 image.
Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-prog, espota, 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 = esp-prog
Uploading .pio/build/esp32doit-devkit-v1/firmware.bin
Open On-Chip Debugger v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
For bug reports, read

debug_level: 1

adapter speed: 20000 kHz

WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
DEPRECATED! use ‘adapter speed’ not ‘adapter_khz’
adapter speed: 5000 kHz

Error: couldn’t bind gdb to socket on port 3333: Address already in use
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
shutdown command invoked
======================================= [SUCCESS] Took 26.46 seconds =======================================

  • Terminal will be reused by tasks, press any key to close it.

Nothing visible in the debug console.

If I run “start debugging”, this is what I see the following in the debug console:

undefinedOpen On-Chip Debugger v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz
WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
DEPRECATED! use ‘adapter speed’ not ‘adapter_khz’
adapter speed: 5000 kHz

Error: couldn’t bind tcl to socket on port 6666: Address already in use

Reading symbols from /Users/gabriele/Dropbox/Documents/PlatformIO/Projects/debug_test/.pio/build/esp32doit-devkit-v1/firmware.elf…
PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target…

and nothing happens…

Can anybody please give me a hint on what I could do to fix this problem?
Thanks!

That’s suspicious; when debugging is stopped, can you find out what programming is hogging the 3333 TCP port, per this?

I restarted the Mac as I noticed that 3 instantiations of python were running in the background… weird.

After restarting -the esp32 devkit was already connected- I plugged in the esp-prog.
Then I clicked on “run–>start debugging”, and the debug console displayed the following:
undefinedOpen On-Chip Debugger v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
For bug reports, read

adapter speed: 20000 kHz

WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
DEPRECATED! use ‘adapter speed’ not ‘adapter_khz’
adapter speed: 5000 kHz

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 5000 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 : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Reading symbols from /Users/gabriele/Dropbox/Documents/PlatformIO/Projects/debug_test/.pio/build/esp32doit-devkit-v1/firmware.elf…
PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target…
Ignoring packet error, continuing…
warning: unrecognized item “timeout” in “qSupported” response

and then nothing happens…

It looks as if the code in not uploaded to the target.
If I try and upload the code, then this is what I see in terminal (no change in the debug-console):

Linking .pio/build/esp32doit-devkit-v1/firmware.elf
Retrieving maximum program size .pio/build/esp32doit-devkit-v1/firmware.elf
Checking size .pio/build/esp32doit-devkit-v1/firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 13.0% (used 42452 bytes from 327680 bytes)
Flash: [==== ] 35.5% (used 698065 bytes from 1966080 bytes)
Building .pio/build/esp32doit-devkit-v1/firmware.bin
esptool.py v3.3
Creating esp32 image…
Merged 25 ELF sections
Successfully created esp32 image.
Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-prog, espota, 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 = esp-prog
Uploading .pio/build/esp32doit-devkit-v1/firmware.bin
Open On-Chip Debugger v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
For bug reports, read

debug_level: 1

adapter speed: 20000 kHz

WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
DEPRECATED! use ‘adapter speed’ not ‘adapter_khz’
adapter speed: 5000 kHz

Error: libusb_claim_interface() failed with LIBUSB_ERROR_ACCESS
Error: unable to open ftdi device with vid 0403, pid 6010, description ‘’, serial '’ at bus location ‘
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6014, description '
’, serial ‘’ at bus location '
** OpenOCD init failed **
shutdown command invoked

Assertion failed: (jtag_trst == 0), function jtag_checks, file core.c, line 338.
*** [upload] Error -6

The esp-prog board appears with 4 names…
image

If I re-run platformio, disconnect and reconnect the esp-prog, when I try and upload the code, I get again the following:
Building in release mode
Retrieving maximum program size .pio/build/esp32doit-devkit-v1/firmware.elf
Checking size .pio/build/esp32doit-devkit-v1/firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 13.0% (used 42452 bytes from 327680 bytes)
Flash: [==== ] 35.5% (used 698065 bytes from 1966080 bytes)
Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-prog, espota, 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 = esp-prog
Uploading .pio/build/esp32doit-devkit-v1/firmware.bin
Open On-Chip Debugger v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
debug_level: 1

adapter speed: 20000 kHz

WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
DEPRECATED! use ‘adapter speed’ not ‘adapter_khz’
adapter speed: 5000 kHz

Error: couldn’t bind gdb to socket on port 3333: Address already in use
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
shutdown command invoked

and the process holding port 3333:

openocd 1490 gabriele 7u IPv4 0xfac29fd273429b91 0t0 TCP localhost:3333 (LISTEN)

It looks like when I run a clean start of platformio, then I get to point where I am opening a debug session - at least this is the kind of messages I was getting with Catalina:

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 5000 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 : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Reading symbols from /Users/gabriele/Dropbox/Documents/PlatformIO/Projects/debug_test/.pio/build/esp32doit-devkit-v1/firmware.elf…
PlatformIO Unified Debugger → [Redirecting…]
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target…

But then nothing happens… or I am missing something to make it move forward.

If I stop debugging at this point, then python 3.9 remains open in the background, as well as openocd, being the process that holds ports 3333 and 6666…
If I abort these processes, then I can apparently re-run a clean start… apparently.

There probably several things involved, and they need to be resolved one by one in order to find the main cause.

Start with these:

1. Duplicate drivers

You have duplicate drivers installed. That’s why it appears 4 times. It should appear twice as it the chip implements 2 ports.

Most likely, you have both Apple’s FTDI driver as well as the FTDI’s driver for their chip. Remove the outdated FTDI kernel driver:

sudo kextunload /Library/Extensions/FTDIUSBSerialDriver.kext
sudo rm -rf /Library/Extensions/FTDIUSBSerialDriver.kext

2. Upload / debug port

If you use esp-prog as the upload or debug protocol, direct USB communication is used. No serial ports and no /dev/cu... are involved.

So you can and should remove upload_port, upload_speed and debug_port from platformio.ini as they are ignored. They just confuse everybody.

3. Test with the blink sketch

Test the upload and debugging with the blink sketch to rule out that the current firmware is the problem. The firmware can disable or otherwise interfere with debugging.

So the best approach is:

  • first upload the blink sketch using the serial port (upload_protocol = esptool),
  • then test uploading with ESP-Prog (upload_protocol = esp-prog),
  • finally test debugging.

This might not fix it yet. But it narrows it down and hopefully better isolates it.

1 Like

Thanks for your support!
Step by step:

  1. Duplicate drivers. I did run the terminal commands to remove FTDI drivers, but Platformio still displays various USB interfaces, though /dev/cu.usbserial-4 seems to be the one actually supporting esp-prog
  2. Upload / debug port. I did simplify my platformio.ini file as follows:
[env:esp32doit-devkit-v1]
platform = espressif32
framework = arduino
board = esp32doit-devkit-v1
monitor_speed = 115200
upload_protocol = esp-prog
  1. Test with the blink sketch. I can successfully upload the code using “upload_protocol = esp-prog” (using esptool generate errors).
    This is what I see in terminal when directly uploading (right arrow icon at the bottom)
Successfully created esp32 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-prog, espota, 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 = esp-prog
Uploading .pio/build/esp32doit-devkit-v1/firmware.bin
Open On-Chip Debugger  v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
debug_level: 1
adapter speed: 20000 kHz
WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 5000 kHz

** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
shutdown command invoked

If I try “run–>Start debugging”, I get the following in terminal

Building in debug mode
Compiling .pio/build/esp32doit-devkit-v1/src/Blink.cpp.o
Linking .pio/build/esp32doit-devkit-v1/firmware.elf
Retrieving maximum program size .pio/build/esp32doit-devkit-v1/firmware.elf
Checking size .pio/build/esp32doit-devkit-v1/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.9% (used 16148 bytes from 327680 bytes)
Flash: [==        ]  16.2% (used 212701 bytes from 1310720 bytes)
Building .pio/build/esp32doit-devkit-v1/firmware.bin
esptool.py v3.3
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.

and this in the debug-console window

Reading symbols from /Users/gabriele/Dropbox/Documents/PlatformIO/Projects/220823-095027-arduino-blink/.pio/build/esp32doit-devkit-v1/firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = cmsis-dap
PlatformIO: Initializing remote target...
Open On-Chip Debugger v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 5000 kHz
Info : tcl server disabled
Info : telnet server disabled
Error: unable to find a matching CMSIS-DAP device
Assertion failed: (jtag_trst == 0), function jtag_checks, file core.c, line 338.
.pioinit:11: Error in sourced command file:
Remote connection closed

But an ESP-Prog should be an FTDI device, not a CMSIS one. Please explicitly add debug_tool = esp-prog to the platformio.ini.

1 Like

IT WORKED!!!
Thanks a lot for your support!
For the sake of the records, this is the platformio.ini file that works:

[env:esp32doit-devkit-v1]
platform = espressif32
framework = arduino
board = esp32doit-devkit-v1
monitor_speed = 115200
upload_protocol = esp-prog
debug_tool = esp-prog

Even though the ESP-prog board still appears multiple times -and also the devkit usb is visible- apparently platformio does find its way and both debugging and also programming take place via the esp-prog board.
Thanks again!
image

1 Like