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


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

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

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

    因为三星是的s5pv1XX这个cpu做了很多个板子,我们在移植的时候虽然与三星的开发板不同但是用的cpu是相同的,所以我们再选择cpu相关文件的时候,要确定好哪个cpu与

    我们用的cpu是相同的,u-boot-2013.10archarmcpuarmv7s5pc1xx 在目录下有s5pc1xx相关的配置文件;这就是我们要选用的cpu文件;

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

    确定我们用的是哪个开发板;

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

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

    arch目录下:

    只保留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;

  • 相关阅读:
    文本框输入限制 [大全]
    JavaScript关于window.open()应用
    你还敢使用window.open弹广告吗?
    在HTML网页中插入ActiveX控件
    XMLDOC的常用方法和属性
    细说HTML元素的ID和Name属性的区别
    常用的40个网站制作技巧
    激活 ActiveX 控件
    laravel 配置 elasticsearch
    mac上运行ls 命名查看做面文件的出现“Operation not permitted”错误
  • 原文地址:https://www.cnblogs.com/biaohc/p/6473079.html
Copyright © 2020-2023  润新知