Neo1973 OpenOCD/zh tw

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Did you turn it on ?)
(Windows Binaries)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== 關於 OpenOCD ==
+
{{Languages|Neo1973 OpenOCD}}
  
[http://openocd.berlios.de/ OpenOCD] 是100% free software On-chip-debugger for commonly-found ARM JTAG probes such as [[wiggler]], chamaeleon, jtag-key and others, like the [[Debug Board]].
+
 
 +
 
 +
== 關於 OpenOCD ==
 +
[http://openocd.berlios.de/ OpenOCD] 是完全免費的On-chip-debugger,類似Debug Board。
  
 
它提供human-readable telnet 界面做為手動halting/resuming目的地裝置。讀取/寫入registers 及記憶體。
 
它提供human-readable telnet 界面做為手動halting/resuming目的地裝置。讀取/寫入registers 及記憶體。
Line 13: Line 16:
 
=== MokoMakefile ===
 
=== MokoMakefile ===
  
[[MokoMakefile]] "make openmoko-devel-tools" target will build statically-linked openocd and [[dfu-util]] binaries. The "bitbake openocd-native" command may also be used.
+
[[MokoMakefile]] "make openmoko-devel-tools" 可以建立與openocd 及[[dfu-util]]二位元檔的連結。或者,你也可以使用"bitbake openocd-native" 指令。
 +
 
  
 
=== Debian套件 ===
 
=== Debian套件 ===
Line 33: Line 37:
 
=== Windows Binaries ===
 
=== Windows Binaries ===
  
[http://www.yagarto.de/ YAGARTO] 專案針對OpenOCD提供Win32安裝。你可以在這個網址http://www.yagarto.de/howto/openocd/index.html查看到詳情及下載。YAGAPTO接著會與從這個位址http://people.openmoko.org/laforge/misc/debug_board_v2/windows_drivers/
+
[http://www.yagarto.de/ YAGARTO]  
下載的FDTI一起運作。 drivers available from
+
[http://www.freddiechopin.info/ OpenOCD Win32]
 +
[http://people.openmoko.org/laforge/misc/debug_board_v2/windows_drivers/ FDTI drivers available from]
  
 
== 設定 ==
 
== 設定 ==
Line 54: Line 59:
 
按住電源按鈕,直到 boot loader開始進行倒數,或者,在這個情況下,你可以讓cpu保持忙碌。
 
按住電源按鈕,直到 boot loader開始進行倒數,或者,在這個情況下,你可以讓cpu保持忙碌。
  
=== number of discovered devices in JTAG chain doesn't match configuration ===
+
=== 已知的在JTAG chainn下無法與裝置設定切合的裝置 ===
  
 
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及[[Debug Board|除錯版]] ==
 
== OpenOCD及[[Debug Board|除錯版]] ==
Line 157: Line 162:
 
在'''telnet''' 指令列,並使用 '''hbreak''' 在gdb中設定中斷點。
 
在'''telnet''' 指令列,並使用 '''hbreak''' 在gdb中設定中斷點。
  
{{Languages|Neo1973 OpenOCD}}
+
[[Category:System Developers/zh tw]]
[[Category:Software ]]
+
[[Category:Application Developer]]
+
[[Category:Guides]]
+

Latest revision as of 12:24, 26 June 2010



Contents

[edit] 關於 OpenOCD

OpenOCD 是完全免費的On-chip-debugger,類似Debug Board。

它提供human-readable telnet 界面做為手動halting/resuming目的地裝置。讀取/寫入registers 及記憶體。

除此之外,它在TCP埠提供RDI (remote debugger interface)。這個界面可以被 gdb (the GNU Debugger)使用。

GTA01開發團隊在最剛開始的時侯,使用與wiggler相容的 OpenOCD probe 做為他們的ICE solution,直到被設計為他們 Debug Board︱除錯板

[edit] 取得 OpenOCD

[edit] MokoMakefile

MokoMakefile "make openmoko-devel-tools" 可以建立與openocd 及dfu-util二位元檔的連結。或者,你也可以使用"bitbake openocd-native" 指令。


[edit] Debian套件

我們現在擁有了Debian OpenOCD二進位檔套件,可以至 http://people.openmoko.org/laforge/dpkg取得。 安裝這個套件是將OpenOCD安裝到你開發軟體的裝置的優先好方法。

dpkg --install openocd_82-1_i386.deb

Debian/Unstable也包含了OpenOCD build。

[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 是100% free software On-chip-debugger for commonly-found ARM JTAG probes such as wiggler, chamaeleon, jtag-key and others, like the Debug Board.

它提供human-readable telnet 界面做為手動halting/resuming目的地裝置。讀取/寫入registers 及記憶體。

除此之外,它在TCP埠提供RDI (remote debugger interface)。這個界面可以被 gdb (the GNU Debugger)使用。

GTA01開發團隊在最剛開始的時侯,使用與wiggler相容的 OpenOCD probe 做為他們的ICE solution,直到被設計為他們 Debug Board︱除錯板

取得 OpenOCD

MokoMakefile

MokoMakefile "make openmoko-devel-tools" target will build statically-linked openocd and dfu-util binaries. The "bitbake openocd-native" command may also be used.

Debian套件

我們現在擁有了Debian OpenOCD二進位檔套件,可以至 http://people.openmoko.org/laforge/dpkg取得。 安裝這個套件是將OpenOCD安裝到你開發軟體的裝置的優先好方法。

dpkg --install openocd_82-1_i386.deb

Debian/Unstable也包含了OpenOCD build。

Gentoo Ebuild

gentoo bugzilla有給Openocd使用的實驗性ebuild。

原始碼

OpenOCD Revision 82 及之後的版本已經證實可以在QT2410Neo1973 裝置及wiggler及Amontect JTAGkey , JTAGkey tiny上良好的運作。你可以透過下面的方法在OpenOCD子版本外查看rev. 130 。

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

Windows Binaries

YAGARTO 專案針對OpenOCD提供Win32安裝。你可以在這個網址http://www.yagarto.de/howto/openocd/index.html查看到詳情及下載。YAGAPTO接著會與從這個位址http://people.openmoko.org/laforge/misc/debug_board_v2/windows_drivers/ 下載的FDTI一起運作。 drivers available from

設定

User:HaraldWelte 提供了 openocd.cfg 設定檔 做為利用OpenOCD及QT2410做為wiggler之用。

使用OpenOCD

我們無法提供OpenOCD的完整使用手冊,但你可以參考Bootloader#Using_JTAG_to_boot_from_RAMNAND bad blocks#JTAG_.2F_OpenOCD_.2F_u-boot_RAM_basedNeo1973 OpenOCD#Using OpenOCD telnet interface這些內容。

已知的臭蟲及問題排除

CP15 register 讀取/寫入 ARM920T core 無法作用

這個為已知的臭蟲,但除錯工作目前為停滯狀態。

你啟動它了嗎?

最容易犯及最具破壞力的錯誤是忘記確實的啟動CPU。只把電源接上是不夠的! 按住電源按鈕,直到 boot loader開始進行倒數,或者,在這個情況下,你可以讓cpu保持忙碌。

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及除錯版

libftdi-0.8

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

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"

使用OpenOCD telnet 界面

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

telnet localhost 4444

它提供很多除錯的功能。你可能會對下列的內容感到興趣。

reset
reset halt
resume
poll
reg
load_binary
mdw
mww

使用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中設定中斷點。