1、u-boot编译脚本:mk.sh

#! /bin/sh
export PATH=$PATH:/opt/ti-sdk-am335x-evm-08.00.00.00/linux-devkit/sysroots/i686-arago-linux/usr/bin/
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf- make clean
make am335x_evm_config
make

make am335x_evm_config:配置所需要的硬件平台和模块。

make:根据make am335x_evm_config得到的配置项(CONFIG_XXX)来决定编译哪些源码。

2、make am335x_evm_config 命令

在Makefile中:


MKCONFIG := $(srctree)/mkconfig

%_config:: outputmakefile # %通配符,相当于xxx_config:: outputmakefile
@$(MKCONFIG) -A $(@:_config=) # :_config=,用=符号后的’’(空字符)替换”_config”
# $@目标集,$(@:_config=) 就是am335x_evm

相当于:

am335x_evm_config:: outputmakefile
@mkconfig -A am335x_evm

3、顶层目录mkconfig:

#!/bin/sh –e     # set –e 判断每条指令的返回值(#?)是否为0,非0自动退出

# Script to create header files and links to configure
# U-Boot for a specific board.
#
# Parameters: Target Architecture CPU Board [VENDOR] [SOC]
#
# (C) 2002-2013 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
#
# SPDX-License-Identifier: GPL-2.0+
# APPEND=no # Default: Create new config file
BOARD_NAME="" # Name to print in make output
TARGETS="" arch=""
cpu=""
board=""
vendor=""
soc=""
options="" if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then # 参数个数为2且第一个参数是”-A”
# Automatic mode
# 在顶层boards.cfg中找到匹配“am335x_evm”的行,存在line变量。
line=`awk '($0 !~ /^#/ && $7 ~ /^'"$2"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' $srctree/boards.cfg`
if [ -z "$line" ] ; then
echo "make: *** No rule to make target \`$2_config'. Stop." >&2
exit 1
fi set ${line} # 把line成员设置为参数$1, $2, $3, $4…
# add default board name if needed
[ $# = 3 ] && set ${line} ${1}
fi
# 结果:line= Active arm armv7 am33xx ti am335x am335x_evm am335x_evm:SERIAL1,CONS_INDEX=1,NAND 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 # Strip all options and/or _config suffixes
CONFIG_NAME="${7%_config}" # 去掉$7的“_config” CONFIG_NAME= am335x_evm [ "${BOARD_NAME}" ] || BOARD_NAME="${7%_config}" # BOARD_NAME= am335x_evm arch="$2" # arch=arm
cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'` # cpu= armv7
spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'` # spl_cpu= if [ "$cpu" = "-" ] ; then
cpu=
fi [ "$6" != "-" ] && board="$6" # board= am335x
[ "$5" != "-" ] && vendor="$5" # vendor=ti
[ "$4" != "-" ] && soc="$4" # soc=am33xx
[ $# -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" # CONFIG_NAME= am335x_evm
fi
# Check if we only have a colon...
if [ "${tmp}" != "$8" ] ; then
options=${8#*:} # options= SERIAL1,CONS_INDEX=1,NAND
TARGETS="`echo ${options} | sed 's:,: :g'` ${TARGETS}" # TARGETS= SERIAL1 CONS_INDEX=1 NAND
fi
} 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
#
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
#
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 # cd arch/arm/include
fi rm -f asm/arch # 删除arch/arm/include下的asm/arch if [ "${soc}" ] ; then
ln -s ${LNPREFIX}arch-${soc} asm/arch # 创建软连接arch -> arch-am33xx
elif [ "${cpu}" ] ; then
ln -s ${LNPREFIX}arch-${cpu} asm/arch
fi if [ -z "$KBUILD_SRC" ] ; then # 判断$KBUILD_SRC是否为空,为空返回真
cd ${srctree}/include # cd include
fi #
# Create include file for Make
#
( echo "ARCH = ${arch}" # ARCH = arm
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}" # CPU = armv7
fi
echo "BOARD = ${board}" # BOARD = am33xx [ "${vendor}" ] && echo "VENDOR = ${vendor}" # VENDOR = ti
[ "${soc}" ] && echo "SOC = ${soc}" # SOC = am33xx
exit 0 ) > config.mk # 创建config.mk # Assign board directory to BOARDIR variable
if [ -z "${vendor}" ] ; then
BOARDDIR=${board}
else
BOARDDIR=${vendor}/${board} # BOARDDIR=ti/am33xx
fi #
# 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 # 往include/config.h 文件中写入配置参数等
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

4、总结

mkconfig做了些什么:

1)       从顶层目录boards.cfg文件中根据make am335x_evm_config中的am335x_evm找到对应单板的属性参数;

2)       创建对应CPU架构的头文件软连接arch/arm/include/asm/arch -> arch/arm/include/asm/arch-am33xx;

3)       创建Makefile的包含文件include/config.mk,并将单板属性参数写进去;

4)       创建对应单板的特征的头文件include/config.h,并将单板属性参数宏定义和必须头文件写进去。

最新文章

  1. 【学习笔记】load-on-startup Servlet
  2. JAVA 中文转GBK内码方法
  3. 【Java每日一题】20161027
  4. perl操作sybase
  5. onSaveInstanceState() 和 onRestoreInstanceState()
  6. 江湖救急:webbrowser中js文件丢失问题~
  7. C++的CreateThread实例
  8. CUBRID学习笔记 14 删除主键错误
  9. ABAP OO与ALV结合方式探索(1)
  10. win7(x64)+VS2012+cocos2d-x环境的配置以及试运行
  11. Android Task 相关
  12. 【用PS3手柄在安卓设备上玩游戏系列】连接手柄和设备
  13. 分享QQ第三方登陆SDK
  14. Android画一个随意拖动的圆形
  15. windows下安装tern for vim
  16. CSS3 六边形绘制
  17. Spring MVC注解式开发
  18. WEB部分题目writeup
  19. 【公众号系列】SAP将裁员4400人,颤抖吧!
  20. 打造SharePoint之在线开发神器SPOnlineDevelopTool(一)——概述

热门文章

  1. 使用LoadRunner的Web(HTTP/HTML)协议录制手机app脚本
  2. Linux升级python至3.4.4
  3. sql server中使用xp_cmdshell
  4. 查看Oracle相关日志 ADRCI
  5. linux怎样使用top命令查看系统状态
  6. Linux系统——源码编译安装
  7. Jquery each循环用法小结
  8. Mybatis中的#与$的区别
  9. Dom与Bom,增删改查
  10. ACM-ICPC 2018 焦作赛区网络预赛 E. Jiu Yuan Wants to Eat (树链剖分-线性变换线段树)