Hi,
I’m running OpenOCD v0.2.0 with an Olimex Usb-Arm-Tiny on a LPC2148 board, but can’t seem to debug, (or read/write to flash for that matter).
Is it possible to debug code running from flash? Is setting breakpoints or halting the target only on ARM processors running out of RAM, and not ARM microcontrollers
like the LPC2148 running out of Flash?
This is the config file I’m using, basically only modified for the olimex tiny and a 12mhz clock for the lpc2148:
#
# For more information about the configuration files, take a
# look at the "Open On-Chip Debugger (openocd)" documentation.
#
# daemon configuration
telnet_port 4444
gdb_port 3333
tcl_port 6666
# tell gdb our flash memory map
# and enable flash programming
gdb_memory_map enable
gdb_flash_program enable
#########################################################
#
# Interface, if you want to use an other interface
# you must replace this section here.
#
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG TINY A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0004
#########################################################
#
# Start slow, speed up after reset
jtag_khz 30
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc2148
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4f1f0f0f
}
jtag_nsrst_delay 250
jtag_ntrst_delay 250
# NOTE!!! LPCs need reset pulled while RTCK is low. 0 to activate
# JTAG, power-on reset is not enough, i.e. you need to perform a
# reset before being able to talk to the LPC2148, attach is not possible.
reset_config trst_and_srst srst_pulls_trst
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4
$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x40000000 -work-area-size 0x4000 -work-area-backup 0
$_TARGETNAME configure -event reset-start {
jtag_khz 30
}
$_TARGETNAME configure -event reset-init {
# Force target into ARM state.
soft_reset_halt
# Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
# "User Flash Mode" where interrupt vectors are _not_ remapped,
# and reside in flash instead).
#
# See section 7.1 on page 32 ("Memory Mapping control register") in
# "UM10139: Volume 1: LPC214x User Manual", Rev. 02 -- 25 July 2006.
# http://www.standardics.nxp.com/support/documents/microcontrollers/pdf/user.manual.lpc2141.lpc2142.lpc2144.lpc2146.lpc2148.pdf
mwb 0xE01FC040 0x01
jtag_khz 1500
}
# flash bank lpc2000 <base> <size> 0 0 <target#> <variant> <clock> [calc_checksum]
flash bank lpc2000 0x0 0x7d000 0 0 0 lpc2000_v2 12000 calc_checksum
#########################################################
init
reset init
And invoking it with openocd-ftd2xx, I get this output:
C:\test>openocd-ftd2xx -f olimex_usb_arm_tiny.cfg
Open On-Chip Debugger 0.2.0 (2009-08-24-22:44) Release
$URL: http://svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.2.0/src/openocd
.c $
For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS
30 kHz
jtag_nsrst_delay: 250
jtag_ntrst_delay: 250
Info : device: 4
Info : deviceID: 364511236
Info : SerialNumber: FTRF9W5CA
Info : Description: Olimex OpenOCD JTAG TINY A
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
Info : JTAG Tap/device matched
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x000000d3 pc: 0x000004c8
30 kHz
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
Info : JTAG Tap/device matched
Warn : srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in ARM state due to debug-request, current mode: Abort
cpsr: 0x000000d7 pc: 0x0000044c
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x000000d3 pc: 0x00000000
Warn : memory write caused data abort (address: 0xe01fc040, size: 0x1, count: 0x
1)
Runtime error, file "olimex_usb_arm_tiny.cfg", line 11:
Not sure why the memory write caused data abort or the runtime error on line 11 (gdb_memory_map enable?) but this is the gdb file I’m using for initialization, I didn’t modify it all:
target remote localhost:3333
monitor reset init
monitor sleep 500
#monitor poll
#monitor soft_reset_halt
monitor mww 0xE01FC040 0x0001
monitor mdw 0xE01FC040
# needed for gdb 6.8 and higher
set mem inaccessible-by-default off
load
break main
continue
When I launch the insight debugger with gdb file,
arm-elf-insight -x lpc2148_rom_oocd.gdb Led_Blink.elf
The Insight console window shows:
0xe01fc040: 00000001
Loading section .eh_frame, size 0x33c lma 0x40000200
Loading section .text, size 0xe24 lma 0x0
Loading section .data, size 0x30 lma 0xe24
Start address 0x0, load size 4496
Transfer rate: 686 bytes/sec, 1498 bytes/write.
Breakpoint 1 at 0x28c: file main_blink.c, line 140.
Note: automatically using hardware breakpoints for read-only addresses.
With the command console window updates :
Warn : srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in ARM state due to debug-request, current mode: Abort
cpsr: 0x000000d7 pc: 0x0000044c
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x000000d3 pc: 0x00000000
Warn : memory write caused data abort (address: 0xe01fc040, size: 0x1, count: 0x
1)
Runtime error, file "olimex_usb_arm_tiny.cfg", line 11:
0xe01fc040: 00000001
Warn : Verification will fail since checksum in image(0xe1a00000) written to flash was different from calculated vector checksum(0xb9205f84).
Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1219). Workaround: increase "set remotetimeout" in GDB
Error: timed out while waiting for target halted
Warn : lpc2000 prepare sectors returned 13822120
Error: failed erasing sectors 0 to 0 (-902)
Error: flash_erase returned -902
Most of the time it will just freeze here, waiting for the target to halt, and no timeout… but occasionally
the main Insight window comes up that would allow me to step thru the source code but I immediately get this error:
Error: timed out while waiting for target halted
Warn : lpc2000 prepare sectors returned 13822120
Error: failed erasing sectors 0 to 0 (-902)
Error: flash_erase returned -902
Is it possible for code to be stepped thru running out of the lpc2148 (flash)?
(I downloaded an eval version of crossworks arm but that too shows an error that the target cannot be halted… perhaps there is something wrong with
reset hardware?)
If Anyone has a cfg/gdb for an lpc2148 that can debug or read/write a hex file to the flash that would be great!