|
My 30-day Crossworks for ARM demo expired. I decided that I would try to get Eclipse/yagarto/OpenOCD working. I figured if it was useable then I'd save $150 and use it. If not I can always send Rowley their $150 and use Crossworks for ARM, which is VERY nice BTW.
NOTE: Everything in this article is based on my present setup: Olimex LPC-P2148 board. Olimex ARM-USB-TINY JTAG programmer/debugger. Windows XP. None of the following info is guaranteed to be correct, or even the proper way to do things, but it's working for me at present. I'll improve on it as I go.
I installed Eclipse/yagarto/OpenOCD from the Olimex CD that came with my LPC-P2148 board. When it was installed it was useless. Wouldn't do nothin. I spent days Googling and gradually things started to come together as I got configuration details figured out and built proper makefiles. I could compile again at last! But the thing wouldn't debug or flash the LPC2148. I was writing code and compiling in Eclipse and using Flash Magic to flash the chip. That's clumsy and annoying, and I still wanted to have a debugger. Makes getting things working right much easier. Once again I Googled hard for days and tried myriads of different OpenOCD and GDB init files. I found that OpenOCD is, and has been, in active development for a while and is a moving target. I would say that 99% of the OpenOCD info you find with Google is badly out of date and useless. You can't trust any init file you get from the web. None of the GDB init files I found were any good to me either, except as an example to tear apart and rebuild almost completely differently. I replaced the supplied OpenOCD r204 with r717 and spent a bunch of time testing it in a cmd console while going through the documentation. Got comfortable with it and then started building OpenOCD and GDB scripts for Eclipse. This gets slightly more confusing. Once you're in GDB you use GDB commands and to talk to OpenOCD you preface those commands with "monitor ". Spent a few more hours doing trial and error till I had something that works pretty well for now. It flashes the chip and sets a breakpoint at main(), where it halts and waits for you to do whatever you want to do in the debugger. Debugging works pretty well so far. It's not pushbutton-simple, like Crossworks, but everything you need is there and is quite useable. To start the debugger in Eclipse you have to follow a certain sequence. It's a bit finicky. Start in the C/C++ perspective. Click on your project title even if it's already selected. I don't know why, but if you don't do this then OpenOCD won't start sometimes. Then click on OpenOCD Tiny. When that is running, switch to the Debug perspective. Click on the Debug icon. Both of these icons (OpenOCD and Debug) have to be set up before you use them. Use the dropdown lists on the right side of the icons to access that.
The following is a typical makefile that I use. When I make a new project I just copy it to the new project dir and use find/replace to replace all the sirc's with the name of my new project. NOTE: If you downloaded the makefile that was here earlier, dump it. It won't work properly with standard C libs. I'm now using this one: NAME = sirc
CC = arm-elf-gcc LD = arm-elf-ld AR = arm-elf-ar AS = arm-elf-as CP = arm-elf-objcopy OD = arm-elf-objdump
CFLAGS = -mcpu=arm7tdmi -Ic:/gccfd/yagarto/arm-elf/include -c -fno-common -O0 -g AFLAGS = -ahls -mapcs-32 -o crt.o LFLAGS= -mcpu=arm7tdmi -Wl,-Map,sirc.map,-T2138_demo.cmd -nostdlib LINK_LIBS= -lc -lm -lg -lgcc CPFLAGS = -O binary HEXFLAGS = -O ihex ODFLAGS = -x --syms
all: test
clean: -rm crt.lst crt.o sirc.o sirc.out sirc.map sirc.dmp sirc.bin VIClowlevel.o
test: sirc.out $(CP) $(CPFLAGS) sirc.out sirc.bin $(OD) $(ODFLAGS) sirc.out > sirc.dmp $(CP) $(HEXFLAGS) sirc.out sirc.hex
sirc.out: crt.o VIClowlevel.o sirc.o 2138_demo.cmd $(CC) $(LFLAGS) -o sirc.out crt.o VIClowlevel.o sirc.o $(LINK_LIBS)
crt.o: crt.s $(AS) $(AFLAGS) crt.s > crt.lst
VIClowlevel.o: VIClowlevel.c $(CC) $(CFLAGS) VIClowlevel.c
sirc.o: sirc.c $(CC) $(CFLAGS) sirc.c Here's my OpenOCD init file for the LPC-P2148 and ARM-USB-TINY. This is for OpenOCD version r717. If you try to use it with earlier versions it almost certainly will not work:#daemon configuration telnet_port 4444 gdb_port 3333
#interface interface ft2232 ft2232_device_desc "Olimex OpenOCD JTAG TINY A" ft2232_layout "olimex-jtag" ft2232_vid_pid 0x15BA 0x0004 jtag_speed 3
#use combined on interfaces or targets that can't set TRST/SRST separately reset_config trst_and_srst separate
#jtag scan chain jtag_device 4 0x1 0xf 0xe
#target configuration daemon_startup reset
target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4 run_and_halt_time 0 30
target_script 0 reset oocd_flash_lpc2148.script working_area 0 0x40000000 0x4000 nobackup
flash bank lpc2000 0x0 0x80000 0 0 0 lpc2000_v2 12000 calc_checksum
And here is my GDB init script. This one flashes the chip, sets a breakpoint at main() and halts at it. There is probably a way to automate it so I don't have to edit the filename in each project, but for now it works fine and doesn't bug me too much. target remote localhost:3333 monitor arm7_9 force_hw_bkpts enable monitor reset #set MEMMAP to User Flash Mode monitor mww 0xE01FC040 0x0001 monitor flash write_image erase c:/gccfd/projects/sirc/sirc.bin break main monitor soft_reset_halt continue
|