嵌入式开发(S5PV210)——u-boot的顶层mkconfig文件分析
Posted 代二毛
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了嵌入式开发(S5PV210)——u-boot的顶层mkconfig文件分析相关的知识,希望对你有一定的参考价值。
mkconfig文件的调用
# 第一步:SRCTREE是源码的路径,也就是顶层的目录
MKCONFIG := $(SRCTREE)/mkconfig
export MKCONFIG
#第二步:配置
#$(@:_config=):作用是将x210_sd_config的_config去掉,得到x210_sd
x210_sd_config : unconfig
@$(MKCONFIG) $(@:_config=) arm s5pc11x x210 samsung s5pc110
@echo "TEXT_BASE = 0xc3e00000" > $(obj)board/samsung/x210/config.mk
#第三步:x210_sd_config目标的依赖
unconfig:
@rm -f $(obj)include/config.h $(obj)include/config.mk \\
$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \\
$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \\
$(obj)board/$(VENDOR)/$(BOARD)/config.mk
解析:上面的脚本是从顶层Makefile中摘抄的,mkconfig也是被顶层mkconfig调用,通过编译指令make x210_sd_config调用,其中x210_sd_config是根据自己开发板来确定的配置项。
(1)第一步:MKCONFIG记录的是顶层mkconfig的路径;
(2)第二步:编译uboot的时候要先配置,然后就会去执行mkconfig脚本,执行时会传参"x210_sd arm s5pc11x x210 samsung s5pc110"。
(3)第三步;unconfig是x210_sd_config的依赖,这个目标的功能是删除掉上一次配置的结果,这样可以保证每次执行配置的操作都可以生效。
mkconfig文件的主要作用
mkconfig是uboot的配置文件,根据传入的参数创建链接指向不同的文件夹,往配置文件里写入不同的内容,适配不同架构的CPU和开发板。创建的链接在源码包含头文件时就会指向不同路径下的头文件,由此实现uboot的兼容性。
mkconfig文件的内容
#!/bin/sh -e
# Script to create header files and links to configure(脚本去创建头文件和配置链接)
# U-Boot for a specific board.(特定开发板的uboot)
#
# Parameters: Target Architecture CPU Board [VENDOR] [SOC](参数:目标COU架构的开发板的供应商)
#
# (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
#
#根据上面Makefile的分析,传入mkconfig文件的参数是"x210_sd arm s5pc11x x210 samsung s5pc110"
#$1=x210_sd; $2=arm; $3=s5pc11x; $4=x210; $5=samsung; $6=s5pc110
APPEND=no # Default: Create new config file
BOARD_NAME="" # Name to print in make output
#判断传入的参数个数是否大于0,并根据$1进行选择
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为空则BOARD_NAME=$1,也就是x210_sd
[ "${BOARD_NAME}" ] || BOARD_NAME="$1"
#传入的参数个数小于4和大于6都会推出
[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1
echo "Configuring for ${BOARD_NAME} board..."
#
# 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
#注意这里已经进入到了相应的include目录,下面都以原地编译进行分析,假设进入到/include目录,/是指uboot源码所在的目录
#删除/include/asm-arm/arch
rm -f asm-$2/arch
#这里$6=s5pc110,所以执行的是:ln -s ${LNPREFIX}arch-$6 asm-$2/arch
#创建了/include/asm-arm/arch链接指向/include/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
# 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
# create link for s5pc11x SoC
#$3=s5pc11x所以条件成立
#创建链接/include/reg.h指向/include/s5pc110.h
#创建链接/include/asm-arm/arch链接指向/include/arch-s5pc11x
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
#创建链接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
#
# 创建/include/config.mk文件并写入内容
#创建完成后config.mk的内容为:
# ARCH = arm
# CPU = s5pc11x
# BOARD = x210
# VENDOR = samsung
# SOC = s5pc110#
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
#
# 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
以上是关于嵌入式开发(S5PV210)——u-boot的顶层mkconfig文件分析的主要内容,如果未能解决你的问题,请参考以下文章
嵌入式开发(S5PV210)——u-boot的顶层config.mk分析
嵌入式开发(S5PV210)——u-boot中如何确定启动方式