rust-embedded/rust-raspberrypi-OS-tutorials

Debug using Serial Debug Cable

vinaychandra opened this issue · 8 comments

Is it possible to debug using the Serial Debug Cable rather than using a dedicated JTAG?

That is useful to do booting via USB. My question was regarding debugging using GDB.

AFAIK the RPi's JTAG is implemented at the transistor level in the hardware. As a result JTAG requires a JTAG adapter - either built from plans found on the internet and/or hacked together and/or purchased from a dealer like Olimex.

You also might consider emulation using the qemu target in the tutorial's Makefile. Please see this comment #45 (comment) for an example of how to modify the 12_cpu_exceptions_part1 tutorial to connect an instance of gdb-multiarch to qemu running in the docker image provided by the tutorial's author @andre-richter.

If you have questions about my alterations to 12_cpu_exceptions_part1 please feel free to ask in the comments section of the commit.

@vinaychandra Forgot to mention: The reason I answered yes to your original question is that your programs can read/write to the RPi UART and send debug info over the serial->USB converter to a computer running a terminal emulator like PuTTY.

Thanks for the info! Yes, while I do understand that we can send random debug info over UART, I am looking more for gdb support over USB so that breakpoints and watches would work. I also do understand that qemu is an option, but I wanted to see if it is possible to do breakpoint debugging over USB/UART

@vinaychandra I did some research. The Arm® Architecture Reference Manual
Armv8, for Armv8-A architecture profile
chapter D2 AArch64 Self-hosted Debug describes the hardware debugging goodies for the ARM cores on the RPi3 SoC. So it might be possible. Has anyone written a crate that you can just add as a dependency and begin debugging? I don't know.

As @rahealy already pointed out, this is currently not possible.

While it would be possible to come up with a software solution, e.g. implementing a GDB Remote Serial Protocol server in an EL > EL1, this is unfortunately out of the scope for now.

It would be a fun project, but given that JTAG adapters are quite affordable, not worth pursuing in light of the effort that would be needed.

Closing for now since this feature is not on the agenda for the near future.