lpc2138 and openocd problem

I am trying to get openocd 0.3.0 (latest from GIT) to work with my LPC2138 board.

I am running under WinXP/cygwin, and have built openocd this way.

I am running the following config for openocd:

file lpc2138.cfg:

if { [info exists CHIPNAME] } {
   set _CHIPNAME $CHIPNAME
} else {
   set _CHIPNAME lpc2138
}

if { [info exists ENDIAN] } {
   set _ENDIAN $ENDIAN
} else {
   set _ENDIAN little
}

if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
   set _CPUTAPID 0x4f1f0f0f
}

jtag_nsrst_delay 200
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.

reset_config trst_and_srst srst_pulls_trst

jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4

$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x40000000 -work-area-size 0x8000 -work-area-backup 0

$_TARGETNAME configure -event reset-init {
	# Force target into ARM state.
	soft_reset_halt

	# 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 section 7.1 on page 32 ("Memory Mapping control register") in
	# "UM10120".
	#

	mwb 0xE01FC040 0x01

#	jtag_khz 1500
}

# flash bank lpc2000 <base> <size> 0 0 <target#> <variant> <clock> [calc_checksum]
flash bank lpc2000 0x0 0x7d000 0 0 0 lpc2000_v2 14765 calc_checksum

testconfig.cfg:

source [find tcl/target/lpc2138.cfg]
source [find tcl/interface/olimex-jtag-tiny.cfg]

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

#daemon configuration
telnet_port 4444
gdb_port 3333

jtag_speed 3

init

reset init

I am running openocd with the command “openocd.exe -d 3 -f testconfig.cfg”, and I am then running this set of commands using gdb from within eclipse:

target remote localhost:3333

monitor reset init

monitor sleep 500

#monitor poll

monitor soft_reset_halt

monitor mww 0xE01FC040 0x0002

monitor mdw 0xE01FC040

needed for gdb 6.8 and higher

set mem inaccessible-by-default off

load

break main

continue

I can connect to the lpc2138 and all, but I cant seem to get the target halted as all goes wrong as soon as I perform the first monitor-command.

The flash-based program in the LPC blinks a LED, and this stops after executing “monitor soft_reset_halt”, while OCD doesn’t seem to believe the target to be halted.

Anyone see anything wrong with my approach?

Here is the log from the above attempt:

http://pastebin.com/f7db4da54

(the forum didnt approve of some of the words in the log)

I would try setting jtag_speed to 1, see if that helps.

bobcousins:
I would try setting jtag_speed to 1, see if that helps.

I tried jtag_speed 1 and 2, with the result of no communication.

I also tried jtag_speed 10 to slow things down, and still I get this gdb output:

monitor sleep 500

monitor armv4_5 core_state arm

core state: ARM

monitor mww 0xE01FC040 0x0002

target not halted

Runtime error, file “command.c”, line 473:

Can this be a problem with openocd 0.3.0 ?

Try to add:

monitor wait_halt

after

monitor soft_reset_halt 

seems like I had P0.14 in the wrong setting, now the chip runs my code.

What’s P0.14? and what’s the correct setting? Thanks.