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.10\arch\arm\cpu\armv7\s5pc1xx 在目錄下有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;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM