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,并将单板属性参数宏定义和必须头文件写进去。

u-boot-2015.07 make xxx_config 分析的更多相关文章

  1. Myeclipse 2015 stable 1.0 完美破解方法(转自 http://yangl.net/2015/07/14/myeclipse_2015stable_1/)

    Myeclipse 2015 stable 1.0 完美破解方法 http://yangl.net/2015/07/14/myeclipse_2015stable_1/ 破解包(注册机)下载地址:链接 ...

  2. spring boot 2.0 源码分析(一)

    在学习spring boot 2.0源码之前,我们先利用spring initializr快速地创建一个基本的简单的示例: 1.先从创建示例中的main函数开始读起: package com.exam ...

  3. spring boot 2.0 源码分析(四)

    在上一章的源码分析里,我们知道了spring boot 2.0中的环境是如何区分普通环境和web环境的,以及如何准备运行时环境和应用上下文的,今天我们继续分析一下run函数接下来又做了那些事情.先把r ...

  4. Murano Weekly Meeting 2015.07.21

    会议时间: 2015.07.21 主持人: Kirill Zaitsev, core from Mirantis 会议摘要:  1.murano client和murano dashboard升级到y ...

  5. Murano Weekly Meeting 2015.07.14

    会议时间: 2015.07.14 主持人: Kirill Zaitsev, core from Mirantis 会议摘要:  1.periodic nightly builds,然后通过mailin ...

  6. Spring Boot 自动配置 源码分析

    Spring Boot 最大的特点(亮点)就是自动配置 AutoConfiguration 下面,先说一下 @EnableAutoConfiguration ,然后再看源代码,到底自动配置是怎么配置的 ...

  7. Archlinux 2015.07.01 和 Windows7 双系统 安装教程

    提前在windows7下给Archlinux预留一个分区,大小最好在20G以上(根据自己硬盘情况分配). 第一步,安装前的准备 从arch官网下载最新的ISO文件archlinux-2015.07.0 ...

  8. Spring Boot探究之旅--启动分析

    刚接触SpringBoot,感觉挺方便的,不用配置那么多乱七八糟的配置,很方便!酒饱思淫欲,得陇望蜀一下,看看SpringBoot到底怎么做到这么方便的. 首先呢,先来看个SpringBoot的hel ...

  9. spring boot 2.0 源码分析(五)

    在上一篇文章中我们详细分析了spring boot是如何准备上下文环境的,今天我们来看一下run函数剩余的内容.还是先把run函数贴出来: /** * Run the Spring applicati ...

随机推荐

  1. MapReduce辅助排序

    需求:订单数据 求出每个订单中最贵的商品? 订单id正序,成交金额倒序. 结果文件三个,每个结果文件只要一条数据. 1.Mapper类 package com.css.order.mr; import ...

  2. django允许外部访问

    默认方法启动django python manage.py runserver 这时启动的服务只能在本机访问,这是因为服务只向本机(127.0.0.1:8000)提供,所以局域网的其他机器不能访问. ...

  3. Linux时间管理涉及数据结构和传统低分辨率时钟的实现

    上篇文章大致描述了Linux时间管理的基本情况,看了一些大牛们的博客感觉自己写的内容很匮乏,但是没办法,只能通过这种方式提升自己……闲话不说,本节介绍下时间管理下重要的数据结构 设备相关数据结构 // ...

  4. 聊聊高并发(三十四)Java内存模型那些事(二)理解CPU快速缓存的工作原理

    在上一篇聊聊高并发(三十三)从一致性(Consistency)的角度理解Java内存模型 我们说了Java内存模型是一个语言级别的内存模型抽象.它屏蔽了底层硬件实现内存一致性需求的差异,提供了对上层的 ...

  5. linux 配置SSH网络传输数据安全方案,JDK,Tomcat和Eclipes

    一.通过ssh实现安全远程访问linux系统 ssh :secure shell 加密: 1. 对称加密 (加密密钥与解密密钥相同) des .aes 2. 非对称加密(加密密钥与解密密钥不同) RS ...

  6. 宏表达式与函数、#undef、条件编译、

    宏表达式在预编译期被处理,编译器不知道宏表达式的存在. 宏表达式没有任何的调用开销 宏表达式中不能出现递归定义. C语言中强大的内置宏 __FILE__:被编译的文件名 //双底线 __LINE__: ...

  7. 正确使用goto语句

    是否应该使用goto语句 goto语句也被称为无条件转移语句,它通常与条件语句配合使用来改变程序流向,使得程序转去执行语句标号所标识的语句. 关于是否应该使用goto语句,历史上也争论不休.恐怕国内大 ...

  8. Selenium-IDE,Selenium-RC ,Selenium grid以及 Selenium-Core

    Selenium-IDE,Selenium-RC ,Selenium grid 以及 Selenium-Core Selenium 是一种 Web 应用的自动测试工具,通过模拟用户对 Web 页面的各 ...

  9. nfs 安装及使用

    安装 引用: https://zerlong.com/537.html Windows Server2012搭建NFS服务器 2017-06-01 5739 Views 1153 Times 开启NF ...

  10. PKU 1208 The Blocks Problem(模拟+list应用)

    题目大意:原题链接 关键是正确理解题目意思 首先:介绍一下list容器的一些操作:参考链接 list<int> c1; c1.unique();              去重. c1.r ...