uboot之---make smdk2410_config命令详细解析

先进入顶层Makefile。有很多相对不同板子的配置,如:

gec2440_config:unconfig

  @$(MKCONFIG) $(@:_config=) arm arm920t gec2440 samsung s3c24x0

 

1.配置编译uboot第一步都是make *****_config。既然是make就得执行Makefile。makefile就包括很多上面的语句,make *****_config,首先执行的就是上面的配置信息。 @$(MKCONFIG)啥意思,其实在Makefile前面就有定义 @$(MKCONFIG) := $(SRCTREE)/mkconfig,也就是根目录的mkconfig文件。$(@:_config=)的意思就是吧make *****_config的_config给去到。所以gec2440_config执行./mkconfig  gec2440  arm arm920t gec2440 samsung s3c24x0。而unconfig的作用在于去除原先的配置信息,即make ***_config与make unconfig互逆关系。

 

2.OK,现在执行make gec2440_config,那么就会出现:

   Configuring for gec2440 board...

     现在看看有发生那些变化。由于上面的命令相当于执行./mkconfig  arm arm920t gec2440 samsung s3c24x0。所以先进去根目录的mkconfig文件看看。

首先,要明确一点:./mkconfig  gec2440  arm arm920t gec2440 samsung s3c24x0使得$0=./mkconfig,$1=arm,$2=arm920t,$3=gec2440, $4=samsung, $5=s3c24x0

下面是mkconfig的内容:


APPEND=no # 这里记得APPEND初值为no
BOARD_NAME=""
TARGETS=""

#下面一段代码不执行(while---done),由于./mkconfig  arm arm920t gec2440 samsung s3c24x0没有--、-a、-n、-t

while [ $# -gt 0 ] ; do
case "$1" in
--) shift ; break ;;
-a) shift ; APPEND=yes ;;
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
-t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
*)  break ;;
esac
done

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


[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1


if [ "${ARCH}" -a "${ARCH}" != "$2" ]; then
echo "Failed: \$ARCH=${ARCH}, should be '$2' for ${BOARD_NAME}" 1>&2
exit 1
fi


//在终端打印Config  for gec2440  board....
echo "Configuring for ${BOARD_NAME} board..."


#
# 产生链接文件
#
if [ "$SRCTREE" != "$OBJTREE" ] ; then   //是否在源代码目录下编译Uboot,不是就执行下面,else就是表示是在源代码目录编译
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    //进入include
rm -f asm
ln -s asm-$2 asm    //ln -s  include/asm-arm   asm
fi


rm -f asm-$2/arch            //删除include/asm-arm/arch


if [ -z "$6" -o "$6" = "NULL" ] ; then   //由于$6=s3c24x0,执行而else下面
ln -s ${LNPREFIX}arch-$3 asm-$2/arch   
else
ln -s ${LNPREFIX}arch-$6 asm-$2/arch  //ln -s include/arch-s3c24x0  include/asm-arm/arch
fi


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


#
# Create include file for Make
#
echo "ARCH   = $2" >  config.mk   //ARCH=arm,放入include/config.mk
echo "CPU    = $3" >> config.mk  //CPU=arm920t,放入includde/config.mk
echo "BOARD  = $4" >> config.mk //BOARD=gec2440,放入include/config.mk


[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
//VERDOR=samaung,放入include/config.mk
[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC    = $6" >> config.mk
//SOC=s3c24x0,放入include/config.mk
#
# Create board specific header file
#
if [ "$APPEND" = "yes" ] # 有第一行知道,APPEND=no
then
echo >> config.h
else
> config.h  #产生config.h文件,位于include目录下
echo "/* Automatically generated - do not edit */" >>config.h


for i in ${TARGETS} ; do
echo "#define CONFIG_MK_${i} 1" >>config.h ;
//将"#define CONFIG_MK_${i} 1加入上面产生的config.h文件
done


echo "#include <configs/$1.h>" >>config.h  //config.h文件包含头文件"#include <configs/gec2440.h>
echo "#include <asm/config.h>" >>config.h //config.h文件包含头文件"#include <asm/config.h>

exit 0

 

3.上面红色部分就是改变部分。到现实中的源代码看看,

大家执行完make gec2440_config之后,到源代码看看。

第一就是ARCH、CPU、BOARD、VERDOR、SOC被赋值,

并加入include/config.mk文件中,

我的config.mk文件内容如下:

ARCH   = arm
  CPU    = arm920t
  BOARD  = gec2440
  VENDOR = samsung
  SOC    = s3c24x0

第二就是看一下链接文件,我的情况如下:

进入include目录下:

#ll

lrwxrwxrwx  1 root root      7 04-01 21:36 asm -> asm-arm

进入include/asm-arm目录下:

lrwxrwxrwx 1 root root     12 04-01 21:36 arch -> arch-s3c24x0

............

lrwxrwxrwx 1 root root      9 04-01 21:36 proc -> proc-armv

第三就是在include目录下产生新文件:config.h.里面包含几个头文件,我的是:   /* Automatically generated - do not edit */
  #include <configs/gec2440.h>
  #include <asm/config.h>           

posted @ 2016-11-07 16:30  ZYVV  阅读(555)  评论(0编辑  收藏  举报