[1]real210 uboot_Makefile配置详解

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: [1]real210 uboot_Makefile配置详解

时间有限,我把real210的uboot这块的分开来写了,今天先来分析下makefile中有关real210的配置过程.

uboot流程分析

我们编译的时候,输入了如下的命令:

make smdkv210single_config
make

按照上面的命令,我们从Makefile来分析:

1:首先看Makefile
我们在Makefile找到我们配置的那项,如下所示:

2572 smdkv210single_config : unconfig
2573 @$(MKCONFIG) $(@:_config=) arm s5pc11x smdkc110 samsung s5pc110
2574 @echo "TEXT_BASE = 0xc3e00000" > $(obj)board/samsung/smdkc110/config.mk

[讲解]
在Makefile中我们可以看到MKCONFIG定义:

101 MKCONFIG := $(SRCTREE)/mkconfig
102 export MKCONFIG
103

$(SRCTREE)指的就是当前代码目录,所以,我们便知道MKCONFIG调用的是代码根目录下的mkconfig这个文件
$(@:_config=)就是smdkv210single_config中的_config去掉变成smdkv210single
最后
@$(MKCONFIG) $(@:_config=) arm s5pc11x smdkc110 samsung s5pc110
翻译后如下:

mkconfig smdkv210single arm s5pc11x smdkc110 samsung s5pc110

$0 = mkconfig
$1 = smdkv210single
$2 = arm
$3 = s5pc11x
$4 = smdkc110
$5 = samsung
$6 = s5pc110

2:查看mkconfig

[讲解]$#为shell中的一个特殊变量,代表传入参数的个数,-gt是大于的意思,该行的意思是"当传入参数个数大于0时"进入循环
case "$1" in接着下面的几行意思表示,判断第一个参数中是否有-- -a -n参数,我们传入的参数都没有这些,所以他们根本没机会执行到

while [ $# -gt 0 ] ; do
case "$1" in
--) shift ; break ;;
-a) shift ; APPEND=yes ;;
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
*) break ;;
esac
done

[讲解]BOARD_NAME 是第一个参数:smdkv210single
[ "${BOARD_NAME}" ] || BOARD_NAME="$1"

[讲解]判断参数个数如果小于4个或者大于6个,那就exit了,我们参数正好6个,所以ok
[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1

[讲解]所以,在输入make smdkv210single_config的时候,会有下面一行打印出来
echo "Configuring for ${BOARD_NAME} board..."

[讲解]判断"$SRCTREE" != "$OBJTREE"是否成立,显然不成立(参考顶层Makefile),所以略过,直接进入else
在else里进入当前目录下的include目录,然后删除上次build的asm文件夹,再次建立新的asm文件夹,指向:asm-$2,$2即arm,也就是指向asm-arm目录.
#
# 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-arm/arch链接
rm -f asm-$2/arch

[详解]如果$6参数字符串长度为0或者为NULL,那么条件成立,但是实际上条件不成立,$6=s5pc110,所以生成一个链接文件asm-arm/arch--->arch-s5pc110
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

[详解]判断$3参数,我们$3=s5pc11x,所以直接找到s5pc11x这个地方
# create link for s3c24xx SoC
if [ "$3" = "s3c24xx" ] ; then
rm -f regs.h
ln -s $6.h regs.h
rm -f asm-$2/arch
ln -s arch-$3 asm-$2/arch
fi

# create link for s3c64xx SoC
if [ "$3" = "s3c64xx" ] ; then
rm -f regs.h
ln -s $6.h regs.h
rm -f asm-$2/arch
ln -s arch-$3 asm-$2/arch
fi

# create link for s5pc1xx SoC
if [ "$3" = "s5pc1xx" ] ; then
rm -f regs.h
ln -s $6.h regs.h
rm -f asm-$2/arch
ln -s arch-$3 asm-$2/arch
fi

[详解]ok,我们来到这个地方,在这里面,我们执行了删除regs.h,重新建立regs.h-->s5pc110.h
删除asm-arm/arch链接,建立asm-arm/arch--->arch-s5pc11x
# create link for s5pc11x SoC
if [ "$3" = "s5pc11x" ] ; then
rm -f regs.h
ln -s $6.h regs.h
rm -f asm-$2/arch
ln -s arch-$3 asm-$2/arch
fi

# create link for s5p64xx SoC
if [ "$3" = "s5p64xx" ] ; then
rm -f regs.h
ln -s $6.h regs.h
rm -f asm-$2/arch
ln -s arch-$3 asm-$2/arch
fi

# create link for s5p644x SoC
if [ "$3" = "s5p644x" ] ; then
rm -f regs.h
ln -s $6.h regs.h
rm -f asm-$2/arch
ln -s arch-$3 asm-$2/arch
fi

[详解]$2=arm,删除链接asm-arm/proc,重新建立asm-arm/proc --> proc-armv
if [ "$2" = "arm" ] ; then
rm -f asm-$2/proc
ln -s ${LNPREFIX}proc-armv asm-$2/proc
fi

# create link for s3c64xx-mp SoC
if [ "$3" = "s3c64xx-mp" ] ; then
rm -f regs.h
ln -s $6.h regs.h
rm -f asm-$2/arch
ln -s arch-$3 asm-$2/arch
fi

[详解]在当前目录下,config.mk文件里显示如下:arch,cpu,board信息.
ARCH = arm
CPU = s5pc11x
BOARD = smdkc110
VENDOR = samsung
SOC = s5pc110

#
# 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
[详解]include文件夹创建开发板头文件config.h,内容#include <configs/smdkv210single.h>
#
# 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

exit 0

至此,配置结束

3:总结下配置uboot的过程
(1)创建到目标板相关的文件的链接
ln -s asm-arm asm
ln -s arch-s5pc11x asm-arm/arch
ln -s proc-armv asm-arm/proc

(2)创建include/config.mk文件,内容如下所示:
ARCH = arm
CPU = s5pc11x
BOARD = smdkc110
VENDOR = samsung
SOC = s5pc110

(3)创建与目标板相关的文件include/config.h,如下所示:
/* Automatically generated - do not edit */
#include <configs/smdkv210single.h>

下一步就是执行Make了,有时间我再更新过来.下文地址:http://www.jyguagua.com/?p=1082

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: [1]real210 uboot_Makefile配置详解

文章的脚注信息由WordPress的wp-posturl插件自动生成



|2|left
打赏

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: