uboot——官网下载直接移植(一)

1:uboot下载地址:ftp://ftp.denx.de/pub/u-boot/spa

咱们下载的版本是:u-boot-2013.10.tar.bz2;code

2:下载好之后,删除里面的相关文件blog

由于三星是的s5pv1XX这个cpu作了不少个板子,咱们在移植的时候虽然与三星的开发板不一样可是用的cpu是相同的,因此咱们再选择cpu相关文件的时候,要肯定好哪一个cpu与ci

咱们用的cpu是相同的,u-boot-2013.10\arch\arm\cpu\armv7\s5pc1xx 在目录下有s5pc1xx相关的配置文件;这就是咱们要选用的cpu文件;开发

3:相较与咱们直接移植三星移植好的uboot,新版的uboot编译配置时有所不一样;把主Makefile与board有关的配置信息文件分开了;咱们能够根据board.cfg文件中的配置信息来get

肯定咱们用的是哪一个开发板;cmd

打开board.cfg文件搜索s5pc1xx咱们能够看到两个相关的开发板,goni、smdk100,咱们先用goni开发板来进行移植;it

首先删除其它的无关文件:io

arch目录下:asm

只保留arm文件夹;arm/cpu目录下的出armv7文件夹之外其余删除;

arm/cpu/armv7目录下保留s5pc1xx 以及s5p_common这两个文件夹,其余的删除;

board目录下:

board目录下只保留samsung文件夹

samsung目录下只保留goni、common文件夹

以后用sourceinsight建立项目

4:对主Makefile进行分析,以前咱们make的时候首先要进行配置:make x210_sd_config,而在新uboot中的配置依赖于下面这个规则:

咱们进行配置的时候make s5p_goni_config 而后执行下面这段脚本

至关于 执行 ./mkcofig -A s5p_goni  

MKCONFIG变量仍是mkconfig脚本,下面咱们看一下mkconfig脚本如何工做:

下面这段代码的做用:

 1 if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then  2  # Automatic mode  3     line=`awk '($0 !~ /^#/ && $7 ~ /^'"$2"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' boards.cfg`  4     if [ -z "$line" ] ; then  5         echo "make: *** No rule to make target \`$2_config'. Stop." >&2
 6         exit 1
 7  fi  8 
 9     set ${line} 10     # add default board name if needed 11     [ $# = 3 ] && set ${line} ${1} 12 fi

 

判断传参是否两个且 第一个参数为 -A,若是是则 对line赋值,line的值是经过在boards.cfg文件中查找第二个参数$2,并把这一行赋值给line,

从前面内容咱们能够看出

line = Active arm armv7 s5pc1xx samsung goni s5p_goni -

而且把这些由空格分开的字符赋值给$1-$8

因此这段代码执行完之后的结果是:

$1 = Active

$2 = arm

$3 = armv7

$4 = s5pv1xx

$5 = samsung

$6 = goni

$7 = s5p_goni

$8 = -

 继续分析下面代码:这段代码实际中没有起到什么做用可忽略

 1 while [ $# -gt 0 ] ; do
 2     case "$1" in
 3     --) shift ; break ;;  4     -a) shift ; APPEND=yes ;;  5     -n) shift ; BOARD_NAME="${7%_config}" ; shift ;;  6     -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;  7     *)  break ;;  8  esac  9 done 10 
11 [ $# -lt 7 ] && exit 1
12 [ $# -gt 8 ] && exit 1

下面代码:

CONFIG_NAME="${7%_config}" [ "${BOARD_NAME}" ] || BOARD_NAME="${7%_config}" arch="$2" cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'` spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'` if [ "$6" = "-" ] ; then board=${BOARD_NAME} else board="$6" fi [ "$5" != "-" ] && vendor="$5" [ "$4" != "-" ] && soc="$4" [ $# -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" fi # Check if we only have a colon... if [ "${tmp}" != "$8" ] ; then options=${8#*:} TARGETS="`echo ${options} | sed 's:,: :g'` ${TARGETS}" fi }

config_name = s5p_goni_config

BOARD_NAME = s5p_goni_config

arch = arm

cpu = armv7

spl_cpu = " "

board = goni

vendor = samsung

soc = s5pc1xx

看下面信息:

在这里第一打印出信息:Configuring for s5p_goni_config board...

if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then echo "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}" 1>&2 exit 1 fi if [ "$options" ] ; then echo "Configuring for ${BOARD_NAME} - Board: ${CONFIG_NAME}, Options: ${options}"
else echo "Configuring for ${BOARD_NAME} board..." fi

 

建立头文件的符号链接:

if [ "$SRCTREE" != "$OBJTREE" ] ; then mkdir -p ${OBJTREE}/include mkdir -p ${OBJTREE}/include2 cd ${OBJTREE}/include2 rm -f asm ln -s ${SRCTREE}/arch/${arch}/include/asm asm LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/ cd ../include mkdir -p asm else cd ./include rm -f asm ln -s ../arch/${arch}/include/asm asm fi rm -f asm/arch if [ -z "${soc}" ] ; then ln -s ${LNPREFIX}arch-${cpu} asm/arch else ln -s ${LNPREFIX}arch-${soc} asm/arch fi if [ "${arch}" = "arm" ] ; then rm -f asm/proc ln -s ${LNPREFIX}proc-armv asm/proc fi

符号链接1:/include/asm 链接到  /arch/arm/include/asm

符号链接2: /include/asm/arch连接到 /arch/arm/include/asm/arch-s5pc1xx

符号连接3: /include/asm/proc连接到/arch/arm/include/asm/proc-armv

看一下下面的代码:

# # Create include file for Make # ( echo "ARCH = ${arch}"
    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}" fi echo "BOARD = ${board}" [ "${vendor}" ] && echo "VENDOR = ${vendor}" [ "${soc}"    ] && echo "SOC = ${soc}" exit 0 ) > config.mk

这段代码的做用是把

ARCH = arm

CPU = armv7

BOARD  = goni

vendor = samsung

soc = s5pc1xx 输出config.mk文件中

看下面代码:

# Assign board directory to BOARDIR variable if [ -z "${vendor}" ] ; then BOARDDIR=${board} else BOARDDIR=${vendor}/${board} fi

 

BOARDDIR = samsung/goni

再看最后一段代码:

# 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 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 cat << EOF >> config.h #define CONFIG_BOARDDIR board/$BOARDDIR #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

 

上面这段代码的做用就是添加一些宏定义到config.h文件中:

/* Automatically generated - do not edit */

TARGETS为空因此不执行

#define CONFIG_SYS_ARCH  arm

#define CONFIG_SYS_CPU  armv7

#define CONFIG_SYS_BOARD  goni

#define CONFIG_SYS_SOC  s5pc1xx 

cat << EOF >> config.h 这句代码的做用是把下面内容写入config.h中,直到EOF;

相关文章
相关标签/搜索