## Here is a sample .gdbinit file for use with the gdb debugger.  If
## you run gdb and select the target 'sim', you can run the program in
## the simulator without having any actual ARM hardware.  As it is,
## this file is set up to run the led1.asm (led1.s) (led1.elf) program
## on an LPC2378 board via a JTAG cable and openOCD.

## NOTE -- ** you must edit the paths to suit your directory structure **


## from within Emacs, try starting gdb with
##   M-x gdb RET gdb-arm -nx -x /home/frank/riscy/p2378/.gdbinit --annotate=3 led1.elf

## above says to ignore the .gdbinit file in ~/ but load the one in .../p2378

## NOTE -- gdb-arm in the above Emacs example works for me because I set up a shell
##         alias like this
##              alias gdb-arm='/usr/local/arm/bin/arm-elf-gdb'
##         you would need to do something similar or give the full path.


#set up to run the led1.elf file

set complaints 1
set output-radix 0x10
set input-radix 0x10

# LPC ARM chips are *always* little endian
set endian little

dir .
set prompt (arm-gdb-examples) 

cd ~/riscy/examples
file led1.elf

# connect to the simulator
#target sim

# connect to openocd running on gdb port 3333
# (you must have started openocd first by running
#     openocd -f lpc2378_wig.cfg 
# in a different terminal
target remote localhost:3333

# This is needed so we can debug in flash memory
monitor arm7_9 force_hw_bkpts enable

# Reset the chip to get to a known state.
#monitor reset
#monitor halt

# LPC Init Values
# Disable IRQ & FIRQ, set SVC mode
#set $cpsr = 0xd3

# Increase the packet size to improve download speed.
# Wish this didn't cause an "Are you sure?" popup.
# At least with small programs, they aren't needed.
#set remote memory-write-packet-size 1024
#set remote memory-write-packet-size fixed

# Write the program executable to flash.
# Since we plan to debug from flash memory, we assume
# the program has already been loaded into the flash.
# If not, use the serial bootloader or use something
# like the following two lines:
#     monitor flash erase <target#> <starting_sector> <ending_sector>
#     monitor flash write <target#> <binary_file>     <load_address>
# e.g. since led1 is so tiny, we only erase 1 sector before loading it.
# (you can type these commands at the gdb prompt)
#     monitor flash erase 0 0 0
#     monitor flash write 0 led1.bin 0

# Load the symbols for the program.
symbol-file led1.elf

# Set a breakpoint
#b _start

# Run to the breakpoint.
#c






