uboot 编译前的配置命令make config分析

在编译uboot前都要执行make config,这里以百问网提供的uboot为例(本人一直用韦东山老师的资料学习,确实讲得好),对照韦东山老师的视频,对make config过程谈一谈自己的理解。
首先下载u-boot-1.6.tar.bz2以及u-boot-1.6.patch
步骤:
1.解压缩tar xjf u-boot-1.6.tar.bz2
2.进入源码目录cd u-boot-1.6
3.打补丁patch -p1 <…/u-boot-1.6.patch
4.配置make 100ask24x0_config
下面就解析一下make 100ask24x0_config

一、make 100ask24x0_config分析

在Makefile中可以查找到
原文:

100ask24x0_config	:	unconfig
	@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0

MKCONFIG := $(SRCTREE)/mkconfig
SRCTREE := $(CURDIR)
变量展开后·:

100ask24x0_config	:	unconfig
	$(CURDIR)/mkconfig 100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0

以当前路径下的mkconfig脚本运行,参数为100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0
$0 $1 $2 ……$n 表示命令行的参数,$0是命令本身,$1是第一个参数,$n是第n个参数
$#表示参数个数

该命令运行前,在运行前执行unconfig:

unconfig:
	@rm -f $(obj)include/config.h $(obj)include/config.mk \
		$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp

obj := $(OBJTREE)/
OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
如果定义BUILD_DIR就用,如果没定义就用CURDIR。
即清除$(CURDIR)/include/config.h $(CURDIR)/include/config.mk等配置文件

二、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

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"
******************************************************************************
未定义BOARD_NAME则定义为$1,即100ask24x0
******************************************************************************
[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1
******************************************************************************
$#表示参数个数,为6,参数个数小于4或大于6都退出
******************************************************************************
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
******************************************************************************
命令:ln -s asm-arm asm
用处:建立指向asm-arm的链接文件asm;
原因:#include<asm-type.h>,编译arm时#include<asm-arm.h>,编译i386时#include<asm-i386.h>,
用该命令后直接写为#include<asm.h>无需更改type。
******************************************************************************
fi

rm -f asm-$2/arch

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
******************************************************************************
将asm-arm/arch指向arch-s3c24x0
******************************************************************************
if [ "$2" = "arm" ] ; then
	rm -f asm-$2/proc
	ln -s ${LNPREFIX}proc-armv asm-$2/proc
fi
******************************************************************************
将asm-arm/proc指向proc-armv
******************************************************************************

#
# Create include file for Make
#
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
******************************************************************************
创建config.mk,内容为
ARCH   = arm
CPU    = arm920t
BOARD  = 100ask24x0
SOC    = s3c24x0
******************************************************************************
#
# 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

******************************************************************************
创建config.h,内容为
/* Automatically generated - do not edit */
#include <configs/100ask24x0.h>
******************************************************************************
exit 0
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

闪耀大叔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值