如何编译Windows下的OpenOCD

网友 1

最佳答案

回答者:网友
【OpenOCD介绍】
Ope所字气布在nOCD为嵌入式目标系统提供一个调试,在线编程和JTAG边界扫描测试的工具。支持Wigg触搞罪边议持亮表广云号ler,基于FT2232的JTAG界面等一些调试器。目标芯片支持ARM7,360问答ARM9, ARM补日肉查系额所曾马干印10, ARM11和Cortex等核心的芯片。并提供一个GDB Server接口。

【OpenOCD的编译和安装损依
1. 如果是Windows平台的话,需要先安装Cygwin环境,注意一定要选择安装以下开发包:

- autoconf: Wrapper scripts for autoconf commands
- automake: Wr训混亲握书并红在apper scripts for automake and aclocals
- gcc: C compiler upgrade helper
- make: Th请错题液将清百静丰e GNU version og the 'make' u写效磁伯tility
- subversion: A version control system
(可以完全安装,占善动用5G多的空间,需要下载8村营拉00M的文件)。

2. 下载OpenOCD的SVN源代码,打开Cygwin命令行界面,执行如下的命令:
mkdir /ho雨蛋控放旧论吗利风me/openocd
cd /home/openoc界训映经足经病扩或格东d
svn checkout svn://svn.***.de/openocd/trunk 或是
svn checkout http://svn.***.de/svnroot/repos/统此使适吧去openocd/trunk trunk

下载需要一定的时间,完成后,当前目录下就多了t除春务草runk目录,里面就有源代码。

3. 如果你想要编译用於FT短费查难宜晚模喜环马2232接口的openocd,需要服热律下载FTDI的驱动
解压后会自动生成一个文件夹"CDM 2.04.06 W扬整比HQL Certified" , 从/i386或/amd64中(根据你的系统来选择)复制 ***.li告别叫载飞星b到/home/openocd/ftd2xx(自己建立)中。现在在openocd文件夹下就有两个文件夹,如下:
/home/openocd/trunk
/home/openocd/ftd2xx

4. 接着使用如下命令配置并编译:
cd trunk
./bootstrap

如果你想生成一个基於cygwin的openocd,则输入
./configure --enable-ft2232_ftd2xx --with-ftd2xx=/home/openocd/ftd2xx
生成一个基於mingw 的openocd,则输入
./configure --enable-ft2232_ftd2xx --with-ftd2xx=/home/openocd/ftd2xx CC="gcc -mno-cygwin"
如果想同时支持FT2232和Wiggler,则输入
./configure --enable-parport –enable-parport_giveio --enable-ft2232_ftd2xx --with-ftd2xx=/home/openocd/ftd2xx CC="gcc -mno-cygwin"

正确配置之后,就可以运行以下命令生成 OpenOCD:

make // 即可在/trunk/src中生成openocd
make install // 将openocd和配置文件安装到/usr/local/bin和/usr/local/lib中
make pdf // 在/trunk/doc中生成pdf (必须安装tex)

这样OpenOCD就编译并安装完成了,并在doc目录下生产了***.pdf帮助文档。
可以使用命令"openocd -v"来查看版本。

【OpenOCD的配置】
详细配置说明,请参考帮助文档
LPC2000的配置文件(***.cfg):

#daemon configuration
telnet_port 4444
gdb_port 3333
tcl_port 6666

# tell gdb our flash memory map
# and enable flash programming
gdb_memory_map enable
gdb_flash_program enable

#interface
interface ft2232
ft2232_device_desc "USB Serial Converter A"
#ft2232_device_desc "USB OpenOCD JTAG A"
ft2232_layout "usbjtag"
ft2232_vid_pid 0x0403 0x6010
jtag_speed 3
#jtag_khz 300

#delays on reset lines
jtag_ntrst_delay 200

# NOTE!!! LPCs need reset pulled while RTCK is low. 0 to activate
# JTAG, power-on reset is not enough, i.e. you need to perform a
# reset before being able to talk to the LPC2148, attach is not
# possible.

#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst srst_pulls_trst

#LPCs need reset pulled while RTCK is low. 0 to activate JTAG, power-on reset is not enough
jtag_reset 1 1
jtag_reset 0 0

#jtag scan chain
jtag_device 4 0x1 0xf 0xe

target arm7tdmi little 0 arm7tdmi-s_r4
[new_target_name] configure -event reset-init {
# Force target into ARM state
soft_reset_halt
#do not remap 0x0000-0x0020 to anything but the flash
mwb 0xE01FC040 0x01
}
working_area 0 0x40000000 0x4000 nobackup
#flash bank lpc2000 <base> <size> 0 0 <target#> <variant>
flash bank lpc2000 0x0 0x7d000 0 0 0 lpc2000_v2 14765

【OpenOCD的测试】
打开Cygwin命令行界面,执行命令:
openocd -f ***.cfg
以下是我的运行截图:

【IAR的配置】
在项目选项的Debug中的setup页里,选择GDB Server;

如果代码需要下载到flash中运行,Download页里选择Use flash loader;在plugin页里,可以去掉stack以提高速度。
在下面的GDB Server中,TCP/IP address or hostname中添localhost。

之后就可以按调试按钮开始调试了。

我来回答