1. openocd安装
安装依赖包
sudo apt-get install make libtool pkg-config autoconf automake texinfo gdb-multiarch
下载openocd软件
git clone https://git.code.sf.net/p/openocd/code openocd-code
编译安装
cd openocd-code
./bootstrap
./configure
make
sudo make install
2. 树莓派与jlink/串口连线
jlink v11管脚图:
树莓派管脚图
树莓派与J-Link仿真器连接
JTAG接口 | 树莓派管脚 | 树莓派管脚名称 |
TRST | 15 | GPIO22 |
RTCK | 16 | GPIO23 |
TDO | 18 | GPIO24 |
TCK | 22 | GPIO25 |
TDI | 37 | GPIO26 |
TMS | 13 | GPIO27 |
VTref | 01 | 3.3v |
GND | 39 | GND |
3. 拷贝benos代码到sd卡
sd卡需要格式化为FAT32格式
拷贝所有文件到sd卡中
4. raspi4.cfg配置文件
在/usr/local/share/openocd/scripts/interface目录下新建raspi4.cfg文件
set _CHIPNAME bcm2711
set _DAP_TAPID 0x4ba00477
adapter_khz 1000
transport select jtag
reset_config trst_and_srst
telnet_port 4444
# create tap
jtag newtap auto0 tap -irlen 4 -expected-id $_DAP_TAPID
# create dap
dap create auto0.dap -chain-position auto0.tap
set CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000}
set DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000}
set _cores 4
set _TARGETNAME $_CHIPNAME.a72
set _CTINAME $_CHIPNAME.cti
set _smp_command ""
for {set _core 0} {$_core < $_cores} { incr _core} {
cti create $_CTINAME.$_core -dap auto0.dap -ap-num 0 -ctibase [lindex $CTIBASE $_core]
set _command "target create ${_TARGETNAME}.$_core aarch64 \
-dap auto0.dap -dbgbase [lindex $DBGBASE $_core] \
-coreid $_core -cti $_CTINAME.$_core"
if {$_core != 0} {
set _smp_command "$_smp_command $_TARGETNAME.$_core"
} else {
set _smp_command "target smp $_TARGETNAME.$_core"
}
eval $_command
}
eval $_smp_command
targets $_TARGETNAME.0
5. openocd连接树莓派
#cd /usr/local/share/openocd/scripts/interface
#sudo openocd -f jlink.cfg -f raspi4.cfg
Open On-Chip Debugger 0.10.0+dev-01408-g762ddcb74-dirty (2020-09-22-10:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter speed' not 'adapter_khz'
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V11 compiled Jun 9 2020 13:38:27
Info : Hardware version: 11.00
Info : VTarget = 3.322 V
Info : clock speed 1000 kHz
Info : JTAG tap: auto0.tap tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : bcm2711.a72.0: hardware has 6 breakpoints, 4 watchpoints
Info : bcm2711.a72.1: hardware has 6 breakpoints, 4 watchpoints
Info : bcm2711.a72.2: hardware has 6 breakpoints, 4 watchpoints
Info : bcm2711.a72.3: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for bcm2711.a72.0 on 3333
Info : Listening on port 3333 for gdb connections