Debugging Raspberry Pi 4 through JTAG using JLink and OpenOCD
Hardware environment:
- One Raspberry Pi, this routine uses Raspberry Pi OS 64 bit system, and can be used on any other Raspberry Pi operating system
- Host win10, install openocd and gdb (this routine includes openocd and gdb multiarch installed in mingw64, which can also be done on Linux)
- One JLink ARM simulator with 8 DuPont cables
Enable Raspberry Pi JTAG pins
Edit config.txt in the root directory of the Raspberry Pi image and add enable_jtag_gpio=1
Raspberry Pi and JLink Connection
Install JLink driver (this step can be skipped under Linux)
It should be noted that OpenOCD does not use the original driver of JLink. It only treats JLink as a regular USB device, so it is necessary to use the zadig tool to reinstall the USB driver for JLink
Start openocd
Edit and save raspberry4.cfg
Start openocd
OpenOCD defaults to starting gdbserver service on port 3333 and telnet service on port 4444
Start GDB
Gdb multiarch, as the name suggests, is a gdb that supports multiple architectures