This evening I spent some time playing around with the new Visual Studio Code plugin for the Xtensa ESP32 microcontrollers.
It was painful. Even for regular Eclipse users.
Everytime I wanted to start a debugging session using my FTDI FT2232HL JTAG-interface a window with a warning sign and no text popped up.
Having a closer look at the error logs there seemed to be something unhealthy regarding OpenOCD:
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_NO_DEVICE
Error: error while flushing MPSSE queue: -4
Error: libusb_handle_events() failed with LIBUSB_ERROR_NO_DEVICE
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_NO_DEVICE
Error: error while flushing MPSSE queue: -4
Error: Failed to exec JTAG queue!
Error: Failed to read debug stubs address location (-4)!
? Polling target esp32.cpu0 failed, trying to reexamine
Error: libusb_handle_events() failed with LIBUSB_ERROR_NO_DEVICE
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_NO_DEVICE
Error: error while flushing MPSSE queue: -4
Examination failed, GDB will be halted. Polling again in 6300ms
? Error: libusb_handle_events() failed with LIBUSB_ERROR_NO_DEVICE
Error: unable to purge ftdi rx buffers: LIBUSB_ERROR_NO_DEVICE
… and …
Failed to wait for target state 1! Current state 2
After poking it for a while it turned out that version v4.4.1 of ESP-IDF is having a buggy OpenOCD version causing all this mess.
Upgrading it manually to version v0.11.0-esp32-20220411 solved this issue.
Another issue was caused by a hidden Python 2 dependency comming from gdb
giving me a “Failed to Init Debug Adapter”-message.
had@es-workstation:~$ ./xtensa-esp32-elf-gdb
./xtensa-esp32-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
Either install Python 2 or upgrade to a newer version like esp-gdb-v11.1_20220318.