10.03.2007

openocd + arm-elf-insight

OpenOCD 可以配合 gdb 和圖形介面的 insight 使用。
一樣,由 YAGARTO 下載 arm 的toolchain,安裝。 (eclipse 的安裝也有,但是實際用起來好像沒那麼好用)。

ref HowTo
follow instruction,download一個example 下來當template改比較快。

修改makefile.. 其實只有改 target 和LDSCRIPT
#######################################################################
#
# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
#
####################################################################
#
# On command line:
#
# make all = Create project
#
# make clean = Clean project files.
#
# To rebuild project do "make clean" and "make all".
#

###############################################################
# Start of default section
#

TRGT = arm-elf-
CC = $(TRGT)gcc
CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
BIN = $(CP) -O ihex

MCU = arm920t

# List all default C defines here, like -D_DEBUG=1
DDEFS =

# List all default ASM defines here, like -D_DEBUG=1
DADEFS =

# List all default directories to look for include files here
DINCDIR =

# List the default directory to look for the libraries here
DLIBDIR =

# List all default libraries here
DLIBS =

#
# End of default section
############################################################################

#############################################################################
# Start of user section
#

# Define project name here
PROJECT = test

# Define linker script file here
LDSCRIPT= ./prj/ANS5000_ram.ld

# List all user C define here, like -D_DEBUG=1
UDEFS =

# Define ASM defines here
UADEFS =

# List C source files here
SRC = ./src/main.c

# List ASM source files here
ASRC = ./src/crt.s

# List all user directories here
UINCDIR = ./inc

# List the user directory to look for the libraries here
ULIBDIR =

# List all user libraries here
ULIBS =

# Define optimisation level here
OPT = -O0

#
# End of user defines
################################################################################


INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
DEFS = $(DDEFS) $(UDEFS)
ADEFS = $(DADEFS) $(UADEFS)
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)
LIBS = $(DLIBS) $(ULIBS)
MCFLAGS = -mcpu=$(MCU)

ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(<:.s=.lst) $(ADEFS) CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb-interwork -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS) LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) # Generate dependency information CPFLAGS += -MD -MP -MF .dep/$(@F).d # # makefile rules # all: $(OBJS) $(PROJECT).elf $(PROJECT).hex %o : %c $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ %o : %s $(AS) -c $(ASFLAGS) $< -o $@ %elf: $(OBJS) $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ %hex: %elf $(BIN) $< $@ clean: -rm -f $(OBJS) -rm -f $(PROJECT).elf -rm -f $(PROJECT).map -rm -f $(PROJECT).hex -rm -f $(SRC:.c=.c.bak) -rm -f $(SRC:.c=.lst) -rm -f $(ASRC:.s=.s.bak) -rm -f $(ASRC:.s=.lst) -rm -fR .dep # # Include the dependency files, should be the last of the makefile
# -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)

# *** EOF ***
然後就是 loading script : ANS5000_ram.ld

就是改 ram 的start address:因為用stepingstone 用的nternal ram,所以起始是0, size只有4k
MEMORY
{
ram : org = 0x0000000, len = 4k
}


然後就是給gdb用的command file : ANS5000_ram.gdb,因為我們的jtag board沒有lay nTRST,所以reset command無效。所以是
target remote localhost:3333
monitor sleep 500
monitor poll
monitor soft_reset_halt
monitor arm7_9 sw_bkpts enable
break main
load
continue
這樣作好後,就可以開啟cmd,下make,把program build 好 (build成test.elf)。
然後 將 openocd啟動起來 (ref 上一篇)。

再follow 上面的 Howto,用修改的cmd file 啟動insight (gdb):
C:\UseYagarto>arm-elf-insight -x .\prj\ANS5000_ram.gdb test.elf
然後就看到

以上都是在windows下做的,因為上次看code發現我們的jtag board layout 和內建的 chameleon 一樣,所以可以用 YAGARTO 的windows binary,只是將config 改為
#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface parport
parport_port 0x378
parport_cable chameleon
jtag_speed 8

#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 attach
#target
target arm920t little reset_run 0 arm920t
#working_area 0 0x200000 0x4000 backup
run_and_halt_time 0 5000
就可以

沒有留言: