Cannot erase flash LPC2103 + OpenOCD + Olimex USB Tiny

Hi,

I have been banging my head against the desk trying to figure out how to erase flash memory via JTAG. There are no errors reported, but the memory won’t change.

Similar to viewtopic.php?t=8961 (but of course no solution for me there)

Using the phillips ISP programmer utility works fine - it can erase the flash and write hex/elf files correctly.

OpenOCD r657, Olimex JTAG USB Tiny

The target is a LPC2103 on an ETT ARM http://www.futurlec.com.au/ARM2103_Controller.jsp

Here’s a telnet session to Open OCD

> poll
target state: halted
target halted in ARM state due to breakpoint, current mode: System
cpsr: 0x800000df pc: 0x000002b4
> flash info 0
#0: lpc2000 at 0x00000000, size 0x00008000, buswidth 0, chipwidth 0
        #0: 0x00000000 (0x1000 4kB) protected
        #1: 0x00001000 (0x1000 4kB) protected
        #2: 0x00002000 (0x1000 4kB) protected
        #3: 0x00003000 (0x1000 4kB) protected
        #4: 0x00004000 (0x1000 4kB) protected
        #5: 0x00005000 (0x1000 4kB) protected
        #6: 0x00006000 (0x1000 4kB) protected
        #7: 0x00007000 (0x1000 4kB) protected
lpc2000 flash driver variant: 2, clk: 0
> flash erase_check 0
successfully checked erase state
        #0: 0x00000000 (0x1000 4kB) not erased
        #1: 0x00001000 (0x1000 4kB) erased
        #2: 0x00002000 (0x1000 4kB) erased
        #3: 0x00003000 (0x1000 4kB) erased
        #4: 0x00004000 (0x1000 4kB) erased
        #5: 0x00005000 (0x1000 4kB) erased
        #6: 0x00006000 (0x1000 4kB) erased
        #7: 0x00007000 (0x1000 4kB) erased
> flash erase_sector 0 0 0
erased sectors 0 through 0 on flash bank 0 in 0.234375s
> poll
target state: halted
target halted in ARM state due to breakpoint, current mode: System
cpsr: 0x800000df pc: 0x000002b4
> flash info 0
#0: lpc2000 at 0x00000000, size 0x00008000, buswidth 0, chipwidth 0
        #0: 0x00000000 (0x1000 4kB) protected
        #1: 0x00001000 (0x1000 4kB) protected
        #2: 0x00002000 (0x1000 4kB) protected
        #3: 0x00003000 (0x1000 4kB) protected
        #4: 0x00004000 (0x1000 4kB) protected
        #5: 0x00005000 (0x1000 4kB) protected
        #6: 0x00006000 (0x1000 4kB) protected
        #7: 0x00007000 (0x1000 4kB) protected
lpc2000 flash driver variant: 2, clk: 0
> flash erase_check 0
successfully checked erase state
        #0: 0x00000000 (0x1000 4kB) not erased
        #1: 0x00001000 (0x1000 4kB) erased
        #2: 0x00002000 (0x1000 4kB) erased
        #3: 0x00003000 (0x1000 4kB) erased
        #4: 0x00004000 (0x1000 4kB) erased
        #5: 0x00005000 (0x1000 4kB) erased
        #6: 0x00006000 (0x1000 4kB) erased
        #7: 0x00007000 (0x1000 4kB) erased
> flash erase_sector 0 0 0
erased sectors 0 through 0 on flash bank 0 in 0.234375s
>> flash erase_sector 0 0 0
erased sectors 0 through 0 on flash bank 0 in 0.234375s
> flash erase_check 0
successfully checked erase state
        #0: 0x00000000 (0x1000 4kB) not erased
        #1: 0x00001000 (0x1000 4kB) erased
        #2: 0x00002000 (0x1000 4kB) erased
        #3: 0x00003000 (0x1000 4kB) erased
        #4: 0x00004000 (0x1000 4kB) erased
        #5: 0x00005000 (0x1000 4kB) erased
        #6: 0x00006000 (0x1000 4kB) erased
        #7: 0x00007000 (0x1000 4kB) erased
> mdb 0 64
0x00000000: 18 f0 9f e5 18 f0 9f e5 18 f0 9f e5 18 f0 9f e5 18 f0 9f e5 84 5f 20 b9 f0 ff 1f e5 14 f0 9f e5
0x00000020: 00 02 00 00 fc 07 00 00 e8 07 00 00 fc 07 00 00 fc 07 00 00 c0 07 00 00 d4 07 00 00 00 00 00 00
>

Heres the config:

#daemon configuration
telnet_port 4444
gdb_port 3333


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

jtag_speed 50
jtag_nsrst_delay 200
jtag_ntrst_delay 200 

#LPCs need reset pulled while RTCK is low. 0 to activate JTAG, power-on reset is not enough
jtag_reset 1 1
jtag_reset 0 0

#use combined on interfaces or targets that can't set TRST/SRST separately
#reset_config trst_and_srst trst_pulls_srst
reset_config trst_and_srst srst_pulls_trst


#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe

#target configuration
daemon_startup reset

#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little run_and_init 0 arm7tdmi-s_r4

run_and_halt_time 0 30

target_script 0 reset lpc2103_reset.script

working_area 0 0x40000200 0x1300 nobackup


#flash configuration
#flash bank lpc2000 0x0 0x8000 0 0 0 lpc2000_v2 0 19660 calc_checksum
flash bank lpc2000 0x0 0x8000 0 0 0 lpc2000_v2 0 58980 calc_checksum

And the reset script:

#do not remap 0x0000-0x0020 to anything but the flash
mwh 0xE01FC040 0x0001

My crystal is 19.6608 Mhz and the program sets the pll to run at 3x (58.980 Mhz). As I understand it, by the time the target can be halted, even after reset, the target is using the PLL speed.

Flash copy protection (0x1fc is not set) (Apparently thought the banks will always appear protected with the flash info command - thats normal)

I have tried slowing down, speeding up, different crystal/clock combos

I’m out of ideas. Would really appreciate any help !

Cheers

Marc