#!/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 <[email protected]>
#
#将开发板参数传入
#表示不在后面添加而是新建一个配置文件config.h
APPEND=no # Default: Create new config file
#开发板的名称默认为空
BOARD_NAME="" # Name to print in make output
#用户传递的配置参数大于0
# $#表示输入进来的参数个数,-gt(great than)表示左边大于右边则返回真
# SHELL常用内部参数:
# $# ----传递给程序的总的参数数目
# $? ----上一个代码或者shell程序在shell中退出的情况,如果正常退出则返回0,反之为非0值。
# $* ----传递给程序的所有参数组成的字符串。
# $n ----表示第几个参数,$1 表示第一个参数,$2 表示第二个参数 ...
# $0 ----当前程序的名称
# $@----以"参数1" "参数2" ... 形式保存所有参数
# $$ ----本程序的(进程ID号)PID
# $! ----上一个命令的PID
#shift为$1=$2.。。以此类推
while [ $# -gt 0 ] ; do
case "$1" in
--) shift ; break ;;
-a) shift ; APPEND=yes ;;
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
*) break ;;
esac
done
#判断开发板的名字是否已经设置 如果没设置的话用第一个参数来设置开发板的名字smdk6410
[ "${BOARD_NAME}" ] || BOARD_NAME="$1"
[ $# -lt 4 ] && exit 1
[ $# -gt 8 ] && exit 1
echo "Configuring for ${BOARD_NAME} board which boot from $7 $8..."
#
# 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
rm -f asm-$2/arch
#判断第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
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
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
#
# 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
#
# 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
case $7 in
SD)
echo "#define FRIENDLYARM_BOOT_MEDIA_SD" >> config.h
;;
NAND)
echo "#define FRIENDLYARM_BOOT_MEDIA_NAND" >> config.h
;;
*)
;;
esac
case $8 in
ram128)
echo "#define FRIENDLYARM_BOOT_RAM128" >> config.h
;;
ram256)
echo "#define FRIENDLYARM_BOOT_RAM256" >> config.h
;;
*)
;;
esac
echo "#include <configs/$1.h>" >>config.h
exit 0