BSP5.7 "gdbserver not found"

Hi all,
I have created a “Minimal Toradex Reference Image” (BSP 5.7) with yocto which runs fine on my Colibri i.MX7D-emmc module.
I also installed the cross compiler toolchain on Ubunbtu 22.04 (gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf) together with Eclipse (version 2022-12 (4.26.0)).
Running a simple “hello world” program works (remote connection is thus correctly set up and working).

But now I want to debug my application and that’s where things get complicated : when starting the debug, the executable is copied to the target but eclipse complains about not being able to start the gdbserver on the remote host.
gdbserver is simply not part of the ‘minimal image’ I made.

My questions are therefore:

  • How do I install gdbserver on the target ?
  • Is it possible to simply install it with e.g. opkg or do I have to add gdbserver to the yocto-generated image ?
  • And how do I do that ?

As always, your help will be greatly appreciated!!!

Best regards,
Jeroen

(P.S. I almost had the same question in june last year. At that time it was with an old Angstrom image. After that, I migrated to TorizonCore with Visual Studio Code which worked (although I’m not a fan of VSC and Docker). Now I’m back to BSP 5.7 for some other technical reasons…)

Hi @ompie,

For BSP 5.7, you can add the gdbserver package by adding the following line to your local.conf file:

IMAGE_INSTALL_append = " gdbserver"

Then run bitbake again. This will produce the image with the required package installed. If you need to install more packages, you can do that by adding them separated with a space:

 IMAGE_INSTALL_append = " gdbserver package1 package2"

Let me know if you need anything.

Best Regards,
Hiago.

1 Like

Hi @ompie,

Using IMAGE_INSTALL_append (or IMAGE_INSTALL:append as the new syntax from YP 3.4 Honister on) certainly works. The yocto-ish way of adding debugging tools to a target build is to add tools-debug to EXTRA_IMAGE_FEATURES in conf/local.conf. tools-debut does not only install gdbserver but other useful tools for debugging such as strace.

Cheers,
Rudi

2 Likes

Hello @hfranco.tx and @RudolfStreif,

Thanks to both of you for your help.
Both methods do indeed add gdb to the image and have the same result. That is, instead of not being able to start the remote gdbserver, I get an error message in eclipse:

Error in final launch sequence:
Failed to execute MI command:
-target-select remote colibri-imx7-emmc-06596549.local:2345
Error message from debugger back end:
Remote 'g' packet reply is too long (expected 312 bytes, got 328 bytes): 
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020fdff7e00000000805bfd76100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

The console (also in eclipse) shows that there is at least something going on at the module since the program to be debugged (“hello”) is started:

root@colibri-imx7-emmc-06596549:~# gdbserver :2345 /home/root/hello;exit
Process /home/root/hello created; pid = 412
Listening on port 2345
Remote debugging from host ::ffff:192.168.0.26, port 41610
Remote side has terminated connection. GDBserver will reopen the connection.
Listening on port 2345

I got the same behavior with
IMAGE_INSTALL_append = " gdbserver"
and
EXTRA_IMAGE_FEATURES ?= "debug-tweaks package-management tools-debug"
(“debug-tweaks” and “package-management” were already assigned, I just added “tools-debug”)

So both answers are the solution to my initial question, but would you have any idea of the reason for the error ? (perhaps the eclipse version is too new ?)

Best regards,

Jeroen

Hello @hfranco.tx and @RudolfStreif,

The Remote 'g' packet reply is too long error simply came from the fact that I forgot to specify the path to the “cross” version of gdb (arm-none-linux-gnueabihf-gdb instead of gdb) in the debug configuration.
Now everything is fine and I’m able to debug.

Thanks a lot to both of you.

Best regards,
Jeroen

1 Like