Posted on 2008-11-08 11:46
buf 阅读(3120)
评论(0) 编辑 收藏 引用 所属分类:
Embedded
在DULG 5.12节中standalone app都是通过loads和tftp下载的,这让我天真地误以为不能通过loadb下载。可是使用tftp下载examples \hello_world.bin到ram后,一运行就死机!尝试用在cu下用loads下载hello_world.srec也不行,真是郁闷。我想这可就奇怪了,调试u-boot也是把u-boot.bin使用loadb下载到ram然后go执行的呀?
猛然想起修改过examples\Makefile!因为arm-elf-gcc v2.95.3编译U-Boot v1.1.1会产生编译错误,对于u-boot/examples/Makefile中的这一段
1 #########################################################################
2 $(LIB): .depend $(LIBOBJS)
3 $(AR) crv $@ $(LIBOBJS)
4
5 %: %.o $(LIB)
6 $(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
7 -o $@ -e $(<:.o=) $< $(LIB) \
8 -L$(gcclibdir) -lgcc
9 %.srec: %
10 $(OBJCOPY) -O srec $< $@ 2>/dev/null
11
12 %.bin: %
13 $(OBJCOPY) -O binary $< $@ 2>/dev/null
14
15 #########################################################################
它不知道line9/12中一个光秃秃的'%'表示啥。为了消除这个编译错误,我把这两行中的'%'替换成'%.o',表示依赖于相应的obj文件。可是事实上,*.srec和*.bin都应该以line5指明的目标'%'(不清楚为啥arm-elf-gcc v2.95.3不抱怨这个)为源文件,使用arm-elf-objdump生成,这才是Makefile要表达的意思。
好吧,那我就写地清楚些,添加一个.elf目标。修改后的u-boot/examples/Makefile:
#
# (C) Copyright 2000
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
ifeq ($(ARCH),arm)
LOAD_ADDR = 0xc008000
endif
include $(TOPDIR)/config.mk
ELF = hello_world.elf
SREC = hello_world.srec
BIN = hello_world.bin
OBJS = $(SREC:.srec=.o)
LIB = libstubs.a
LIBAOBJS=
ifeq ($(ARCH),ppc)
LIBAOBJS+= $(ARCH)_longjmp.o $(ARCH)_setjmp.o
endif
LIBCOBJS= stubs.o
LIBOBJS = $(LIBAOBJS) $(LIBCOBJS)
gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
clibdir := $(shell dirname `$(CC) $(CFLAGS) -print-file-name=libc.a`)
CPPFLAGS += -I..
all: .depend $(LIB) $(ELF) $(SREC) $(BIN)
#########################################################################
$(LIB): .depend $(LIBOBJS)
$(AR) crv $@ $(LIBOBJS)
%.elf: %.o $(LIB)
$(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
-o $@ -e $(<:.o=) $< $(LIB) \
-L$(gcclibdir) -lgcc
%.srec: %.elf
$(OBJCOPY) -O srec $< $@ 2>/dev/null
%.bin: %.elf
$(OBJCOPY) -O binary $< $@ 2>/dev/null
#########################################################################
.depend: Makefile $(OBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
$(CC) -M $(CFLAGS) $(OBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S) > $@
sinclude .depend
#########################################################################
这下没问题了...
=>loadb 0x0c008000
## Ready for binary (kermit) download to 0x0C008000 at 115200 bps
(Back at localhost)
----------------------------------------------------
(/home/buf/dev/u-boot/u-boot-1.1.1/) C-Kermit>send examples/hello_world.bin(/home/buf/dev/u-boot/u-boot-1.1.1/) C-Kermit>c
Connecting to /dev/ttyS0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
## Total Size = 0x00000228 = 552 Bytes
## Start Addr = 0x0C008000
=>go 0x0c008000 this is a test
## Starting application at 0x0C008000
Example expects ABI version 2
Actual U-Boot ABI version 2
Hello World
argc = 5
argv[0] = "0x0c008000"
argv[1] = "this"
argv[2] = "is"
argv[3] = "a"
argv[4] = "test"
argv[5] = "<NULL>"
Hit any key to exit
## Application terminated, rc = 0x0