Reply by Owen Farrant June 19, 20102010-06-19
Hi Rolf

Thank you very much for your reply. You were exactly right by adding the
"reset init" allows it to operate as expected. I am very grateful to you for
your assistance. Such I simple change that I have wasted so much time over.

Thank you once again.

Cheers

O.

_____

From: l... [mailto:l...] On Behalf Of
rolf_meeser
Sent: 19 June 2010 11:28
To: l...
Subject: [lpc2000] Re: Hitex LPC2929/39 fail to write to flash

Hi Owen,

--- In l... ,
"owen.farrant" wrote:
> I would appreciate if someone could help me with an issue. I have a
> Hitex 2929/39 evaluation board. I have connected an Olimex
> ARM-USB-OCD and i am using openocd version 0.4.0.

I am using the same board with an LPC2939, OpenOCD 0.4.0 on a Linux machine,
and a J-Link adapter.
Flash programming works fine!

> I am using the following configuration file
>
> telnet_port 4444
> gdb_port 3333
> source [find olimex-arm-usb-ocd.cfg]
> source [find hitex_lpc2929.cfg]
>
> Where all the cfg files have been copied into the same directory.
> I can connect to the board and control it via a telnet session.
> I have managed to erase the flash but I can re-program it.
>
> Open On-Chip Debugger
> > halt
> target state: halted
> target halted in ARM state due to debug-request, current mode: Undefined
instruction
> cpsr: 0x000000db pc: 0x00000004

Looks a bit strange that the CPU ends up in Undefined Instruction mode. When
I execute a "reset init" command, the CPU is in Supervisor mode at address
0:
------------------
* reset init
2000 kHz
JTAG tap: lpc2900.etb tap/device found: 0x1b900f0f (mfg: 0x787, part:
0xb900, ver: 0x1)
JTAG tap: lpc2900.cpu tap/device found: 0x0596802b (mfg: 0x015, part:
0x5968, ver: 0x0)
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x000000d3 pc: 0x00000000
6000 kHz
------------------

My configuration file is similar yours, but I added the "reset init"
command:
------------------
source [find interface/jlink.cfg]
source [find board/hitex_lpc2929.cfg]
telnet_port 4444
gdb_port 2331
tcl_port 6666
init
reset init
------------------

> > flash write_bank 0 blinky.bin 0
> Flash bank 0: Device LPC2939, 768 KiB in 19 sectors timed out while
waiting for target debug-running Unable to write data to target error
writing to flash at address 0x20000000 at offset 0x00000000 (-902) Command
handler execution failed in procedure 'flash' called at file "command.c",
line 650 called at file "command.c", line 361

This is what I get here:
------------------
* flash erase_sector 0 0 18
Flash bank 0: Device LPC2939, 768 KiB in 19 sectors
erased sectors 0 through 18 on flash bank 0 in 0.637007s
* flash write_bank 0 x.bin 0
wrote 786432 bytes from file x.bin to flash bank 0 at offset 0x00000000 in
16.795250s (45.727 kb/s)
------------------

I've got three suggestions:

1. Try adding the "reset init" command. This may already solve it, since
this command invokes a hook in the board script to enable the external
memory interface. External memory is used for the working area!

2. If that doesn't help, try to reduce JTAG clock speed (there are a few
"jtag_khz" statements in hitex_lpc2929.cfg) from the default 2 MHz and 6
MHz.

3. Next step would be to try without using target code. If you comment out
the working area definitions in hitex_lpc2929.cfg, the driver will fall back
to a host-only programming mode. This is much slower, but avoids running
code on the CPU. It takes 103s vs the 16.8s on my machine.
--> #$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size
0x2000 -work-area-backup 0
--> #$_TARGETNAME configure -work-area-phys 0x58000000 -work-area-size
0x10000 -work-area-backup 0

Don't worry about the bunch of warning messages that you will see when using
the "flash write_bank" command. There's nothing wrong with it.

Hope it helps!

Cheers,
Rolf

An Engineer's Guide to the LPC2100 Series

Reply by rolf_meeser June 19, 20102010-06-19
Hi Owen,

--- In l..., "owen.farrant" wrote:
> I would appreciate if someone could help me with an issue. I have a
> Hitex 2929/39 evaluation board. I have connected an Olimex
> ARM-USB-OCD and i am using openocd version 0.4.0.

I am using the same board with an LPC2939, OpenOCD 0.4.0 on a Linux machine, and a J-Link adapter.
Flash programming works fine!
> I am using the following configuration file
>
> telnet_port 4444
> gdb_port 3333
> source [find olimex-arm-usb-ocd.cfg]
> source [find hitex_lpc2929.cfg]
>
> Where all the cfg files have been copied into the same directory.
> I can connect to the board and control it via a telnet session.
> I have managed to erase the flash but I can re-program it.
>
> Open On-Chip Debugger
> > halt
> target state: halted
> target halted in ARM state due to debug-request, current mode: Undefined instruction
> cpsr: 0x000000db pc: 0x00000004

Looks a bit strange that the CPU ends up in Undefined Instruction mode. When I execute a "reset init" command, the CPU is in Supervisor mode at address 0:
------------------
* reset init
2000 kHz
JTAG tap: lpc2900.etb tap/device found: 0x1b900f0f (mfg: 0x787, part: 0xb900, ver: 0x1)
JTAG tap: lpc2900.cpu tap/device found: 0x0596802b (mfg: 0x015, part: 0x5968, ver: 0x0)
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x000000d3 pc: 0x00000000
6000 kHz
------------------
My configuration file is similar yours, but I added the "reset init" command:
------------------
source [find interface/jlink.cfg]
source [find board/hitex_lpc2929.cfg]
telnet_port 4444
gdb_port 2331
tcl_port 6666
init
reset init
------------------
> > flash write_bank 0 blinky.bin 0
> Flash bank 0: Device LPC2939, 768 KiB in 19 sectors timed out while waiting for target debug-running Unable to write data to target error writing to flash at address 0x20000000 at offset 0x00000000 (-902) Command handler execution failed in procedure 'flash' called at file "command.c", line 650 called at file "command.c", line 361
This is what I get here:
------------------
* flash erase_sector 0 0 18
Flash bank 0: Device LPC2939, 768 KiB in 19 sectors
erased sectors 0 through 18 on flash bank 0 in 0.637007s
* flash write_bank 0 x.bin 0
wrote 786432 bytes from file x.bin to flash bank 0 at offset 0x00000000 in 16.795250s (45.727 kb/s)
------------------
I've got three suggestions:

1. Try adding the "reset init" command. This may already solve it, since this command invokes a hook in the board script to enable the external memory interface. External memory is used for the working area!

2. If that doesn't help, try to reduce JTAG clock speed (there are a few "jtag_khz" statements in hitex_lpc2929.cfg) from the default 2 MHz and 6 MHz.

3. Next step would be to try without using target code. If you comment out the working area definitions in hitex_lpc2929.cfg, the driver will fall back to a host-only programming mode. This is much slower, but avoids running code on the CPU. It takes 103s vs the 16.8s on my machine.
--> #$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size 0x2000 -work-area-backup 0
--> #$_TARGETNAME configure -work-area-phys 0x58000000 -work-area-size 0x10000 -work-area-backup 0

Don't worry about the bunch of warning messages that you will see when using the "flash write_bank" command. There's nothing wrong with it.
Hope it helps!

Cheers,
Rolf

Reply by "owen.farrant" June 18, 20102010-06-18
Hi all

I would appreciate if someone could help me with an issue. I have a Hitex 2929/39 evaluation board. I have connected an Olimex ARM-USB-OCD and i am using openocd version 0.4.0. I am using the following configuration file

telnet_port 4444
gdb_port 3333
source [find olimex-arm-usb-ocd.cfg]
source [find hitex_lpc2929.cfg]

Where all the cfg files have been copied into the same directory. I can connect to the board and control it via a telnet session. I have managed to erase the flash but I can re-program it.

Open On-Chip Debugger
> halt
target state: halted
target halted in ARM state due to debug-request, current mode: Undefined instruction
cpsr: 0x000000db pc: 0x00000004

> flash write_bank 0 blinky.bin 0
Flash bank 0: Device LPC2939, 768 KiB in 19 sectors timed out while waiting for target debug-running Unable to write data to target error writing to flash at address 0x20000000 at offset 0x00000000 (-902) Command handler execution failed in procedure 'flash' called at file "command.c", line 650 called at file "command.c", line 361
>

Any pointers you can give me would be appreciated.

Many thanks in advance.

Cheers
Owen.