OpenOCD安装与使用(JTAG调试)

本文介绍openocd开源软件的安装以及搭配JTAG对Xilinx u500VC707devkit的调试
PC OS: Ubuntu20.04 LTS
Target ARCH: riscv64
JTAG: Olimex-ARM-USB-TINY-H
OpenOCD version: OpenOCD v0.10.0

1、OpenOCD简介

  OpenOCD(Open On-Chip Debugger)是一款开源的开放式片上调试软件,需要在调试适配器(如: JTAG、SWD等)的配合下可以对片上系统进行相应调试,以及在嵌入式设备上测试系统内程序或边界接扫描测试。

2、下载OpenOCD

  可以通过OpenOCD官网下载源码,已经有很多平台提供配套目标平台的OpenOCD源码,也可以通过这些来下载带有相应目标平台配置文件的OpenOCD,本文主要介绍支持riscv64的OpenOCD下载和使用。
riscv-openocd下载链接: https://github.com/sifive/riscv-openocd
通过git下载:

git clone https://github.com/sifive/riscv-openocd.git 3、编译与安装

<1> 进入riscv-openocd源码目录

imaginemiracle@:openocd$ cd riscv-openocd imaginemiracle@:riscv-openocd$ ls AUTHORS ChangeLog COPYING HACKING NEWS-0.10.0 NEWS-0.5.0 NEWS-0.9.0 README.Windows TODO AUTHORS.ChangeLog config_subdir.m4 doc jimtcl NEWS-0.2.0 NEWS-0.6.0 NEWTAPS src tools bootstrap configure.ac Doxyfile.in Makefile.am NEWS-0.3.0 NEWS-0.7.0 README tcl uncrustify.cfg BUGS contrib guess-rev.sh NEWS NEWS-0.4.0 NEWS-0.8.0 README.OSX testing

<2> 执行bootstrap生成configure文件,通过configure配置OpenOCD,主要需要配置OpenOCD支持的调试器的类型,笔者使用的JTAG为FTDI类型,因此需要OpenOCD支持FTDI。
[注] 通过查看JTAG手册了解所使用的JTAG是什么类型,通过./configure --help 命令查看所需要开启的类型以及其它配置参数

#创建安装目录 imaginemiracle@:riscv-openocd$ mkdir install_IM #执行bootstrap imaginemiracle@:riscv-openocd$ ./bootstrap

bootstrap执行的正常输出:

+ aclocal + libtoolize --automake --copy + autoconf + autoheader + automake --gnu --add-missing --copy configure.ac:26: installing './compile' configure.ac:37: installing './config.guess' configure.ac:37: installing './config.sub' configure.ac:16: installing './install-sh' configure.ac:16: installing './missing' Makefile.am:46: warning: wildcard $(srcdir: non-POSIX variable name Makefile.am:46: (probably a GNU make extension) Makefile.am: installing './INSTALL' Makefile.am: installing './depcomp' Makefile.am:23: installing './mdate-sh' Makefile.am:23: installing './texinfo.tex' Setting up submodules Submodule 'jimtcl' (https://github.com/msteveb/jimtcl) registered for path 'jimtcl' Cloning into '/media/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/File_System_test/openocd/riscv-openocd/jimtcl'... Submodule path 'jimtcl': checked out '51f65c6d38fbf86e1f0b036ad336761fd2ab7fa0' Submodule path 'jimtcl': checked out '51f65c6d38fbf86e1f0b036ad336761fd2ab7fa0' Generating build system... libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'. libtoolize: copying file 'build-aux/config.guess' libtoolize: copying file 'build-aux/config.sub' libtoolize: copying file 'build-aux/install-sh' libtoolize: copying file 'build-aux/ltmain.sh' libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'. libtoolize: copying file 'm4/libtool.m4' libtoolize: copying file 'm4/ltoptions.m4' libtoolize: copying file 'm4/ltsugar.m4' libtoolize: copying file 'm4/ltversion.m4' libtoolize: copying file 'm4/lt~obsolete.m4' configure.ac:42: installing 'build-aux/ar-lib' configure.ac:37: installing 'build-aux/compile' configure.ac:30: installing 'build-aux/missing' Makefile.am: installing './INSTALL' libjaylink/Makefile.am: installing 'build-aux/depcomp' Bootstrap complete. Quick build instructions: ./configure ....

成功生成configure文件

#配置安装目录路径必须为绝对路径 imaginemiracle@:riscv-openocd$ ./configure --prefix=http://www.likecs.com/home/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/File_System_test/openocd/openocd-0.10.0/install_IM/ --enable-ftdi ###################只显示关键输出#################### checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating libjaylink/Makefile config.status: creating libjaylink/version.h config.status: creating libjaylink.pc config.status: creating Doxyfile config.status: creating config.h config.status: executing depfiles commands config.status: executing libtool commands

看到成功成生Makefile文件且没有报错,则说明配置成功。
<3> 配置成功后直接编译并安装即可
直接使用make; make install编译并安装

#编译后并且安装 imaginemiracle@:riscv-openocd$ make; make install

若make; make install直接通过,则跳过<4>这一节直接看下一节的openocd使用介绍。

<4> 编译openocd可能会遇到如下几种错误
<4.1> 报错 1: src/svf/svf.c:663:7: error: this statement may fall through [-Werror=implicit-fallthrough=]

#错误1 src/svf/svf.c: In function ‘svf_read_command_from_file’: src/svf/svf.c:663:7: error: this statement may fall through [-Werror=implicit-fallthrough=] 663 | i = -1; | ~~^~~~ src/svf/svf.c:664:4: note: here 664 | case '\r': | ^~~~ src/svf/svf.c:667:8: error: this statement may fall through [-Werror=implicit-fallthrough=] 667 | if (!cmd_pos) | ^ src/svf/svf.c:669:4: note: here 669 | default: | ^~~~~~~ cc1: all warnings being treated as errors

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wspgpw.html