OpenOCD config for LPC2478

Started by Kevin Townsend March 14, 2009
I've been having a heck of a time getting the latest build of OpenOCD to work with a P2478 board, and was wondering if anyone here has had any success configuring with this combination?

I'm using OpenOCD 0.1.0 (the latest downloadable binaries), an Olimex ARM-USB-OCD, and an Olimex P2478-STK board. I can get OpenOCD up and running 'seemingly' properly, and can connect over GDB, etc., in Eclipse, but I am unable to soft reset, load the code, etc., as visible in the following output:


source .gdbinit
target remote
Load$$ER_FLASH$$Base () at E:\MicroFrameworkPK_v3_0\DeviceCode\coresrm\AssemblyCoderm\GNU_S\FirstEntry.s:102
102 msr cpsr_c, #PSR_MODE_SYSTEM @ go into System mode, interrupts off
Current language: auto; currently asm
monitor reset
JTAG tap: lpc2478.cpu tap/device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
JTAG Tap/device matched

monitor sleep 500

monitor poll
target state: running

monitor soft_reset_halt
requesting target halt and executing a soft reset
Failed to halt CPU after 1 sec

monitor arm7_9 force_hw_bkpts enable
invalid command name "arm7_9_force_hw_bkpts"
called at file "command.c", line 456
called at file "embedded:startup.tcl", line 89
called at file "embedded:startup.tcl", line 93
break PreStackEntry
Breakpoint 1 at 0x4: file E:\MicroFrameworkPK_v3_0\DeviceCode\coresrm\AssemblyCoderm\GNU_S\FirstEntry.s, line 110.
Loading section ER_STACK_BOTTOM, size 0x4 lma 0x40000400
Load failed
Note: automatically using hardware breakpoints for read-only addresses.
Cannot insert hardware breakpoint 1.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.


Just for reference sake, these are the commands I'm trying to send:

target remote
monitor reset
monitor sleep 500
monitor poll
monitor soft_reset_halt
monitor arm7_9 force_hw_bkpts enable
break PreStackEntry

Hardly anything exotic, I think ??? I anyone has a set of working config files for OpenOCD and any of the 246x, 247x, 237x chips, I'd love to see them just to compare notes, so to speak.


An Engineer's Guide to the LPC2100 Series

I'm new to OpenOCD myself and struggled getting it to work for my LPC2103 project. I can't offer specifics for your board but I can share what worked for me. I tried to identify the bare minimum that worked and spent quite a bit of time with the OpenOCD documentation and doing experiments. There are some "defaults" that I rely on OpenOCD to establish (the defaults can be found in the documentation). One such example is "monitor arm7_9 force_hw_brkpts enable". The current version of OpenOCD figures that out and sets it by default.

I'm using the Olimex LPC-P2103 board and the Olimex USB JTAG Tiny for debugging. I use FlashMagic and a USB-RS232 port for code flash.

Here is my OpenOCD.CFG file.


#Daemon Configuration
telnet_port 4444
gdb_port 3333

#JTAG Interface Configuration
interface ft2232 0
jtag_speed 3
reset_config trst_and_srst
jtag_device 4 0x1 0xf 0xe

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

#Target Configuration
target arm7tdmi little reset_run 0
run_and_halt 0 10
working_area 0 0x40000000 0x2000 nobackup

#Flash Configuration
#NOTE: NOT using OpenOCD to update FLASH (using FlashMagic instead)
#NOTE: GDB still needs to know the memory map (via OpenOCD)
flash bank lpc2000 0x00000000 0x8000 0 0 0 lpc2000_v2 14746 calc_checksum

#Use the following information to configure OpenOCD as an Eclipse external tool
# Location:
# C:\Program Files\openocd-r717\bin\openocd-ftd2xx.exe
# Arguments:
# -f openocd.cfg
# -c init

#Eclipse debugger console output captured from OpenOCD:
#Open On-Chip Debugger (2008-06-19 19:00) svn: 717
#Info: options.c:50 configuration_output_handler(): jtag_speed: 3, 3
#Info: jtag.c:1389 jtag_examine_chain(): JTAG device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)

#End: openocd.cfg


To work around path issues I simply put a copy of OpenOCD.cfg in each project directory in my Eclipse workspace.

Here are my GDB "initialize" commands:

target remote localhost:3333
info mem
set $pc = 0x0
monitor poll

Here are my GDB "run" commands:

break main
clear main
info breakpoints

I hope this helps you (or others...).

I had a similar problem when I switched from using the Signalyzer dongle to
use the ARM-USB-TINY from Olimex.

Initially using the Signalyzer with Eclipse worked flawless, but after
switching to the ARM-USB-TINY I could not download anymore.
I could connect to the target, red/write registers and memory without any
problems. What I found is that once the core was running, issuing a HALT
command would cause a "TIMEOUT waiting for the AMR to halt" (or similar
If the cor is not halted, GDB still continues to work off the commands in
the list but will report that the download did not succed.

What I ended up doing is issuing two reset commands on startup of the
debugger seperated by a 1000ms pause. So far this seems to work fine for me.

Here are my commands from the ECLIPS command tab in the debug configuration

target remote localhost:3333
monitor sleep 500
monitor reset
monitor sleep 1000
monitor reset
monitor poll
monitor mwh 0xE01FC040 0x0001
monitor flash probe 0
monitor flash protect 0 0 7 off
monitor flash write_image erase SIO_rom.hex ihex
monitor reset
monitor sleep 500
monitor reset
monitor poll
monitor soft_reset_halt
monitor arm7_9 force_hw_bkpts enable
symbol-file SIO_rom.elf
monitor halt
monitor poll
thbreak main
monitor reg pc 0x00000000

I am sure there could be improvements made, but once I got it running I just
left it alone.