Build GDB for ESP32 and QEMU

Viewed 477

I tried to build a gdb for esp32 that works with qemu, but after many attempt, I didn't manage. All my attempts leaded me to the following error message after connecting to the remote target: Remote 'g' packet reply is too long.

Right now I am using the prebuilt version from Ebiroll: https://github.com/Ebiroll/qemu_esp32/blob/master/bin/xtensa-esp32-elf-gdb but I would like to use a newer gdb version than 7.10, did anyone had success with this?

Here is how I built gdb:

git clone --depth 1 --branch esp-2021r2-gdb https://github.com/espressif/binutils-gdb.git
cd binutils-gdb
mkdir -p build
cd build
../configure --without-guile --host=x86_64-pc-linux-gnu --target=xtensa-esp32-elf --disable-werror
make
make install

(note from this branch the patch to apply from the Zephyr project, as described here https://github.com/Ebiroll/qemu_esp32#qemu-esp32, seems to already be included)

I also tried by applying the following patch (no success):

curl -L https://raw.githubusercontent.com/Ebiroll/gdb/master/gdb/xtensa-config.c.qemu --output binutils-gdb/gdb/xtensa-config.c

or patching qemu to fix the value of num_regs (tried 104 and 172, also no success).

1 Answers

Espressif's qemu wiki mentions setting an environment variable to only list the core registers:

export QEMU_XTENSA_CORE_REGS_ONLY=1

This needs to be set in the environment from where qemu will be executed.

My recommendation is to use both qemu and gdb (from the Esp32 tool chain) as provided by Espressif. I have recently used this combination with success. The latest release uses gdb 9.2.

Related