首先安装openocd,具体步骤请参考我前面的文章。
然后就是配置openocd,以下是我的配置,仅供参考,也希望更多的人能够共同成长,一同分享:
telnet_port 4444
tcl_port 6666
gdb_port 2331
# GDB Setup
#gdb_port 3333
#gdb_breakpoint_override hard
#gdb_memory_map enable
#gdb_flash_program enable
#-------------------------------------------------------------------------
# interface Setup
#-------------------------------------------------------------------------
interface jlink
#-------------------------------------------------------------------------
# target Setup
#-------------------------------------------------------------------------
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME s3c6410
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
# this defaults to a bigendian
set _ENDIAN little
}
# trace buffer
if { [info exists ETBTAPID ] } {
set _ETBTAPID $ETBTAPID
} else {
# force an error till we get a good number
set _ETBTAPID 0x2b900f0f
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
# force an error till we get a good number
set _CPUTAPID 0x07b76f0f
}
#jtag scan chain
jtag newtap $_CHIPNAME etb -irlen 4 -expected-id $_ETBTAPID
jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_CPUTAPID
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm11 -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm1176
jtag interface
jtag_khz 1000
jtag_nsrst_delay 500
jtag_ntrst_delay 500
#reset configuration
arm11 memwrite burst disable
reset_config trst_and_srst
nand device 0 s3c6400 $_TARGETNAME
# trace setup ... NOTE, "normal full" mode fudges the real ETMv3.1 mode
etm config $_TARGETNAME 16 normal full etb
etb config $_TARGETNAME $_CHIPNAME.etb
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME cfi 0x00000000 0x00100000 2 2 $_TARGETNAME
$_TARGETNAME configure -event reset-init {
puts "Halting target"
poll
sleep 1
halt
wait_halt
puts "Clock/Timer settings"
reg cpsr 0x600001D3
arm mcr 15 0 15 2 4 0x70000003
mww 0x7e004000 0x00000000
mww 0x7e00f120 0x00000003
puts "Operating Mode Change to Sync Mode"
mww 0x7e00f900 0x0000805E
sleep 1000
mww 0x7e00f900 0x000080DE
sleep 1000
mww 0x7e00f000 0x0000ffff
mww 0x7e00f004 0x0000ffff
mww 0x7e00f020 0x01047310
mww 0x7e00f00c 0x81900302
mww 0x7e00f010 0x81900303
mww 0x7e00f01c 0x00000003
puts "DRAM Initialization"
mww 0x7e001004 0x00000004
mww 0x7e001010 0x0000030c
mww 0x7e001014 0x00000006
mww 0x7e001018 0x00000001
mww 0x7e00101c 0x00000002
mww 0x7e001020 0x00000007
mww 0x7e001024 0x0000000A
mww 0x7e001028 0x0000000C
mww 0x7e00102C 0x0000010B
mww 0x7e001030 0x0000000C
mww 0x7e001034 0x00000003
mww 0x7e001038 0x00000003
mww 0x7e00103C 0x00000002
mww 0x7e001040 0x00000002
mww 0x7e001044 0x00000011
mww 0x7e001048 0x00000011
puts "Memory Configuration Register"
mww 0x7e00100C 0x00010012
puts "Memory Configuration Register 2"
mww 0x7e00104C 0x00000B41
puts "Chip 0 Configuration"
mww 0x7e001200 0x000150F8
puts "Memory Direct Command"
mww 0x7e001008 0xc0000000
mww 0x7e001008 0x00000000
mww 0x7e001008 0x40000000
mww 0x7e001008 0x40000000
mww 0x7e001008 0x000A0000
mww 0x7e001008 0x00080032
mww 0x7e001004 0x00000000
}
将配置文件复制到你的工作目录下,就是你要load文件的目录
之后:
1、打开minicom,
2、打开开发板,启动uboot,然后在minicom终端中迅速敲任意键
3、进入有配置文件的目录,使用命令openocd,即可启动openocd
4、打开另一个终端2,使用命令telnet localhost 4444
5、在终端2中,使用load_image led.bin 0X50008000
6、在终端2中使用命令resume 0x50008000即可
注意第5 、6步,load文件可以使bin、elf、ihex、s19,若要使用调试功能,就要使用命令step命令