原创 U-Boot 分析与移植

2009-2-12 11:25 2195 6 6 分类: MCU/ 嵌入式

1、先了解“smdk2410_config”、“make all”做了些什么,医疗界程序的流程,知道要修改哪些文件。


2、U-Boot的配置过程


SRCTREE  := $(CURDIR)


MKCONFIG := $(SRCTREE)/mkconfig


smdk2410_config : unconfig
 @$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0


=>


。/mkconfig smdk2410 arm arm920t smdk2410 NULL s3c24x0


再看看mkconfig的作用


# Parameters:  Target  Architecture  CPU  Board [VENDOR] [SOC]


(1)确定开发板名称BOARD_NAME:


APPEND=no # Default: Create new config file
BOARD_NAME="" # Name to print in make output


[ "${BOARD_NAME}" ] || BOARD_NAME="$1"


(2)创建到平台/开发板相关的头文件的链接


#
# Create link to architecture specific headers
#
if [ "$SRCTREE" != "$OBJTREE" ] ; then
 mkdir -p ${OBJTREE}/include
 mkdir -p ${OBJTREE}/include2
 cd ${OBJTREE}/include2
 rm -f asm
 ln -s ${SRCTREE}/include/asm-$2 asm
 LNPREFIX="../../include2/asm/"
 cd ../include
 rm -rf asm-$2
 rm -f asm
 mkdir asm-$2
 ln -s asm-$2 asm
else
 cd ./include
 rm -f asm
 ln -s asm-$2 asm
fi


建立asm文件链接向asm-arm


rm -f asm-$2/arch


if [ -z "$6" -o "$6" = "NULL" ] ; then
 ln -s ${LNPREFIX}arch-$3 asm-$2/arch
else
 ln -s ${LNPREFIX}arch-$6 asm-$2/arch
fi


if [ "$2" = "arm" ] ; then
 rm -f asm-$2/proc
 ln -s ${LNPREFIX}proc-armv asm-$2/proc
fi
删除asm-arm/arch


“ln -s arch-s3c24x0 asm-arm/arch”


重新建立asm-arm/proc文件,并链接向proc-armv目录


(3)Create include file for Make
#
# Create include file for Make
#
echo "ARCH   = $2" >  config.mk
echo "CPU    = $3" >> config.mk
echo "BOARD  = $4" >> config.mk


[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk


[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC    = $6" >> config.mk


config.mk内容:


ARCH = arm


CPU = arm920t


BOARD = smdk2410


SOC = s3c24x0


(4) Create board specific header file


if [ "$APPEND" = "yes" ] # Append to existing config file
then
 echo >> config.h
else
 > config.h  # Create new config file
fi
echo "/* Automatically generated - do not edit */" >>config.h
echo "#include <configs/$1.h>" >>config.h


 配置文件中有两类宏:


1、选项:“CONFIG_*”,选择CPU、SOC、开发板类型、设置系统时钟、选择设备驱动:


#define CONFIG_ARM920T  1 /* This is an ARM920T Core */
#define CONFIG_S3C2410  1 /* in a SAMSUNG S3C2410 SoC     */
#define CONFIG_SMDK2410  1 /* on a SAMSUNG SMDK2410 Board  */


/* input clock of PLL */
#define CONFIG_SYS_CLK_FREQ 12000000/* the SMDK2410 has 12MHz input clock */



#define USE_920T_MMU  1
#undef CONFIG_USE_IRQ   /* we don't need IRQ/FIQ stuff */


/*
 * Size of malloc() pool
 */
#define CFG_MALLOC_LEN  (CFG_ENV_SIZE + 128*1024)
#define CFG_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */
(2)“CFG_*”设置malloc缓冲池的大小、U-Boot的提示符、U-Boot下载文件时的默认下载地址、Flash的起始地址:


#define CFG_MALLOC_LEN  (CFG_ENV_SIZE + 128*1024)
#define CFG_PROMPT  "SMDK2410 # " /* Monitor Command Prompt */


#define CFG_LOAD_ADDR  0x33000000 /* default load address */
#define CFG_FLASH_BASE  PHYS_FLASH_1


3、U-Boot的编译、链接过程


include $(OBJTREE)/include/config.mk
export ARCH CPU BOARD VENDOR SOC


//定义ARCH、CPU、BOARD、SOC等
……


ifeq ($(ARCH),arm)
CROSS_COMPILE = arm-linux-
endif


……


# load other configuration
include $(TOPDIR)/config.mk


//根据定义ARCH、CPU、BOARD、SOC确定编译器、编译选项等。


BOARDDIR = $(BOARD)
……


sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules
……


LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
……


LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)


Makefile:


#########################################################################
# U-Boot objects....order is important (i.e. start must be first)


OBJS  = cpu/$(CPU)/start.o                        即cpu/arm920t/start.o
……


LIBS  = lib_generic/libgeneric.a
LIBS += board/$(BOARDDIR)/lib$(BOARD).a
LIBS += cpu/$(CPU)/lib$(CPU).a


……


LIBS += lib_$(ARCH)/lib$(ARCH).a
LIBS += fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a \
 fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a
LIBS += net/libnet.a
LIBS += disk/libdisk.a
LIBS += rtc/librtc.a
LIBS += dtt/libdtt.a
LIBS += drivers/libdrivers.a
LIBS += drivers/nand/libnand.a
LIBS += drivers/nand_legacy/libnand_legacy.a
LIBS += drivers/sk98lin/libsk98lin.a
LIBS += post/libpost.a post/cpu/libcpu.a
LIBS += common/libcommon.a
LIBS += $(BOARDLIBS)


//


$(OBJS):
  $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))


$(LIBS):
  $(MAKE) -C $(dir $(subst $(obj),,$@))


$(SUBDIRS):
  $(MAKE) -C $@ all


网卡移植:


/*
 * Hardware drivers
 */
//#define CONFIG_DRIVER_CS8900    1    /* we have a CS8900 on-board */
//#define CS8900_BASE        0x19000300
//#define CS8900_BUS16   1 /* the Linux driver does accesses as shorts */

#define CONFIG_DRIVER_DM9000  1
#define CONFIG_DM9000_BASE  0x28000300
#define DM9000_IO   CONFIG_DM9000_BASE
#define DM9000_DATA   (CONFIG_DM9000_BASE+4)
#define CONFIG_DM9000_USE_16BIT


在这里#define CONFIG_DM9000_BASE 的定义最为重要。不同的板子只要修改这个参数即可。优龙的YL-P2440上的DM9000AE在BANK5上所以定义为“0x20000300”。有的板子是在BANK1上,就为“0x08000300”。

文章评论0条评论)

登录后参与讨论
我要评论
0
6
关闭 站长推荐上一条 /2 下一条