私は完全かつ具体的にしようとします:
NXP LPC1756 Cortex-M3。Codesourcery ARM ツールチェーンとデバッグ用の OpenOCD を使用する Eclipse Helios。JTAG は Olimex ARM-USB-OCD です。OSはWindows7 64ビットです。
私は、物事のフラッシュアップロード側が解決したと信じています. プログラミング後、スクリプトで dump_image を実行すると、ダンプされたイメージはほぼ正しいように見えます。現時点では検証の問題があり、それを整理する必要がありますが、この段階では JTAG セットアップが機能しているようで、'1756 と正常に通信しています。
ただし、デバッグしようとすると問題が発生します。まず、ターゲット デバイスの cfg ファイルから始まる cfg ファイル:
# NXP LPC1756 Cortex-M3 with 256kB Flash and 32kB SRAM
debug_level 2
# LPC17xx chips support both JTAG and SWD transports.
# Adapt based on what transport is active.
#source [find swj-dp.tcl]
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc1756
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
if { [info exists CCLK ] } {
set _CCLK $CCLK
} else {
set _CCLK 4000
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4ba00477
}
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000
$_TARGETNAME configure -work-area-backup 0
#$_TARGETNAME configure -endian $_ENDIAN
#$_TARGETNAME configure -variant ARMv7
#delays on reset lines
adapter_nsrst_delay 200
jtag_ntrst_delay 200
#reset_config srst_only
#reset_config trst_and_srst srst_pulls_trst
# LPC1756 has 256kB of flash memory, managed by ROM code (including a
# boot loader which verifies the flash exception table's checksum).
# flash bank <name> lpc2000 <base> <size> 0 0 <target#> <variant> <clock> [calc checksum]
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME lpc2000 0x0 0x40000 0 0 $_TARGETNAME \
lpc1700 $_CCLK calc_checksum
# Run with *real slow* clock by default since the
# boot rom could have been playing with the PLL, so
# we have no idea what clock the target is running at.
jtag_khz 50
#$_TARGETNAME configure -event reset-init {
# Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
# "User Flash Mode" where interrupt vectors are _not_ remapped,
# and reside in flash instead).
#
# See Table 612. Memory Mapping Control register (MEMMAP - 0x400F C040) bit description
# Bit Symbol Value Description Reset
# value
# 0 MAP Memory map control. 0
# 0 Boot mode. A portion of the Boot ROM is mapped to address 0.
# 1 User mode. The on-chip Flash memory is mapped to address 0.
# 31:1 - Reserved. The value read from a reserved bit is not defined. NA
#
# http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC1768&type=user
#MEMMAP - set user mode
# mww 0x400FC040 0x01
#}
$_TARGETNAME configure -event reset-init {
# Force target into ARM state
#armv4_5 core_state arm
#do not remap 0x0000-0x0020 to anything but the flash
#mwb 0xE01FC040 0x01
mwb 0x400FC040 0x01
#mwb 0xE000ED08 0x00
}
さて、私のデバッグ cfg ファイル:
#define our ports
#telnet_port 4444
#gdb_port 3333
#commands specific to the Olimex ARM-USB-OCD
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0003
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc1756
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4ba00477
}
if { [info exists CCLK ] } {
set _CCLK $CCLK
} else {
set _CCLK 4000
}
if { [info exists ENDIAN ] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
debug_level 3
jtag_khz 100
#delays on reset lines
adapter_nsrst_delay 200
jtag_ntrst_delay 200
#reset_config srst_only
reset_config trst_and_srst srst_pulls_trst
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
#target cortex_m3 little 0 armv7
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
#
$_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000
$_TARGETNAME configure -work-area-backup 0
#working_area 0 0x10000000 0x8000 nobackup
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME lpc2000 0x0 0x40000 0 0 $_TARGETNAME lpc1700 $_CCLK calc_checksum
$_TARGETNAME configure -event reset-init {
# Force target into ARM state
#armv4_5 core_state arm
#do not remap 0x0000-0x0020 to anything but the flash
mwb 0xE01FC040 0x01
mwb 0x400FC040 0x01
mwb 0xE000ED08 0x00
}
gdb_flash_program enable
init
#fast enable
jtag_khz 100
debug_level 1
Eclipse では、次のフラグを指定してこのツールを呼び出します。
-f arm-usb-ocd.cfg -f debug.cfg
これは問題なく動作しているようです (少なくとも、コンソールにエラーは表示されないようです)。今、私が問題を抱えている部分があります:
GDB Hardware Debugging の下にある Eclipse (Run > Debug Configurations...) でデバッグ構成を作成しました。関連するパラメータは次のとおりです。
Main:
C/C++ Application: output\project_UT1.elf
Debugger:
C:\CodeSourcery\bin\arm-none-eabi-gdb.exe
Startup:
Reset and Delay checked (2-seconds)
Halt checked
Initialization commands:
target remote localhost:3333
monitor flash device = LPC1756
monitor flash download = 1
monitor flash breakpoints = 1
monitor endian little
monitor speed 100
monitor speed auto
monitor reset halt
monitor writeu32 0x400FC040 = 0x00000001
monitor clrbp
Load image: not checked
Load symbols: checked
Runtime options: none of Set program counter, set breakpoint or resume checked
Run commands:
monitor reg sp = 0x10001ffc
monitor reg pc = 0x00001278
continue
Using "Standard GDB Hardware Debugging Launcher"
(注: PC を 0x00001278 に設定しました。これが私の Reset_Handler のアドレスだったからです。0x00000004 にする必要があることはわかっていますが、実験していました。0x00000004 のときに同じ問題が発生しました...)
このセットアップを使用してデバッグしようとすると、「GDB Hardware Debugging Suspended」というメッセージが表示され、PC がブートローダー 0x1FFF0080 にあるように見え、デバッガーが接続されていないように見えます。コンソールには、次のようなものが表示されます。
.
.
.
target remote localhost:3333
0x1fff0080 in ?? ()
.
.
.
continue
Program received signal SIGINT, Interrupt.
0x1fff0080 in ?? ()
たとえば、逆アセンブリ ウィンドウでは、「main」や「Reset_Handler」などを検索して見つけることができますが、逆アセンブリはすべて「movs r0, r0」であり、基本的にすべてゼロです。私は単一のステップを実行できません (明らかに、一時停止されています...)おそらくJTAGインターフェースは死んでいない...)
フラッシュされた画像は 0x00000000 (つまり、そこにあるベクター テーブル) にあるはずです。dump_image を実行すると、デバイスがプログラムされているように見え、ベクター テーブル エントリが正しく表示されます。コード保護?もしそうなら、明らかに成功した「ダンプ+イメージ」を行うにはどうすればよいですか?
ただし、JTAG を接続せずにデバイスを接続しても、動作しません。LPC1768 についてこれに似た投稿を見たことがありますが、自分に合うものは見つかりませんでした。アドバイスや提案は大歓迎です。