ESP-PROG - openocd path contains "undefined"

I want to debug my ESPCam with esp-prog. When I click on quick access-> Debug-> start debugging, the terminal shows the make output.
udev rules are installed.

The output terminal shows:

undefinedWarning! Ignore unknown configuration option `upload_tool` in section [env:esp32cam]
Warning! Please install `99-platformio-udev.rules`. 
More details: https://docs.platformio.org/page/faq.html#platformio-udev-rules
Preparing firmware for debugging...
Warning! Ignore unknown configuration option `upload_tool` in section [env:esp32cam]
Processing esp32cam (platform: espressif32@2.1.0; board: esp32cam; framework: espidf)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32cam.html
PLATFORM: Espressif 32 (2.1.0) > AI Thinker ESP32-CAM
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) 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)
PACKAGES: 
 - framework-espidf 3.40100.200827 (4.1.0) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - tool-ninja 1.7.1 
 - toolchain-esp32ulp 1.22851.191205 (2.28.51) 
 - toolchain-xtensa32 2.80200.200827 (8.2.0)
Reading CMake configuration...
Library Manager: Installing jomjol_configfile
Warning! Could not find the package with 'jomjol_configfile' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_helper
Warning! Could not find the package with 'jomjol_helper' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_wlan
Warning! Could not find the package with 'jomjol_wlan' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_image_proc
Warning! Could not find the package with 'jomjol_image_proc' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_controlcamera
Warning! Could not find the package with 'jomjol_controlcamera' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_flowcontroll

Warning! Could not find the package with 'jomjol_tfliteclass' requirements for your system 'linux_x86_64'
Library Manager: Installing tfmicro
Warning! Could not find the package with 'tfmicro' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_fileserver_ota
Warning! Could not find the package with 'jomjol_fileserver_ota' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_time_sntp
Warning! Could not find the package with 'jomjol_time_sntp' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_logfile
Warning! Could not find the package with 'jomjol_logfile' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_mqtt
Warning! Could not find the package with 'jomjol_mqtt' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_controlGPIO
Warning! Could not find the package with 'jomjol_controlGPIO' requirements for your system 'linux_x86_64'
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Retrieving maximum program size .pio/build/esp32cam/firmware.elf
Checking size .pio/build/esp32cam/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  21.2% (used 69524 bytes from 327680 bytes)
Flash: [========= ]  86.1% (used 1674453 bytes from 1945600 bytes)
========================= [SUCCESS] Took 10.18 seconds =========================

Environment    Status    Duration
-------------  --------  ------------
esp32cam       SUCCESS   00:00:10.181
========================= 1 succeeded in 00:00:10.181 =========================
undefined/home/john/.platformio/packages/tool-openocd-esp32/bin/openocd: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory
/home/john/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

Needless to say that debug does not start, I guess it has something to do with “undefined” in the opeocd path. Has anyone an idea what causes the above errors ?

There is no upload_tool, only upload_protocol (and debug_tool).

The Xtensa32-GDB binary expects certain dynamic libraries to be installed in your system, it is not linked statically. This has already been discussed before at Problem with esp32 debug for Ubuntu. (undefined symbol: _Py_ZeroStruct) - #13 by maxgerhardt. In your case it looks like you need at least

sudo apt install python2.7 libpython2.7 libusb-1.0-0

or whatever packet manager your distribution uses.

sudo apt install python2.7 libpython2.7 libusb-1.0-0

shows it is already installed.
where does that “undefined” in the path come from ?

undefined/home/john/.platformio/packages/tool-openocd-esp32/bin/openocd: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory
/home/john/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

Good question, I remember getting that too, but it has no effect whatsoever.

Then it starts up now? Or what does

ldd ~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb

output?

Then it starts up now? Or what does

ldd ~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb

output?

(base) john@john-Mint:~$ ldd ~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb
	linux-vdso.so.1 (0x00007ffd63db3000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb226272000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb22624f000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fb22624a000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb2260fb000)
	libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007fb225d8b000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb225b99000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb22629d000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fb225b7b000)

Then it must start up.

What happens on the commandline when you directly execute it?

/home/john/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb

and what’s the latest output when you start debugging in VSCode + PlatformIO?

it appears to work. Output is

(base) john@john-Mint:~$ /home/john/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb
GNU gdb (crosstool-NG esp-2020r2) 8.1.0.20180627-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) 

when I run the debug command in PlatformIO, the build process starts and shows:

Preparing firmware for debugging...
Processing esp32cam (platform: espressif32@2.1.0; board: esp32cam; framework: espidf)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32cam.html
PLATFORM: Espressif 32 (2.1.0) > AI Thinker ESP32-CAM
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) 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)
PACKAGES:
 - framework-espidf 3.40100.200827 (4.1.0)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - tool-ninja 1.7.1
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-xtensa32 2.80200.200827 (8.2.0)
Reading CMake configuration...
Library Manager: Installing jomjol_configfile
Warning! Could not find the package with 'jomjol_configfile' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_helper
Warning! Could not find the package with 'jomjol_helper' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_wlan
Warning! Could not find the package with 'jomjol_wlan' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_image_proc
Warning! Could not find the package with 'jomjol_image_proc' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_controlcamera
Warning! Could not find the package with 'jomjol_controlcamera' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_flowcontroll
Warning! Could not find the package with 'jomjol_flowcontroll' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_tfliteclass
Warning! Could not find the package with 'jomjol_tfliteclass' requirements for your system 'linux_x86_64'
Library Manager: Installing tfmicro
Warning! Could not find the package with 'tfmicro' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_fileserver_ota
Warning! Could not find the package with 'jomjol_fileserver_ota' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_time_sntp
Warning! Could not find the package with 'jomjol_time_sntp' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_logfile
Warning! Could not find the package with 'jomjol_logfile' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_mqtt
Warning! Could not find the package with 'jomjol_mqtt' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_controlGPIO
Warning! Could not find the package with 'jomjol_controlGPIO' requirements for your system 'linux_x86_64'
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing jomjol_configfile
Warning! Could not find the package with 'jomjol_configfile' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_helper
Warning! Could not find the package with 'jomjol_helper' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_wlan
Warning! Could not find the package with 'jomjol_wlan' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_image_proc
Warning! Could not find the package with 'jomjol_image_proc' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_controlcamera
Warning! Could not find the package with 'jomjol_controlcamera' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_flowcontroll
Warning! Could not find the package with 'jomjol_flowcontroll' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_tfliteclass
Warning! Could not find the package with 'jomjol_tfliteclass' requirements for your system 'linux_x86_64'
Library Manager: Installing tfmicro
Warning! Could not find the package with 'tfmicro' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_fileserver_ota
Warning! Could not find the package with 'jomjol_fileserver_ota' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_time_sntp
Warning! Could not find the package with 'jomjol_time_sntp' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_logfile
Warning! Could not find the package with 'jomjol_logfile' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_mqtt
Warning! Could not find the package with 'jomjol_mqtt' requirements for your system 'linux_x86_64'
Library Manager: Installing jomjol_controlGPIO
Warning! Could not find the package with 'jomjol_controlGPIO' requirements for your system 'linux_x86_64'
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Retrieving maximum program size .pio/build/esp32cam/firmware.elf
Checking size .pio/build/esp32cam/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  21.2% (used 69524 bytes from 327680 bytes)
Flash: [========= ]  86.1% (used 1674453 bytes from 1945600 bytes)
========================= [SUCCESS] Took 10.28 seconds =========================

Environment    Status    Duration
-------------  --------  ------------
esp32cam       SUCCESS   00:00:10.283
========================= 1 succeeded in 00:00:10.283 =========================

when build is complete, the whole build output also shows up in the debug window with this added:

   undefined/home/john/.platformio/packages/tool-openocd-esp32/bin/openocd: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory
    /home/john/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

What is strange though is that after I hit the debug button, two tasks show up on the call stack window (left part of screenshot). Shortly after that I sometimes get a pop up error that complains about multiple requests to rebuild the code index. I get the feeling that somehow two tasks are triggered when I hit debug.

Something is very wrong there. If it starts up in the shell, and PlatformIO uses has the same environment available, it should start up. It makes no sense.

Can you

  1. disable all other extensions except C/C++ by Microsoft and PlatformIO,
  2. Grab the known-good project at platform-espressif32/examples/espidf-blink at develop · platformio/platform-espressif32 · GitHub
  3. Import it and switch to it using the project environment switcher
  4. Select the “PIO Debug (espidf-blinky)” configuration in the debugger, and start debugging?

No success. I did

  1. remove VSCode completely, reinstall it.
  2. install platformio.
  3. copy the contents of the “known good” git folder (extracted the zip)
  4. open vscode, On the platformio welcome screen click open project.
  5. go to espidf-blink
  6. klick the platformio icon on the left, choose build

output is:

> Executing task in folder espidf-blink: platformio run <

Processing esp32dev (platform: espressif32; framework: espidf; board: esp32dev)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.3.2) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) 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)
PACKAGES: 
 - framework-espidf 3.40300.0 (4.3.0) 
 - tool-cmake 3.16.4 
 - tool-esptoolpy 1.30100.210531 (3.1.0) 
 - tool-ninja 1.7.1 
 - toolchain-esp32ulp 1.22851.191205 (2.28.51) 
 - toolchain-xtensa32 2.80400.210211 (8.4.0)
Reading CMake configuration...
Generating assembly for certificate bundle...
CMake Error at /home/john/.platformio/packages/framework-espidf/tools/cmake/scripts/data_file_embed_asm.cmake:26 (file):
  file failed to open for reading (No such file or directory):

    /home/john/VScodeWorkspaces/espblink/examples/espidf-blink/.pio/build/esp32dev/x509_crt_bundle


*** Error 1
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
*** [.pio/build/esp32dev/.pio/build/esp32dev/x509_crt_bundle.o] Source `.pio/build/esp32dev/x509_crt_bundle.S' not found, needed by target `.pio/build/esp32dev/.pio/build/esp32dev/x509_crt_bundle.o'.
===================================================================================================================== [FAILED] Took 4.28 seconds =====================================================================================================================
The terminal process "platformio 'run'" terminated with exit code: 1.

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

Indeed, there is no .pio folder… not even a hidden one.

Since the systax highlighting in the code errored that arduino.h could not be included, I also installed the arduino add-on- but with no success. I guess its a highlighting error since it is not showing up in the output.

ok, I was using the espidf-Ardunino example, but its the same for the other one:

But that’s a different error now, try resolving it via Problems building with ESP-IDF latest version (4.3.0) - #4 by maxgerhardt.

(The file should be locally in <home folder>/.platformio/packages/framework-espidf/components/mbedtls/esp_crt_bundle/cacrt_all.pem)

disabling the certificates package with the menu did the trick. Just deleting the one mentioned in the topic did not.
Also, I did add to platformio.ini:

upload_port = /dev/ttyUSB1
debug_tool = esp-prog
debug_port = /dev/ttyUSB0
debug_init_break = tbreak loop



undefinedOpen On-Chip Debugger v0.10.0-esp32-20210721 (2021-07-21-13:33)

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.

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

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 : Listening on port 3333 for gdb connections

Reading symbols from /home/john/VScodeWorkspaces/espblink/examples/espidf-blink/.pio/build/esp32dev/firmware.elf...

done.

PlatformIO Unified Debugger -> http://bit.ly/pio-debug

PlatformIO: debug_tool = esp-prog

PlatformIO: Initializing remote target...

.pioinit:11: Error in sourced command file:

/dev/ttyUSB0: Datei oder Verzeichnis nicht gefunden.

I noticed that before firing up the debugger, pio-devices show both, USB0 and 1 available. I did successfully upload via USB1 before, so USB0 must be the JTAG,
After activating the debugger USB0 is gone. If I re-plug the esp-prog adapter, it re-appears.

Your debug port is not a serial adapter ttyUSB0, it’s a USB device. Remove debug_port, the adapter will be found by OpenOCD through the USB VID/PID and description.

Thanks, that’s it. Its working now. Premium support !
Can I paypal you a beer ?

Good to hear that it’s working now. I don’t have my paypal address in my profile (and also not expecting donations for the regular support I’m doing here anyways), but I sent you a PM if you really want to :smiley:

Could you please explain what do you mean by “disabling the certificates package with the menu”?
I am facing the same problem currently and do not understand how to fix it.

on the left side of VSC, click on the platformio icon. That opens a menu. Also on the left side, look for a sub menu that says run menu config. That starts a script in the output window that shows a config menu.

(Top) → Component config → mbedTLS → Certificate Bundle- Disable it
Save
quit

1 Like