Skip to content

Instantly share code, notes, and snippets.

@elFarto
elFarto / Pi-Serial-Debugging.md
Last active September 1, 2024 09:35
Remotely debugging PI over a serial connection

The first thing you'll need is someway to connect to the serial port on the Pi. This can be done with a USB to UART adapter (preferably one that has a individual DuPont connnectors), or via a second Pi (in which case you'll need three DuPont jumper wires, with female ends).

You'll want to be running GDB from the machine/VM that's also building the kernel, as the debugger will need access to all the source code. If you're running the build from a VM, and using a USB-serial adapter you'll need to make sure you can add this device to the VM.

note In theory you should have a cross-compiled GDB, one that runs on your system that is targetted to arm64. I believe Ubuntu has the 'gdb-multiarch' package available that contains a compatible version (I did my testing on Fedora). However, I didn't seem to have any issues using my x86-64 GDB to debug it. It might only be an issue when it needs to disassemble instructions.

The first step is to recompiling the kernel for the target Pi you want to debug. Ensure these c