OPENOCD error with LPC2xxx.cfg file

I am trying to get OPENOCD to work with an IAR LPC2468 kickstart board using an Olimex USB-OCD-H dongle.

Without direct support for the board, I created the following file (IAR_LPC2468.cfg) to point to a LPC2468.cfg file based on other samples in the directory.

# Board from IAR KickStart Kit for LPC2468
#

echo "Start sourcing target/lpc2468.cfg"
source [find target/lpc2468.cfg]
echo "Stop sourcing target/lpc2468.cfg"

# The chip has just been reset.
$_TARGETNAME configure -event reset-init {
	flash probe 0
}

I then created an LPC2468.cfg file by cloning the LPC2478.cfg file. The 68 is the same as the 78 other than the lack of an LCD controller. That file looks like this:

# NXP LPC2468 ARM7TDMI-S with:
# 512kB flash (8kB used by bootloader)
# 98kB SRAM (16kB for ETH, 16kB for DMA, 2kB for RTC)
# clocked with 4MHz internal oscillator

echo "Start sourcing target/lpc2xxx.cfg"
source [find target/lpc2xxx.cfg]
echo "Stop sourcing target/lpc2xxx.cfg"

# parameters:
# - core_freq_khz - frequency of core in kHz during flashing, usually equal to connected crystal or internal oscillator, e.g. 12000
# - adapter_freq_khz - frequency of debug adapter in kHz, should be 8x slower than core_freq_khz, e.g. 1000

proc setup_lpc2468 {core_freq_khz adapter_freq_khz} {
	# 504kB flash and 64kB SRAM
	# setup_lpc2xxx <chip_name> <cputapid> <flash_size> <flash_variant> <workarea_size> <core_freq_khz> <adapter_freq_khz>
	# <chip_name>        = lpc2468
  # <cputapid>         = 0x4f1f0f0f
  # <flash_size>       = 0xfe000
  # <flash_variant>    = lpc2000_v2
  # <workarea_size>    = 0x10000
  # <core_freq_khz>    = $core_freq_khz
  # <adapter_freq_khz> = $adapter_freq_khz
  #
  echo "Performing setup_lpc2xxx"
	setup_lpc2xxx lpc2468 0x4f1f0f0f 0x7e000 lpc2000_v2 0x10000 $core_freq_khz $adapter_freq_khz
}

proc init_targets {} {
	# default to core clocked with 4MHz internal oscillator
	echo "Warning - assuming default core clock 4MHz! Flashing may fail if actual core clock is different."
	
	# setup_lpc2468 <core_freq_khz> <adapter_freq_khz>
	setup_lpc2468 4000 500
}

Now when I run openocd, I get the following output:

C:\openocd-0.6.1\bin>openocd
Open On-Chip Debugger 0.6.1 (2012-10-07-10:34)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Start sourcing target/lpc2468.cfg
Stop sourcing target/lpc2468.cfg
Runtime Error: C:/openocd-0.6.1/bin/../scripts/board/iar_lpc2468.cfg:11: can't r
ead "_TARGETNAME": no such variable
in procedure 'script'
at file "embedded:startup.tcl", line 58
at file "openocd.cfg", line 2
at file "C:/openocd-0.6.1/bin/../scripts/board/iar_lpc2468.cfg", line 11
Warning - assuming default core clock 4MHz! Flashing may fail if actual core clo
ck is different.
Inside lpc2xxx.cfg in setup_lpc2xxx
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
adapter speed: 500 kHz
Info : max TCK change to: 30000 kHz
Info : clock speed 500 kHz
Info : JTAG tap: lpc2478.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf
1f0, ver: 0x4)
Info : Embedded ICE version 7
Error: EmbeddedICE v7 handling might be broken
Info : lpc2478.cpu: hardware has 2 breakpoint/watchpoint units

OPENOCD sources the board file and the sources the lpc2468.cfg file without error. But returning from sourcing the target/lpc2468.cfg file it hits the code: $_TARGETNAME configure -event reset-init. At this moment, the variable $_TARGETNAME has not been defined as setup_lpc2468 has yet to be called. The output returns a “Runtime Error” but continues on. At some point later, setup_lpc2468 does get called and the variable set.

Question:

Is this an error, and if so, how to I correct the use of the undefined function before it gets defined. And how does this work for other boards that use the LPC?

Also, can anyone comment on the last Error that EmbeddedICE v7 might be broken?

try adding global declaration - not tested.

# Board from IAR KickStart Kit for LPC2468
#

echo "Start sourcing target/lpc2468.cfg"
source [find target/lpc2468.cfg]
echo "Stop sourcing target/lpc2468.cfg"

global _TARGETNAME

# The chip has just been reset.
$_TARGETNAME configure -event reset-init {
   flash probe 0
}

Spen