EmbeddedRelated.com
Forums
Memfault Beyond the Launch

please share your LPC2103 OpenOCD script and GDB commands

Started by Casainho May 12, 2009
Hello :-)

I got my OpenOCD scripts and GDB commands by mixing a lot of sources.

I am looking to program and debug the code on the flash. I am using
the Olimex Header board, for LPC2103.

My OpenOCD script:

#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface ft2232
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0004
jtag_speed 10

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

#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
#target arm7tdmi
target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
#run_and_halt_time 0 10

#target_script 0 reset oocd_flash2138.script
working_area 0 0x40000000 0x2000 nobackup

#flash configuration
flash bank lpc2000 0x0 0x8000 0 0 0 lpc2000_v2 14745 calc_checksum
# pre-OpenOCD189
#flash bank lpc2000 0x0 0x40000 0 0 lpc2000_v2 0 14745 calc_checksum

# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
My GDB commands:

target remote localhost:3333
monitor flash write_image erase ../main.bin 0x0 bin
monitor sleep 500

monitor soft_reset_halt

monitor gdb_breakpoint_override hard

symbol-file main.out

continue
I am having problems, most part of the time PC goes to bootloader
section :-( also looks to me that peripherals registers are not
getting their correct value after reset :-(

Thank you.
Jorge "Casainho" Pinto
http://www.casainho.net

An Engineer's Guide to the LPC2100 Series

Am 5/12/2009 4:19 PM, also sprach Casainho:
> Hello :-)
>
> I got my OpenOCD scripts and GDB commands by mixing a lot of sources.
>
> I am looking to program and debug the code on the flash. I am using
> the Olimex Header board, for LPC2103.
>
> My OpenOCD script:
>
> #daemon configuration
> telnet_port 4444
> gdb_port 3333
>
> #interface
> interface ft2232
> ft2232_layout "olimex-jtag"
> ft2232_vid_pid 0x15BA 0x0004
> jtag_speed 10
>
> #use combined on interfaces or targets that can't set TRST/SRST separately
> reset_config trst_and_srst separate
>
> #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
> #target arm7tdmi
> target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
> #run_and_halt_time 0 10
>
> #target_script 0 reset oocd_flash2138.script
> working_area 0 0x40000000 0x2000 nobackup
>
> #flash configuration
> flash bank lpc2000 0x0 0x8000 0 0 0 lpc2000_v2 14745 calc_checksum
> # pre-OpenOCD189
> #flash bank lpc2000 0x0 0x40000 0 0 lpc2000_v2 0 14745 calc_checksum
>
> # For more information about the configuration files, take a look at:
> # http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
> My GDB commands:
>
> target remote localhost:3333
> monitor flash write_image erase ../main.bin 0x0 bin
> monitor sleep 500
>
> monitor soft_reset_halt
>
> monitor gdb_breakpoint_override hard
>
> symbol-file main.out
>
> continue
> I am having problems, most part of the time PC goes to bootloader
> section :-( also looks to me that peripherals registers are not
> getting their correct value after reset :-(
>
> Thank you.
> Jorge "Casainho" Pinto
> http://www.casainho.net
>
LPC2368
I am using eclipse/yagarto with an Olimex ARM-USB-OCD. I use FlashMagic
to download.
One USB port on the PC goes to the Olimex.
Two USB port on the PC goes to a bridge.
One port goes to USB-RS232 cable to COM0 on the LPC2368.
Two port goes to USB on the 2368 (not needed for debugging).

SerialEnum.exe tells me what com port the Radio Shack USB-RS232 is on
for FlashMagic.
The Olimex must be unplugged from the PC for FlashMagic to work.

In gdb, i get two breakpoints. If i have more than two set, then there
is no halt on reset,
target runs in the weeds, etc. Sometimes i can delete the third
breakpoint and recover.
Somtimes i have to unplug the ocd. And if i want to do "step over" then
0 breakpoints is best.
"step into" can handle having one breakpoint.

It feels a bit like driving a Model T with a manual choke and timing,
and no synchros in the tranny, but it works.
----------
script ocd sez:

#!/bin/bash
cd "/c/Program Files (x86)/openocd-r717/bin"
./openocd-ftd2xx.exe -f scripts/lpc2148/lpc2xxx_armusbocd.cfg

----------
script scripts/lpc2148/lpc2xxx_armusbocd.cfg sez:

#daemon configuration
telnet_port 4444
gdb_port 10000

# tell gdb our flash memory map
# and enable flash programming
gdb_memory_map enable
gdb_flash_program enable

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

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

#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

#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
#target arm7tdmi
target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
run_and_halt_time 0 30

working_area 0 0x40000000 0x4000 nobackup

#flash bank lpc2000 0 0
flash bank lpc2000 0x0 0x7d000 0 0 0 lpc2000_v2 14765 calc_checksum

# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger

----------

gdb commands:

monitor soft_reset_halt
monitor arm7_9 force_hw_bkpts enable
symbol-file myapp.elf
thbreak main
continue
----------

dik

--- In l..., Casainho wrote:
My OpenOCD.cfg file is included below.

I do NOT use JTAG to download code. I use FlashMagic via UART instead.

Here's my list of project specifics...

LCP2103 (Olimex LPC-P2103)
Eclipse Ganymede
YAGARTO
OpenOCD
FlashMagic
Olimex USB JTAG Tiny
FreeRTOS

TC

++++
#File: openocd.cfg
#
#OpenOCD Congfiguration File for NXP LPC2103 development with Eclipse+ZylinCDT+Yagarto
#
#Using Olimex LPC-P2103 board
# Product page: http://www.olimex.com/dev/lpc-p2103.html
# Schematic: http://www.olimex.com/dev/images/lpc-p2103-sch.gif
#
#Using Olimex ARM-USB-TINY JTAG debugger
# Product page: http://www.olimex.com/dev/index.html (click on ARM-USB-TINY link)
#
#Using openocd-r717
# NOTE: Edit the following files and change all occurences of "PID_0003" to "PID_0004"
# NOTE: Do NOT make any other edits
# NOTE: Assumes your OpenOCD directory is C:/Program Files/openocd-r717
# C:/Program Files/openocd-r717/driver/arm-usb-ocd/ftd2xx.inf
# C:/Program Files/openocd-r717/driver/arm-usb-ocd/ftdibus.inf
# C:/Program Files/openocd-r717/driver/arm-usb-ocd/ftdiport.inf
# NOTE: Install ARM-USB-TINY JTAG debugger and device drivers (listed above)
#
#NOTE: For more information about OpenOCD configuration files see:
# C:/Program Files/openocd-r717/doc/openocd.pdf
#

#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
#URL: http://svn.berlios.de/svnroot/repos/openocd/trunk
#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


Memfault Beyond the Launch