OpenOCD compile on Windows

Open On-Chip Debugger (OpenOCD) 是一个用于嵌入式目标设备调试、编程和边界扫描测试的开源工具,支持通过JTAG接口连接。本文档将介绍在Windows上安装Cygwin,下载OpenOCD源代码,并详细说明如何编译OpenOCD,包括可能遇到的编译错误及其解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OpenOCD compile on Windows

  • About Open On-Chip Debugger

The Open On-Chip Debugger (openocd) aims to provide debugging, in-system programming and boundary-scan testing for embedded target devices. The targets are interfaced using JTAG (IEEE 1149.1) compliant hardware, but this may be extended to other connection types in the future.

Openocd currently supports Wiggler (clones), FTDI FT2232 based JTAG interfaces, the Amontec JTAG Accelerator, and the Gateworks GW1602. It allows ARM7 (ARM7TDMI and ARM720t), ARM9 (ARM920t, ARM922t, ARM926ej-s, ARM966e-s), XScale (PXA27x,PXA25x, IXP42x) and Cortex-M3 (Luminary Stellaris LM3 and ST STM32) based cores to be debugged.

Flash writing is supported for external CFI compatible flashes (Intel and AMD/Spansion command set) and several internal flashes (LPC2000, AT91SAM7, STR7x, STR9x, LM3 and STM32x). Preliminary support for using the LPC3180's NAND flash controller is included.

This OpenFacts entry will try to document openocd's current state, and provide general information about the technology involved.


  1. 安装cygwin
必须安装的组件包括: gcc, autoconf, automake, M4, perl

  1. 下载openocd源代码
The OpenOCD Wiki entries always document the latest version of OpenOCD. You can download the current SVN version with SVN client of your choice from the following repositories:
 svn://svn.berlios.de/openocd/trunk
or
http://svn.berlios.de/svnroot/repos/openocd/trunk
Using the SVN command line client, you could use the following command to fetch the latest version (make sure there is no (non-svn) directory called "openocd" in the current directory):svn checkout svn://svn.berlios.de/openocd/trunk

  1. 编译openocd

  • ./bootstrap
Bootstrap generates the configure script, and prepares building on your system.

  • ./configure --enable-parport --enable-parport_giveio
Configure generates the Makefiles used to build OpenOCD.

  • make
Make builds the OpenOCD, and places the final executable in ./src/

  1. 可能出现的编译错误及解决办法:
  • 编译parport.c时出错:
parport.c:65:20: sys/io.h: No such file or directory
解决办法:在parport.c中定义宏_WIN32,注意不能在config.h中定义这个宏,否则在编译其他模块代码时会出错。

  • -DPKGLIBDIR 错误:
        src/target src/flash
gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/helper -I../../src/jtag -I../../src/target  -DPKGLIBDIR=/"/usr/local/lib/openocd/
"    -g -O2 -MT flash.o -MD -MP -MF .deps/flash.Tpo -c -o flash.o flash.c
gcc: no input files
解决办法:由于gcc不识别DPKGLIBDIR造成,更改DPKGLIBDIR即可。

  • OPENOCD_VERSION宏的错误
gcc -DHAVE_CONFIG_H -I. -I.. -I../src/helper -I../src/jtag -I../src/target -I../src/xsvf -I../src/server -I../src/flash -I../
src/pld  -DPKGLIBDIR=/"/usr/local/lib/openocd/" -DPKGBLDDATE=/"`date +%F-%R`/" -DPKGBLDREV=/"`../guess-rev.sh`/"    -g -O2 -M
T openocd-openocd.o -MD -MP -MF .deps/openocd-openocd.Tpo -c -o openocd-openocd.o `test -f 'openocd.c' || echo './'`openocd.c

openocd.c: In function `handle_version_command':
openocd.c:55: error: missing terminating " character
openocd.c: In function `main':
openocd.c:93: error: missing terminating " character
解决办法:更改-DPKGBLDREV=/"`../guess-rev.sh`/"即可。

  1. 运行
telnet localhost 4444


参考:
1.Building OpenOCD: http://openfacts.berlios.de/index-en.phtml?title=Building_OpenOCD
2.OpenOCD compile on Windows XP: http://forum.sparkfun.com/viewtopic.php?t=7743&highlight=xscale
3.parport issues: http://forum.sparkfun.com/viewtopic.php?t=3795

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值