看uboot说明知道,uboot编译需要
(1)先配置 make 。。。
(2)make。
一:配置过程 make 100ask24x0
(1)解压打号补丁的u-boot-1.1.6,打开makefile。
(2)make 100ask24x0_config相当于执行:
a.首先执行make uconfig,删除相关配置文件。
b.@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0
MKCONFIG:= $(SRCTREE)/mkconfig(根目录下有个mkconfig脚本文件)
$(@:_config=) = 100ask24x0
make 100ask24x0_config相当于执行:
mkconfig 100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0
$0 $1 $2 $3 $4 $5 $6
观察脚本文件mkconfig :
APPEND=no # Default: Create new config file
BOARD_NAME="" # Name to print in make output
while [ $# -gt 0 ] ; do (YF:检测命令中是否带有如下 -- -a等参数,没有忽略)
case "$1" in
--) shift ; break ;;
-a) shift ; APPEND=yes ;;
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
*) break ;;
esac
done
[ "${BOARD_NAME}" ] || BOARD_NAME="$1"(YF:BOARD_NAME没有定义则等于$1)
[ $# -lt 4 ] && exit 1(YF:判断参数的个数,小于4 退出)
[ $# -gt 6 ] && exit 1
echo "Configuring for ${BOARD_NAME} board..."(YF:打印信息)
#
# Create link to architecture specific headers
#
if [ "$SRCTREE" != "$OBJTREE" ] ; then(YF:等于)
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(YF:执行此)
cd ./include
rm -f asm
ln -s asm-$2 asm (YF:建立连接文件指向asm-arm,方便后续头文件使用asm)
fi
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(YF:执行此处,建立连接文件)
fi
if [ "$2" = "arm" ] ; then
rm -f asm-$2/proc
ln -s ${LNPREFIX}proc-armv asm-$2/proc(YF:执行此,建立一个连接文件)
fi
#
# Create include file for Make
#
echo "ARCH = $2" > config.mk(YF:>创建文件 写入内容)
echo "CPU = $3" >> config.mk(YF:》追加)
echo "BOARD = $4" >> config.mk
[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk(YF:不执行)
[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk(YF:追加)
#
# Create board specific header file(YF:创建单板相关的头文件)
#
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
exit 0
最后目的:
为make做准备,建立一些连接文件,方便后面使用,并在include目录中产生如下两个文件。
(1)config.mk
ARCH = arm
CPU = arm920t
BOARD = 100ask24x0
SOC = s3c24x0
(2)config.h(相关头文件被包含,需要自己创建此文件100ask24x0.h)
/* Automatically generated - do not edit */
#include <configs/100ask24x0.h>
二:make过程分析
makefile包含config.mk。将第一步配置产生的参数传入进来。
# load ARCH, BOARD, and CPU configuration
include $(OBJTREE)/include/config.mk
export ARCH CPU BOARD VENDOR SOC
各种准备文件:
OBJS = cpu/$(CPU)/start.o
LIBS = lib_generic/libgeneric.a
LIBS += board/$(BOARDDIR)/lib$(BOARD).a
LIBS += cpu/$(CPU)/lib$(CPU).a
最后生成uboot.bin