使用openocd+dap-link调试树莓派4B
2024-7-8
hongxi.zhu
1. 接线方式
这里的dap-link使用的是jtag的方式
dap-link | 树莓派4B |
---|---|
TDI | PIN_37/GPIO26 |
TDO | PIN_18/GPIO24 |
nRST | PIN_15/GPIO22 |
U_TX | PIN_10/GPIO15 |
U_RX | PIN_08/GPIO14 |
TMS/SWDIO | PIN_13/GPIO27 |
TCK/SWCLK | PIN_22/GPIO25 |
GND | GND |
2. 修改OpenOCD的配置
由于使用的是jtag
方式连接树莓派,但是OpenOCD的interface
中的cmsis-dap.cfg
是以swd
方式连接,我们要参考它新建一个cmsis-dap-jtag.cfg
OpenOCD-20231002-0.12.0/share/openocd/scripts/interface/cmsis-dap-jtag.cfg
# SPDX-License-Identifier: GPL-2.0-or-later
#
# ARM CMSIS-DAP compliant adapter
#
# http://www.keil.com/support/man/docs/dapdebug/
#
adapter driver cmsis-dap
transport select jtag
# Optionally specify the serial number of CMSIS-DAP usb device.
# adapter serial 02200201E6661E601B98E3B9
运行OpenOCD
openocd -f interface/cmsis-dap-jtag.cfg -f target/bcm2711.cfg
运行GDB
aarch64-none-linux-gnu-gdb
运行效果如下:
C:\Users\hongxi.zhu>aarch64-none-linux-gnu-gdb
GNU gdb (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 14.2.90.20240526-git
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=aarch64-none-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.linaro.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target extended-remote :3333
Remote debugging using :3333
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0xffffffd84d36560c in ?? ()
(gdb) monitor targets
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0 bcm2711.ap mem_ap little bcm2711.cpu running
1* bcm2711.cpu0 aarch64 little bcm2711.cpu halted
2 bcm2711.cpu1 aarch64 little bcm2711.cpu running
3 bcm2711.cpu2 aarch64 little bcm2711.cpu running
4 bcm2711.cpu3 aarch64 little bcm2711.cpu running
(gdb)