Debug aborts with python error

Hi altogether,

I’m trying to debug a simple sketch (blink) with my new ESP32 S3 board, but unfortunately aborts with a wierd error message from python

piodebuggdb -v -e esp32S3
Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
Info : only one transport option; autoselect 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
adapter speed: 40000 kHz

Warn : Transport "jtag" was already selected
adapter speed: 5000 kHz

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: serial (24:58:7C:CD:A6:48)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 5000 kHz
Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : starting gdb server for esp32s3.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
My platformio.ini looks like that
platform = espressif32
; board = esp32-s3-devkitm-1
board = esp32-s3-devkitc-1-n16r8v
upload_port = /dev/ttyACM0
test_port = /dev/ttyACM0
monitor_port = /dev/ttyACM0
build_flags = 
    -D SPEED=921600
    -D ESP32S3
debug_tool = esp-builtin
debug_init_break = break setup
build_type = debug  

I’ve no idea what python is trying to tell me as the module should be present

python3 -m site
sys.path = [
USER_BASE: '/home/hst/.local' (exists)
USER_SITE: '/home/hst/.local/lib/python3.6/site-packages' (exists)

In the meantime - with having much fun while debugging the debugger :wink: - I think I’ve found the origin of the strange python error. It’s the missing support for python 2.7 on my system.

piodebuggdb spawns to the real debugger - in my case xtensa-esp32s3-elf-gdb - which is dynamically linked to Unfortunately this python version is not supported in my distribution (openSUSE 15.6). To circumvent the inevitable linkage error I had manually installed a time ago to solve another problem with this missing lib.

Now I must hope that this already known issue is fixed soon :crossed_fingers:

After some kind of one-man-hackathon, I’ve found a solution or at least a workaround :grin:

Following the instructions from espressif I build my own toolchain:

mkdir ~/esp
cd ~/esp
git clone -b v5.2.2 --recursive
cd ~/esp/esp-idf
./ esp32s3

And then I replaced the dysfunctional debugger

cd ~/.platformio/packages/toolchain-xtensa-esp32s3/bin
mv xtensa-esp32s3-elf-gdb xtensa-esp32s3-elf-gdb.orig
cp ~/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin/xtensa-esp32s3-elf-gdb xtensa-esp32s3-elf-gdb
cp ~/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin/xtensa-esp-elf-gdb-no-python .
cp ~/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/lib/ ../lib

(the 2 additional files are necessary) - et voilà

Same solution works for an ESP32 (with some minor changes in naming :wink:)

  1. ./ esp32
  2. cd .platformio/packages/toolchain-xtensa-esp32/bin/
  3. mv xtensa-esp32-elf-gdb xtensa-esp32-elf-gdb.orig
  4. cp ~/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin/xtensa-esp32-elf-gdb .
  5. cp ~/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin/xtensa-esp-elf-gdb-no-python .
  6. cp ~/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/lib/ …/lib/
1 Like

Had debug console throwing following error when trying to start debug session with ESP-PROG and NodeMCU-32S :

error while loading shared libraries: cannot open shared object file: No such file or directory

I followed your instructions and now debugging works like a charm. I’m running Ubuntu 24.04