韦东山jz2440配套光盘uboot及视频学习笔记
分析uboot配置过程 make 100ask24x0_config
100ask24x0_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0
$(MKCONFIG)解释:
在顶层Makefile查找
MKCONFIG := $(SRCTREE)/mkconfig // 即源码树下的mkconfig
SRCTREE := $(CURDIR)
==> ./mkconfig
$(@:_config=) 解释:
$@ 表示目标
_config= 等于空表示替换掉这段字符
目标是100ask24x0_config, _config字符串被替换就变成100ask24x0
100ask24x0_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0
==>
./mkconfig 100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0
$0 $1 $2 $3 $4 $5 $6
打开mkconfig文件查看:
#!/bin/sh -e
# Script to create header files and links to configure
# U-Boot for a specific board.
#
# Parameters: Target Architecture CPU Board [VENDOR] [SOC]
#
# (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
#
APPEND=no # Default: Create new config file
BOARD_NAME="" # Name to print in make output
#我们要执行的命令没有-- -a -n , 所以以下while可以忽略
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", $1命令执行的表示第一个参数
# BOARD_NAME="$1" = 100ask24x0
[ "${BOARD_NAME}" ] || BOARD_NAME="$1"
#打印这句话
echo "Configuring for ${BOARD_NAME} board..."
#查看根目录Makefile可以得知 $SRCTREE = $OBJTREE
if [ "$SRCTREE" != "$OBJTREE" ] ; then
else
cd ./include #进入include目录
rm -f asm
ln -s asm-$2 asm # ln -s asm-arm asm 就是建立软连接, asm -> asm-arm
#当包含头文件#include <asm/type.h>实际上就是#include <asm-arm/type.h>
fi
rm -f asm-$2/arch #rm -f asm-arm/arch
# $6 = s3c24x0
# 判断$6是否为空或者=NULL, 都不成立
if [ -z "$6" -o "$6" = "NULL" ] ; then
ln -s ${LNPREFIX}arch-$3 asm-$2/arch
else
ln -s ${LNPREFIX}arch-$6 asm-$2/arch #ln -s arch-s3c24x0 asm-arm/arch 就是 asm-arm/arch -> arch-s3c24x0
fi
# $2 = arm
if [ "$2" = "arm" ] ; then
rm -f asm-$2/proc # m -f asm-arm/proc
ln -s ${LNPREFIX}proc-armv asm-$2/proc #ln -s proc-armv asm-arm/proc 就是 asm-arm/proc -> proc-armv
fi
#
# Create include file for Make 生成一个配置文件
#
echo "ARCH = $2" > config.mk # echo "ARCH = arm" > config.mk
echo "CPU = $3" >> config.mk # echo "CPU = arm920t" >> config.mk
echo "BOARD = $4" >> config.mk # echo "BOARD = 100ask24x0" >> config.mk
# $5 = NULL
[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
#$6 = s3c24x0
[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk # echo "SOC = s3c24x0" >> config.mk
# config.mk内容
# ARCH = arm
# CPU = arm920t
# BOARD = 100ask24x0
# SOC = s3c24x0
#
# Create board specific header file 创建一个板相关的头文件
#
#APPEND=no 执行else分支
if [ "$APPEND" = "yes" ] # Append to existing config file
then
echo >> config.h
else
> config.h # Create new config file 创建一个新的config.h
fi
echo "/* Automatically generated - do not edit */" >>config.h # 追加 /* Automatically generated - do not edit */ 到config.h
echo "#include <configs/$1.h>" >>config.h # 追加 #include <configs/100ask24x0.h> 到config.h
# config.h的内容
# /* Automatically generated - do not edit *
# #include <configs/100ask24x0.h>
exit 0