SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By karim
#19233
Flash debugging OpenOCD+Olimex+arm-usb-ocd+Lpc2129

I can't seem to get flash debugging working. I'm using a fresh copy of the 2106 flash demo from Lim Lynch's tutorial, but I don't have a 2106 board. Very little was needed to modify it to make it work with the lpc2129 proto board from Olimex - I just changed the pin number in main.c to use the yellow led on the board and changed the flash and ram lengths appropriately in the linker script. I know the code and arm-usb-ocd are working the because I was able to debug from RAM by pulling the code into the 2294 debugging demo from the yagarto site.

But between the openocd configuration file, the (on reset?) script defined by the config file, the gdb commands in the eclipse debug setup, and my own ignorance - I'm lost and need some help.

Using the configuration that I think is correct (below), when I launch the debug in eclipse - it just stalls at 60% and never progresses. If I remove the last 2 gdb commands (thbreak main and continue), it seems to launch a thread, but that thread seems to be associated solely with the UNDEF_Routine - main never seems to be entered.

Here are the files:

The openocd configuration file:
Code: Select all
#daemon configuration
telnet_port 4444
gdb_port 3333

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

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

#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 <type> <startup mode>
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
run_and_halt_time 0 30
target_script 0 reset oocd_flash2106.script
working_area 0 0x40000000 0x40000 nobackup

#flash configuration
flash bank lpc2000 0x0 0x20000 0 0 lpc2000_v1 0 14765 calc_checksum
#flash bank cfi 0x80000000 0x400000 2 2 0

# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
The referenced openocd reset script:
Code: Select all
# LPC2106 flash command-"batch"
# adapted by Martin Thomas based on information from Dominic Rath - Thanks
sleep 500
poll
flash probe 0
flash erase 0 0 0
flash write 0 main.bin 0x0
reset run
sleep 500
And the eclipse debug commands:
Code: Select all
target remote localhost:3333
monitor soft_reset_halt
monitor arm7_9 force_hw_bkpts enable
symbol-file main.out
thbreak main
continue

Any guidance is appreciated. Thanks,

Karim
By karim
#19239
Just noting that I did see that the openocd reset script has a line:

flash write 0 main.bin 0x0

but there isn't any main.bin produced by the make. So I tried changing it to:

flash write 0 main.out 0x0

and the behavior remained the same. I've also tried manually running the above command (main.out version) through openocd via a telnet session, and it seems to write the file, but on reset there is no indication that the code is running correctly - no flashing led like when the same code runs from ram.

Thanks, Karim
By dumarjo
#19267
this line should be change to work on flash.

working_area 0 0x40000000 0x40000 nobackup // this is only for ram degug

working_area 0 0x00000000 0x400000 nobackup //Flash degug only

Dumarjo
By karim
#19291
Thanks Dumarjo.

I tried the change, but the behavior is still the same - the debug launch halts at 60%. Sometimes after cancelling I get a message saying it failed to set a breakpoint. But I can't tell what's really happening.

Does anyone have an ultra simple OpenOCD+Olimex-arm-usb-ocd+Lpc2000+Eclipse project they'd like to share for comparison purposes?
By Dominic
#19293
Hello Karim,

The fact that no main.bin is being generated is crucial - the OpenOCD expects a plain binary when you're using the "flash write" command. The main.out can't work as it's a ELF executable - you have to use objcopy (actually the arm-xxx-objcopy from your cross-toolchain) to convert the ELF to a plain binary:

arm-none-eabi-objcopy -O binary main.out main.bin

works for me (not sure what the name of your cross-objcopy is).

Regards,

Dominic
By karim
#19295
Thanks Dominic,

I added the objcopy command to the makefile and it produces a tiny main.bin. I edited the reset script to specify that file. But the debug launch is still halting in the same place.

Here's the debug console output up to where it stalls:
Code: Select all
(gdb) target remote localhost:3333
(gdb) monitor soft_reset_halt
monitor arm7_9 force_hw_bkpts enable
symbol-file main.out
thbreak main
requesting target halt and executing a soft reset
(gdb) force hardware breakpoints enabled
(gdb) (gdb) (gdb) 
Don't know if it's relevant, but when I kill the stalled launch:
Code: Select all
Info:    openocd.c:82 main(): Open On-Chip Debugger (2006-08-31 15:00 CEST)
Warning: arm7_9_common.c:679 arm7_9_assert_reset(): srst resets test logic, too
Warning: arm7_9_common.c:785 arm7_9_halt(): target was already halted
Info:    server.c:67 add_connection(): accepted 'gdb' connection from 0
Error:   arm7_9_common.c:1756 arm7_9_read_memory(): memory read caused data abort
Info:    server.c:367 server_loop(): dropped 'gdb' connection
And here's the build output:
Code: Select all
make clean all 
rm crt.lst main.lst crt.o main.o main.out main.hex main.map main.dmp
rm: cannot remove `main.lst': No such file or directory
make: [clean] Error 1 (ignored)
.assembling
arm-elf-as -ahls -mapcs-32 -o crt.o crt.s > crt.lst
.compiling
arm-elf-gcc -I./ -c -fno-common -O0 -g main.c
..linking
arm-elf-ld -v -Map main.map -Tdemo2106_blink_flash.cmd -o main.out  crt.o main.o
GNU ld version 2.17
...copying
arm-elf-objcopy -O binary main.out main.bin
arm-elf-objcopy -O ihex main.out main.hex
arm-elf-objdump -x --syms main.out > main.dmp