Neo1973 OpenOCD/zh cn

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Languages|Neo1973 OpenOCD}}
 +
 +
 +
 
== 关于 OpenOCD ==
 
== 关于 OpenOCD ==
  
Line 24: Line 28:
 
您还可以在[http://packages.debian.org/openocd Debian/Unstable]找到OpenOCD的deb包。
 
您还可以在[http://packages.debian.org/openocd Debian/Unstable]找到OpenOCD的deb包。
  
=== Gentoo Ebuild ===
 
There is an experimental ebuild for openocd in the [http://bugs.gentoo.org/show_bug.cgi?id=200689 gentoo bugzilla].
 
  
=== Source Code ===
+
=== Gentoo Ebuild ===
 +
在[http://bugs.gentoo.org/show_bug.cgi?id=200689 gentoo bugzilla]有给Openocd使用的实验性ebuild。
  
OpenOCD 82以后的版本已经可以很好的工作在 [[QT2410]] 和 [[Neo1973]] 目标板上了。您可以通过svn获得代码,例如获得版本130的源代码:
+
=== 原始码 ===
  
 +
OpenOCD Revision 82 及之后的版本已经证实可以在[[QT2410]]及[[Neo1973]] 装置及wiggler及Amontect JTAGkey ,  JTAGkey tiny上良好的运作。你可以透过下面的方法在OpenOCD子版本外查看rev. 130 。
 
  svn co -r 130 http://svn.berlios.de/svnroot/repos/openocd/trunk
 
  svn co -r 130 http://svn.berlios.de/svnroot/repos/openocd/trunk
  
 
=== Windows Binaries ===
 
=== Windows Binaries ===
  
The [http://www.yagarto.de/ YAGARTO] Project provides a Win32 installer for OpenOCD. Details and download can be found at http://www.yagarto.de/howto/openocd/index.html. This will then work with the FDTI drivers available from http://people.openmoko.org/laforge/misc/debug_board_v2/windows_drivers/
+
[http://www.yagarto.de/ YAGARTO]  
 +
[http://www.yagarto.de/howto/openocd/ OpenOCD Win32]
 +
[http://people.openmoko.org/laforge/misc/debug_board_v2/windows_drivers/ FDTI drivers available from]
  
== Configuration ==
+
== 设定 ==
  
[[User:HaraldWelte]] has provided a [http://people.gta01.hmw-consulting.de/laforge/misc/openocd.cfg openocd.cfg configuration file] for use of OpenOCD with wiggler and the QT2410 target board.
+
[[User:HaraldWelte]] 提供了 [http://people.gta01.hmw-consulting.de/laforge/misc/openocd.cfg openocd.cfg 设定档] 做为利用OpenOCD及QT2410做为wiggler之用。
  
== Using OpenOCD ==
+
== 使用OpenOCD ==
 +
我们无法提供OpenOCD的完整使用手册,但你可以参考[[Bootloader#Using_JTAG_to_boot_from_RAM]]及[[NAND bad blocks#JTAG_.2F_OpenOCD_.2F_u-boot_RAM_based]]及[[Neo1973 OpenOCD#Using OpenOCD telnet interface]]这些内容。
  
We cannot provide a full manual for OpenOCD, but please check
+
== 已知的臭虫及问题排除 ==
[[Bootloader#Using_JTAG_to_boot_from_RAM]] and [[NAND bad blocks#JTAG_.2F_OpenOCD_.2F_u-boot_RAM_based]], as well as the [[Neo1973 OpenOCD#Using OpenOCD telnet interface]] section below.
+
  
== Known Bugs and Troubleshooting ==
+
=== CP15 register 读取/写入 ARM920T core 无法作用 ===
  
=== CP15 register read/write of ARM920T core not working ===
+
这个为已知的臭虫,但除错工作目前为停滞状态。
  
This has been reported upstream. Bugfix pending.
+
=== 你启动它了吗? ===
  
=== Did you turn it on ? ===
+
最容易犯及最具破坏力的错误是忘记确实的启动CPU。只把电源接上是不够的!
 +
按住电源按钮,直到 boot loader开始进行倒数,或者,在这个情况下,你可以让cpu保持忙碌。
  
An easily made but devastating mistake is to forget to actually activate the CPU. Just connecting power is not enough !
+
=== 已知的在JTAG chainn下无法与装置设定切合的装置 ===
Press and hold the power button until the boot loader does its count-down, or, in case there is no runnable boot loader,
+
the CPU keeps itself busy.
+
 
+
=== number of discovered devices in JTAG chain doesn't match configuration ===
+
  
 
You get something like:
 
You get something like:
 
  Error:  jtag.c:1224 jtag_examine_chain(): number of discovered devices in JTAG chain (51) doesn't match configuration (1)
 
  Error:  jtag.c:1224 jtag_examine_chain(): number of discovered devices in JTAG chain (51) doesn't match configuration (1)
  
This seems like a libftdi initialization bug.  Sometimes the FT2232 doesn't get completely reset into a sane state at startup of OpenOCD.  Please unplug the USB cable from the [[Amontec JTAGkey]] / [[Debug Board]] and re-plug.  It should immediately work the next time.  Bugfix would be appreciated a lot!
+
这看起来是libftdi启动的臭虫,有时,在FT2232下也无法取得在启动OpenOCD时完全的重新定定。请重新自[[Amontec JTAGkey]] / [[Debug Board]] 上拔下USB装置,再重新插回,就可以很快的重新启动及使用。
  
=== JTAG communication failure ===
+
=== JTAG 通讯错误 ===
  
Another common error is this one:
+
其它常见的错误如下:
 
  JTAG communication failure, check connection, JTAG interface, target power etc.
 
  JTAG communication failure, check connection, JTAG interface, target power etc.
  
Also this one is fixed by unplugging and re-plugging USB.
+
同时,它也可以藉由插、拔USB来修复。
  
== OpenOCD and [[Debug Board]] ==
+
== OpenOCD及[[Debug Board|除错版]] ==
  
 
=== libftdi-0.8 ===
 
=== libftdi-0.8 ===
 
+
如果你想要使用OpenOCD搭配Debug Board v2一起使用,并且想在OpenOCD下同时使用串行埠,你 '''需使用libftdi-0.8 或之后的版本'''。你的套件仍是使用之前的libftdi版本的机率很高,因此,你可以自下面的地址 http://www.intra2net.com/de/produkte/opensource/ftdi/ 下载,并且自行建置。
If you want to use OpenOCD with our Debug Board v2, and want to use the serial port simultaneously with OpenOCD, you '''need libftdi-0.8 or later'''.  Chances are high that your distribution still ships an earlier version of libftdi, so you might want to download it from http://www.intra2net.com/de/produkte/opensource/ftdi/ and build yourself.
+
  
 
=== openocd.cfg ===
 
=== openocd.cfg ===
  
This is an openocd.cfg that is known to work with [[Debug Board]] (v2/v3), [[Neo1973 Hardware#GTA01Bv3]] and OpenOCD 130:
+
openocd.cfg设定档是可以与 [[Debug Board]] (v2/v3)[[Neo1973 Hardware#GTA01Bv3]]及OpenOCD 130合用的版本:
 
<pre>
 
<pre>
 
telnet_port 4444
 
telnet_port 4444
Line 96: Line 98:
 
</pre>
 
</pre>
  
For later versions of OpenOCD you may need to specify the device description. For the v2 Debug board add this line to your openocd.cfg:
+
对于OpenOCD之后的版本,你可能必须指定装置描述。针对v2 Debug board ,你可以在你的openocd.cfg中加入这一行:
 
<pre>
 
<pre>
 
ft2232_device_desc "Debug Board for Neo1973 A"
 
ft2232_device_desc "Debug Board for Neo1973 A"
 
</pre>
 
</pre>
  
If you are using the libftdi version on Linux, and if you see this iProduct string in your lsusb output "Debug Board for Neo1973", please add this line instead.
+
如果你使用Linux的libftdi 版本,并且你在lsusb output "Debug Board for Neo1973 看到iProduct string ,请加入以下的内容,而非上述的设定行:
 
<pre>
 
<pre>
 
ft2232_device_desc "Debug Board for Neo1973"
 
ft2232_device_desc "Debug Board for Neo1973"
 
</pre>
 
</pre>
  
=== Using OpenOCD telnet interface ===
+
=== 使用OpenOCD telnet 界面 ===
 +
 
 +
telnet界面可以使用以下的指令存取
  
The telnet interface can be accessed using
 
 
  telnet localhost 4444
 
  telnet localhost 4444
  
it provides a plethora of functions for debugging. You might be interested in
+
它提供很多除错的功能。你可能会对下列的内容感到兴趣。
 
<pre>
 
<pre>
 
reset
 
reset
Line 123: Line 126:
 
</pre>
 
</pre>
  
=== Using OpenOCD and gdb for remote debugging ===
+
=== 使用OpenOCD与gdb进行远程侦错 ===
 +
首先,你需要一个适合的跨gdb(在你的主架构上执行的gdb架构,如i386,但在arm上是与程序一起运作)。在OpenEmbedded中,你可以使用下面的指令建立cross-gdb:
  
First, you will need a suitable cross-gdb (a gdb that runs on your host architecture, e.g. i386, but works with code for arm).  In OpenEmbedded, you can build such a cross-gdb by using
 
 
  bitbake  gdb-cross
 
  bitbake  gdb-cross
  
If you want to debug the kernel, you can then start this gdb with
+
如果你想要对kernel进行除错工作, you can then start this gdb with
 +
 
 
  $ arm-linux-gdb vmlinux
 
  $ arm-linux-gdb vmlinux
  
which will give you something like
+
它会出现以下的内容:
 
<pre>
 
<pre>
 
GNU gdb 6.6
 
GNU gdb 6.6
Line 143: Line 147:
 
</pre>
 
</pre>
  
We now need to connect to the OpenOCD daemon, which is done using the '''target remote''' command.  In this particular example, we did already halt the target by issuing '''halt''' on the '''telnet''' command line
+
我们现在需要连接到OpenOCD daemon,你可以使用 '''target remote'''指令。在这个特定的案例中,我们已经使用在'''telnet'''指令列中使用'''halt'''
  
 
<pre>
 
<pre>
Line 154: Line 158:
 
</pre>
 
</pre>
  
For breakpoints to work, you have to enable software breakpoints in OpenOCD, by issuing
+
对于这项工作的断点,你可以使用以下的指令,启用OpenOCD中的软件断点。
 +
 
 
  > arm7_9 sw_bkpts enable
 
  > arm7_9 sw_bkpts enable
  
on the '''telnet''' command line, and use '''hbreak''' to set breakpoints in gdb.
+
'''telnet''' 指令列,并使用 '''hbreak''' 在gdb中设定断点。
{{Languages|Neo1973 OpenOCD}}
+
 
[[Category:Software ]]
+
 
[[Category:Application Developer]]
+
[[Category:System Developers/zh cn]]
[[Category:Guides]]
+

Latest revision as of 23:24, 20 August 2008



Contents

[edit] 关于 OpenOCD

OpenOCD 是完全免费的片上调式软件(On-chip-debugger),类似Debug Board。

它为目标程序的挂起和恢复,寄存器,内存的读写等提供一个易读的telnet接口,

同时,还在tcp端口提供一个远程gdb调试接口。

最初在Debug Board设计出来之前,GTA01开发组就是使用OpenOCD结合wiggler作为他们的调试工具的。

[edit] 获得 OpenOCD 的方法

[edit] MokoMakefile方式

通过MokoMakefile 构建openmoko开发工具"make openmoko-devel-tools" 将会生成openocd和dfu-util的二进制文件。构建时需要使用 "bitbake openocd-native" 命令。

[edit] Debian包方式

我们现在可以从http://people.openmoko.org/laforge/dpkg 获得debian包。安装openocd,执行

dpkg --install openocd_82-1_i386.deb

您还可以在Debian/Unstable找到OpenOCD的deb包。


[edit] Gentoo Ebuild

gentoo bugzilla有给Openocd使用的实验性ebuild。

[edit] 原始码

OpenOCD Revision 82 及之后的版本已经证实可以在QT2410Neo1973 装置及wiggler及Amontect JTAGkey , JTAGkey tiny上良好的运作。你可以透过下面的方法在OpenOCD子版本外查看rev. 130 。

svn co -r 130 http://svn.berlios.de/svnroot/repos/openocd/trunk

[edit] Windows Binaries

YAGARTO OpenOCD Win32 FDTI drivers available from

[edit] 设定

User:HaraldWelte 提供了 openocd.cfg 设定档 做为利用OpenOCD及QT2410做为wiggler之用。

[edit] 使用OpenOCD

我们无法提供OpenOCD的完整使用手册,但你可以参考Bootloader#Using_JTAG_to_boot_from_RAMNAND bad blocks#JTAG_.2F_OpenOCD_.2F_u-boot_RAM_basedNeo1973 OpenOCD#Using OpenOCD telnet interface这些内容。

[edit] 已知的臭虫及问题排除

[edit] CP15 register 读取/写入 ARM920T core 无法作用

这个为已知的臭虫,但除错工作目前为停滞状态。

[edit] 你启动它了吗?

最容易犯及最具破坏力的错误是忘记确实的启动CPU。只把电源接上是不够的! 按住电源按钮,直到 boot loader开始进行倒数,或者,在这个情况下,你可以让cpu保持忙碌。

[edit] 已知的在JTAG chainn下无法与装置设定切合的装置

You get something like:

Error:   jtag.c:1224 jtag_examine_chain(): number of discovered devices in JTAG chain (51) doesn't match configuration (1)

这看起来是libftdi启动的臭虫,有时,在FT2232下也无法取得在启动OpenOCD时完全的重新定定。请重新自Amontec JTAGkey / Debug Board 上拔下USB装置,再重新插回,就可以很快的重新启动及使用。

[edit] JTAG 通讯错误

其它常见的错误如下:

JTAG communication failure, check connection, JTAG interface, target power etc.

同时,它也可以藉由插、拔USB来修复。

[edit] OpenOCD及除错版

[edit] libftdi-0.8

如果你想要使用OpenOCD搭配Debug Board v2一起使用,并且想在OpenOCD下同时使用串行埠,你 需使用libftdi-0.8 或之后的版本。你的套件仍是使用之前的libftdi版本的机率很高,因此,你可以自下面的地址 http://www.intra2net.com/de/produkte/opensource/ftdi/ 下载,并且自行建置。

[edit] openocd.cfg

openocd.cfg设定档是可以与 Debug Board (v2/v3)、Neo1973 Hardware#GTA01Bv3及OpenOCD 130合用的版本:

telnet_port 4444
gdb_port 3333
interface ft2232
jtag_speed 0
ft2232_vid_pid 0x1457 0x5118
ft2232_layout "jtagkey"
reset_config trst_and_srst
jtag_device 4 0x1 0xf 0xe
daemon_startup attach
target arm920t little reset_run 0 arm920t
working_area 0 0x200000 0x4000 backup
run_and_halt_time 0 5000

对于OpenOCD之后的版本,你可能必须指定装置描述。针对v2 Debug board ,你可以在你的openocd.cfg中加入这一行:

ft2232_device_desc "Debug Board for Neo1973 A"

如果你使用Linux的libftdi 版本,并且你在lsusb output "Debug Board for Neo1973 看到iProduct string ,请加入以下的内容,而非上述的设定行:

ft2232_device_desc "Debug Board for Neo1973"

[edit] 使用OpenOCD telnet 界面

telnet界面可以使用以下的指令存取

telnet localhost 4444

它提供很多除错的功能。你可能会对下列的内容感到兴趣。

reset
reset halt
resume
poll
reg
load_binary
mdw
mww

[edit] 使用OpenOCD与gdb进行远程侦错

首先,你需要一个适合的跨gdb(在你的主架构上执行的gdb架构,如i386,但在arm上是与程序一起运作)。在OpenEmbedded中,你可以使用下面的指令建立cross-gdb:

bitbake  gdb-cross

如果你想要对kernel进行除错工作, you can then start this gdb with

$ arm-linux-gdb vmlinux

它会出现以下的内容:

GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-linux --target=arm-linux"...
(gdb) 

我们现在需要连接到OpenOCD daemon,你可以使用 target remote指令。在这个特定的案例中,我们已经使用在telnet指令列中使用halt

(gdb) target remote localhost:3333
Remote debugging using localhost:3333
warning: shared library handler failed to enable breakpoint
0xc0129b8c in memmove () at include/asm/current.h:9
9       {
(gdb)

对于这项工作的断点,你可以使用以下的指令,启用OpenOCD中的软件断点。

> arm7_9 sw_bkpts enable

telnet 指令列,并使用 hbreak 在gdb中设定断点。

Personal tools

关于 OpenOCD

OpenOCD 是完全免费的片上调式软件(On-chip-debugger),类似Debug Board。

它为目标程序的挂起和恢复,寄存器,内存的读写等提供一个易读的telnet接口,

同时,还在tcp端口提供一个远程gdb调试接口。

最初在Debug Board设计出来之前,GTA01开发组就是使用OpenOCD结合wiggler作为他们的调试工具的。

获得 OpenOCD 的方法

MokoMakefile方式

通过MokoMakefile 构建openmoko开发工具"make openmoko-devel-tools" 将会生成openocd和dfu-util的二进制文件。构建时需要使用 "bitbake openocd-native" 命令。

Debian包方式

我们现在可以从http://people.openmoko.org/laforge/dpkg 获得debian包。安装openocd,执行

dpkg --install openocd_82-1_i386.deb

您还可以在Debian/Unstable找到OpenOCD的deb包。

Gentoo Ebuild

There is an experimental ebuild for openocd in the gentoo bugzilla.

Source Code

OpenOCD 82以后的版本已经可以很好的工作在 QT2410Neo1973 目标板上了。您可以通过svn获得代码,例如获得版本130的源代码:

svn co -r 130 http://svn.berlios.de/svnroot/repos/openocd/trunk

Windows Binaries

The YAGARTO Project provides a Win32 installer for OpenOCD. Details and download can be found at http://www.yagarto.de/howto/openocd/index.html. This will then work with the FDTI drivers available from http://people.openmoko.org/laforge/misc/debug_board_v2/windows_drivers/

Configuration

User:HaraldWelte has provided a openocd.cfg configuration file for use of OpenOCD with wiggler and the QT2410 target board.

Using OpenOCD

We cannot provide a full manual for OpenOCD, but please check Bootloader#Using_JTAG_to_boot_from_RAM and NAND bad blocks#JTAG_.2F_OpenOCD_.2F_u-boot_RAM_based, as well as the Neo1973 OpenOCD#Using OpenOCD telnet interface section below.

Known Bugs and Troubleshooting

CP15 register read/write of ARM920T core not working

This has been reported upstream. Bugfix pending.

Did you turn it on ?

An easily made but devastating mistake is to forget to actually activate the CPU. Just connecting power is not enough ! Press and hold the power button until the boot loader does its count-down, or, in case there is no runnable boot loader, the CPU keeps itself busy.

number of discovered devices in JTAG chain doesn't match configuration

You get something like:

Error:   jtag.c:1224 jtag_examine_chain(): number of discovered devices in JTAG chain (51) doesn't match configuration (1)

This seems like a libftdi initialization bug. Sometimes the FT2232 doesn't get completely reset into a sane state at startup of OpenOCD. Please unplug the USB cable from the Amontec JTAGkey / Debug Board and re-plug. It should immediately work the next time. Bugfix would be appreciated a lot!

JTAG communication failure

Another common error is this one:

JTAG communication failure, check connection, JTAG interface, target power etc.

Also this one is fixed by unplugging and re-plugging USB.

OpenOCD and Debug Board

libftdi-0.8

If you want to use OpenOCD with our Debug Board v2, and want to use the serial port simultaneously with OpenOCD, you need libftdi-0.8 or later. Chances are high that your distribution still ships an earlier version of libftdi, so you might want to download it from http://www.intra2net.com/de/produkte/opensource/ftdi/ and build yourself.

openocd.cfg

This is an openocd.cfg that is known to work with Debug Board (v2/v3), Neo1973 Hardware#GTA01Bv3 and OpenOCD 130:

telnet_port 4444
gdb_port 3333
interface ft2232
jtag_speed 0
ft2232_vid_pid 0x1457 0x5118
ft2232_layout "jtagkey"
reset_config trst_and_srst
jtag_device 4 0x1 0xf 0xe
daemon_startup attach
target arm920t little reset_run 0 arm920t
working_area 0 0x200000 0x4000 backup
run_and_halt_time 0 5000

For later versions of OpenOCD you may need to specify the device description. For the v2 Debug board add this line to your openocd.cfg:

ft2232_device_desc "Debug Board for Neo1973 A"

If you are using the libftdi version on Linux, and if you see this iProduct string in your lsusb output "Debug Board for Neo1973", please add this line instead.

ft2232_device_desc "Debug Board for Neo1973"

Using OpenOCD telnet interface

The telnet interface can be accessed using

telnet localhost 4444

it provides a plethora of functions for debugging. You might be interested in

reset
reset halt
resume
poll
reg
load_binary
mdw
mww

Using OpenOCD and gdb for remote debugging

First, you will need a suitable cross-gdb (a gdb that runs on your host architecture, e.g. i386, but works with code for arm). In OpenEmbedded, you can build such a cross-gdb by using

bitbake  gdb-cross

If you want to debug the kernel, you can then start this gdb with

$ arm-linux-gdb vmlinux

which will give you something like

GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-linux --target=arm-linux"...
(gdb) 

We now need to connect to the OpenOCD daemon, which is done using the target remote command. In this particular example, we did already halt the target by issuing halt on the telnet command line

(gdb) target remote localhost:3333
Remote debugging using localhost:3333
warning: shared library handler failed to enable breakpoint
0xc0129b8c in memmove () at include/asm/current.h:9
9       {
(gdb)

For breakpoints to work, you have to enable software breakpoints in OpenOCD, by issuing

> arm7_9 sw_bkpts enable

on the telnet command line, and use hbreak to set breakpoints in gdb.