歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> u-boot-2015.01在TQ2440上移植過程分享

u-boot-2015.01在TQ2440上移植過程分享

日期:2017/3/1 9:33:37   编辑:Linux編程

開發板: tq2440

工具: Win7 + VMware + Debian6

U-boot版本: u-boot-2015.01

Linux版本: 天嵌自帶的 linux-2.6.30.4

GCC版本: gcc version 4.3.3 (Sourcery G++ Lite 2009q1-176)

之前由於移植過u-boot-2014.04到tq2440上,現在移植u-boot-2015.01的時候就不說那麼詳細了,因為之前已經說的很詳細了,現在簡略移植一下。

在移植的時候,基本上是參考移植u-boot-2014.04時寫的文檔,可以到這裡下載:http://www.linuxidc.com/Linux/2015-02/112933.htm

首先說明一下u-boot-2015.01跟之前版本的差別
從 http://www.linuxidc.com/Linux/2011-07/38897.htm 下載最新的u-boot版本,目前最新的是 u-boot-2015.01.tar.bz2

下面是解壓後得到的文件:

可以看到目錄內容跟u-boot-2014.04不同了,下面是u-boot-2014.04的頂層目錄內容:

其中最不同的就是我們所熟悉的在u-boot-2014.04中的boards.cfg和mkconfig沒有了,而同時又在u-boot-2015.01的頂層目錄下多出了一個configs目錄,還有一個Kconfig文件(這不是Linux內核所特有的嗎?),可以看到u-boot一直在學習Linux內核的配置和編譯方法。

在configs目錄下有很多默認的配置文件:

在Linux的arch/arm/configs下面也有很多默認的配置文件,Linux內核在配置的時候可以使用 make xxx_defconfig 來配置,

看樣子,u-boot也可以使用make xxx_defconfig,Linux內核還可以使用make menuconfig來配置,u-boot也可以使用make menuconfig來配置,下面我們用smdk2410為例實驗一下:

在u-boot-2015.01的configs目錄下有一個叫做smd2410_defconfig的配置文件,那麼執行 make smd2410_defconfig

然後我們再執行make menuconfig試試:

果然如此。

我們選擇的是smdk2410的配置文件,在這裡體現出來:

然後就可以編譯了, 直接執行 make 即可,剛開始會報錯:

原因是我們沒有指定交叉編譯工具鏈的名字,修改頂層的Makefile即可:

然後再執行make就可以編譯成功。

在以前的u-boot配置是總是有什麼ARCH、CPU、BOARD和SOC之類的變量,同時編譯完成後會在include下生成一個叫做config.mk的文件,其中對這幾個變量賦值了,如:

但是在u-boot-2015.01編譯完成後,在include下面卻沒有config.mk了,只有autoconf.mk了,那它是怎麼做的呢?

在u-boot-2015.01中執行完make smdk2410_defconfig後,會在頂層目錄中生成一個.config文件,我們大致看一下其中的內容:

可以看到,在.config中還是有ARCH、CPU、SOC以及BOARD之類的配置項,在頂層目錄下的config.mk中會使用.config中的配置:

在arch/Kconfig中對這幾個配置進行了說明:

config SYS_ARCH
string
help
This option should contain the architecture name to build the
appropriate arch/<CONFIG_SYS_ARCH> directory.
All the architectures should specify this option correctly.

config SYS_CPU
string
help
This option should contain the CPU name to build the correct
arch/<CONFIG_SYS_ARCH>/cpu/<CONFIG_SYS_CPU> directory.

This is optional. For those targets without the CPU directory,
leave this option empty.

config SYS_SOC
string
help
This option should contain the SoC name to build the directory
arch/<CONFIG_SYS_ARCH>/cpu/<CONFIG_SYS_CPU>/<CONFIG_SYS_SOC>.

This is optional. For those targets without the SoC directory,
leave this option empty.

config SYS_VENDOR
string
help
This option should contain the vendor name of the target board.
If it is set and
board/<CONFIG_SYS_VENDOR>/common/Makefile exists, the vendor common
directory is compiled.
If CONFIG_SYS_BOARD is also set, the sources under
board/<CONFIG_SYS_VENDOR>/<CONFIG_SYS_BOARD> directory are compiled.

This is optional. For those targets without the vendor directory,
leave this option empty.

config SYS_BOARD
string
help
This option should contain the name of the target board.
If it is set, either board/<CONFIG_SYS_VENDOR>/<CONFIG_SYS_BOARD>
or board/<CONFIG_SYS_BOARD> directory is compiled depending on
whether CONFIG_SYS_VENDOR is set or not.

This is optional. For those targets without the board directory,
leave this option empty.

config SYS_CONFIG_NAME
string
help
This option should contain the base name of board header file.
The header file include/configs/<CONFIG_SYS_CONFIG_NAME>.h
should be included from include/config.h.


同時在arch/Kconfig中又會加載其他目錄下的Kconfig,如 source “arch/arm/Kconfig”,在arch/arm/Kconfig中又會加載board目錄下的Kconfig,如 source “board/samsung/smdk2410/Kconfig”,下面我們看一下board/samsung/smdk2410/Kconfig中的內容:

不錯,就是在這裡對.config中的那幾個配置賦了值,可以看到,第一個行用TARGET_SMDK2410進行了判斷,這個在arch/arm/Kconfig中:

意思是: 如果選擇的是smd2410,TARGET_SMDK2410會被選擇,然後board/samsung/smdk2410/Kconfig會對CONFIG_SYS_CPU、CONFIG_SYS_SOC、CONFIG_SYS_VENDOR、CONFIG_SYS_BOARD、CONFIG_SYS_CONFIG_NAME賦值:

先說到這裡吧。

更多詳情見請繼續閱讀下一頁的精彩內容: http://www.linuxidc.com/Linux/2015-02/112934p2.htm

Copyright © Linux教程網 All Rights Reserved