OpenOCD 0.1.0 with LPC288X flash driver

What I’ve got:

OpenOCD 0.1.0 (2009-01-21-21:15) Release.

Olimex LPC2888 header board (LPC-H2888).

Olimex USB-JTAG adapter (ARM-USB-OCD).

I also have installed the Eclipse package and IAR EW ARM as well, but let’s forget that for now.

My LPC288x.cfg looks like this:

#jtag interface
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0003

telnet_port 4444
gdb_port 3333
tcl_port 6666

#set  _CHIPNAME lpc288x
#set  _ENDIAN little
#set CPUTAPID 0x4f1f0f0f

jtag_nsrst_delay 200
jtag_ntrst_delay 200

jtag_khz 300

reset_config trst_and_srst srst_pulls_trst

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

target create lcp288x.cpu arm7tdmi -endian little -chain-position lpc288x.cpu -variant arm7tdmi-s_r4
lcp288x.cpu configure -work-area-virt 0 -work-area-phys 0x00400000 -work-area-size 0x4000 -work-area-backup 0
lcp288x.cpu configure -event reset-init {
	soft_reset_halt
	#do not remap 0x0000-0x0020 to anything but the flash #lpc2888 
	mww 0x80104018 0x82
}

#flash bank lpc2000 <base> <size> 0 0 <target#> <variant> <cclk> [options..]
#flash_bank lpc288x 0x00000000 0x100000 0 0 0 12000000
flash_bank lpc288x 0x10400000 0x100000 0 0 0 12000000

Well ok, I start openocd, connect via telnet and enter “reset init”.

Now the core is halted and flash memory is mapped to addr 0. However, I’ve entered the physical address in the cfg file.

I now try to unprotect the sectors:

flash protect 0 0 22 off

the return message tells me that the locks have been cleared.

However, calling

flash info 0

shows that still all sectors are protected.

Same result when using remapped flash memory address at 0x00.

In former cfg files the clock (12MHz) param should be entered in kHz, however, the source code for the lpc288x driver expects Hz values. Trying different values here doesn’t give any different results.

Any hints? I’m completely new to ARM and this and here is where I’m stuck - any help is appreciated!

Ok, I am not really sure why the lpc288x flash driver doesn’t work…

However, I managed to kill the user program marker (0xaa55aa55 at 0x104ff800) manually by using jtag memory access sequences.

reset halt

# flash clock setup

mww 0x80102000 5     # F_CTRL = WEN | CS
mww 0x8010201c 0x3c  # F_CLK_TIME = 0x3C,  (12MHz/66kHz/3)
#mdw 0x80102004      # F_STAT & RDY == RDY ?

# unprotect sector 22

mww 0x104ff800 0x00   # base sector 22
mww 080102000 0x8087  # F_CTRL = PROG_REQ | PROTECT | WEN | FUNC | CS

# erase sector 22

#mdw 0x80102004       # F_STAT & DONE == DONE ?
mww 0x80102008 0xA49F # F_PROG_TIME = 9375 | ENABLE
mww 0x80102000 0x1081 # F_CTRL = PROG_REQ | PROTECT | CS

Afterwards the sector is erased and the flash app inactive making the DFU bootloader reappear.