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;

相關文章
相關標籤/搜索