针对dra7xx_evm_qspiboot_config 解析uboot mkconfig

Uboot Makefile


%_config:: outputmakefile
     @$(MKCONFIG) -A $(@:_config=)
             /*%通配符 dra7xx_evm_qspiboot_config
                  ${VAR:_config=}:把Var中的尾部_config用空来替换变成dra7xx_evm_qspiboot
      mkconfig -A dra7xx_evm_qspiboot*/

uboot  mkconfig
    
            line=`awk '($0 !~ /^#/ && $7 ~ /^'"dra7xx_evm_qspiboot"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' boards.cfg`
            /*此个awk就是为了得到boards.cfg内含有dra7xx_evm_qspiboot的行的所有参数,中间用空格隔开
                Active arm armv7 omap5 ti dra7xx dra7xx_evm_qspiboot dra7xx_evm:CONS_INDEX=1,QSPI_BOO*/

   set ${line}
                            /*set Active arm armv7 omap5 ti dra7xx dra7xx_evm_qspiboot dra7xx_evm:CONS_INDEX=1,QSPI_BOO 八个参数*/
     # add default board name if needed
   [ $# = 3 ] && set ${line} ${1}
 fi
         /*$#=8,$1=Active  while 直接break跳出*/
 while [ $# -gt 0 ] ; do
     case "$1" in
     --) shift ; break ;;
     -a) shift ; APPEND=yes ;;
    -n) shift ; BOARD_NAME="${7%_config}" ; shift ;;
    -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
     *)  break ;;
     esac                                                                                                                                                                                                 
 done
    /*参数低于7大于8就退出*/
 [ $# -lt 7 ] && exit 1
 [ $# -gt 8 ] && exit 1
    /*$7 =dra7xx_evm_qspiboot CONFIG_NAME=dra7xx_evm_qspiboot*/
 CONFIG_NAME="${7%_config}"
 52
    /*如果BOARD_NAME已经设置了,就保留,如果没设置就BOARD_NAME=dra7xx_evm_qspiboot*/
 53 [ "${BOARD_NAME}" ] || BOARD_NAME="${7%_config}"
 54
    /*arch=arm*/
 55 arch="$2"
    /*如果有splcpu armv7:arm623el 此时无cpu=armv7*/        
 56 cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'`
    /*spl_cpu =空*/
 57 spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'`
 58
 59 if [ "$cpu" = "-" ] ; then
 60     cpu=
 61 fi
 62 /*board=dra7xx verdor=ti soc=omap5*/
 63 [ "$6" != "-" ] && board="$6"
 64 [ "$5" != "-" ] && vendor="$5"
 65 [ "$4" != "-" ] && soc="$4"
/*测试如果大于7或者$8!="-"全部满足,tmp="${8%:*}" 意味着tmp=dra7xx_evm CONFIG_NAME=dra7xx_evm
                                                                                                                                                                                                                        options=${8#*:}把:前面的去掉赋值给options=CONS_INDEX=1,QSPI_BOO
    echo ${options} | sed 's:,: :g' 把逗号去掉TARGETS=CONS_INDEX=1 QSPI_BOO*/
  [ $# -gt 7 ] && [ "$8" != "-" ] && {
      # check if we have a board config name in the options field
      # the options field mave have a board config name and a list
      # of options, both separated by a colon (':'); the options are
      # separated by commas (',').
      #
      # Check for board name
      tmp="${8%:*}"
      if [ "$tmp" ] ; then
          CONFIG_NAME="$tmp"
      fi
     # Check if we only have a colon...
      if [ "${tmp}" != "$8" ] ; then
          options=${8#*:}
          TARGETS="`echo ${options} | sed 's:,: :g'` ${TARGETS}"
     fi
 }
    /*判断ARCH存在,并且不等于arch条件不满足退出*/
if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then
    echo "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}" 1>&2
    exit 1
fi

#
# Test above needed aarch64, now we need arm
#
/*如果arch=aarch64 需要把arch=arm*/
if [ "${arch}" = "aarch64" ]; then
    arch="arm"
fi

if [ "$options" ] ; then
    echo "Configuring for ${BOARD_NAME} - Board: ${CONFIG_NAME}, Options: ${options}"
else
    echo "Configuring for ${BOARD_NAME} board..."
fi

#
# Create link to architecture specific headers
#
/*在makefile中我们已经知道SRCTREE和OBJTREE都是当前目录,所以这里执行else 进入include文件夹*/
if [ -n "$KBUILD_SRC" ] ; then
    mkdir -p ${objtree}/include
    LNPREFIX=${srctree}/arch/${arch}/include/asm/
    cd ${objtree}/include
    mkdir -p asm
else
        cd arch/${arch}/include
fi
/*删除asm下的arch目录*/
rm -f asm/arch
/*创建链接文件目录 ln -s arch-omap5 asm/arch ln -s arch-armv7 asm/arch */
if [ "${soc}" ] ; then
    ln -s ${LNPREFIX}arch-${soc} asm/arch
elif [ "${cpu}" ] ; then
    ln -s ${LNPREFIX}arch-${cpu} asm/arch
fi

if [ -z "$KBUILD_SRC" ] ; then
    cd ${srctree}/include
fi

#
# Create include file for Make
#
    /*  include/config.mk
                1 ARCH =arm                                                                                                                                                                                             
          2 CPU    = armv7
          3 BOARD  = dra7xx
          4 VENDOR = ti
          5 SOC    = omap5*/
( echo "ARCH   = ${arch}"
    if [ ! -z "$spl_cpu" ] ; then
    echo 'ifeq ($(CONFIG_SPL_BUILD),y)'
    echo "CPU    = ${spl_cpu}"
    echo "else"
    echo "CPU    = ${cpu}"
    echo "endif"
    else
    echo "CPU    = ${cpu}"
    fi
    echo "BOARD  = ${board}"

    [ "${vendor}" ] && echo "VENDOR = ${vendor}"
    [ "${soc}"    ] && echo "SOC    = ${soc}"
    exit 0 ) > config.mk

# Assign board directory to BOARDIR variable
if [ -z "${vendor}" ] ; then
    BOARDDIR=${board}
else
    BOARDDIR=${vendor}/${board}
fi
/*创建config.h
  2 #define CONFIG_CONS_INDEX   1
  3 #define CONFIG_QSPI_BOOT    1
  4 #define CONFIG_SYS_ARCH  "arm"
  5 #define CONFIG_SYS_CPU   "armv7"
  6 #define CONFIG_SYS_BOARD "dra7xx"
  7 #define CONFIG_SYS_VENDOR "ti"
  8 #define CONFIG_SYS_SOC    "omap5"
  9 #define CONFIG_BOARDDIR board/ti/dra7xx
 10 #include <config_cmd_defaults.h>
 11 #include <config_defaults.h>
 12 #include <configs/dra7xx_evm.h>
 13 #include <asm/config.h>
 14 #include <config_fallbacks.h>
 15 #include <config_uncmd_spl.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

for i in ${TARGETS} ; do
    i="`echo ${i} | sed '/=/ {s/=/    /;q; } ; { s/$/    1/; }'`"
    echo "#define CONFIG_${i}" >>config.h ;
done

echo "#define CONFIG_SYS_ARCH  \"${arch}\""  >> config.h
echo "#define CONFIG_SYS_CPU   \"${cpu}\""   >> config.h
echo "#define CONFIG_SYS_BOARD \"${board}\"" >> config.h

[ "${vendor}" ] && echo "#define CONFIG_SYS_VENDOR \"${vendor}\"" >> config.h

[ "${soc}"    ] && echo "#define CONFIG_SYS_SOC    \"${soc}\""    >> config.h

[ "${board}"  ] && echo "#define CONFIG_BOARDDIR board/$BOARDDIR" >> config.h
cat << EOF >> config.h
#include <config_cmd_defaults.h>
#include <config_defaults.h>
#include <configs/${CONFIG_NAME}.h>
#include <asm/config.h>
#include <config_fallbacks.h>
#include <config_uncmd_spl.h>
EOF

exit 0
/*mkconfig 脚本解析boards.cfg 创建头文件链接,config.mk config.h
      make xxx_config后,主要的变化是多了几个文件:
      1.include/asm    -->     arch/arm/include/arm
      2.include/asm/arch  -->  arch-omap5
      4.在include目录下新建了config.mk文件,文件内容是ARCH CPU BOARD VENDOR SOC的定义
      5.在include目录下新建了config.h文件*/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值