環(huán)境:ubuntu 20.04
1 uboot源碼下載:
1.1 進入uboot官網
uboot官網在進入之后如下所示:
我們可以直接選擇Obtaining the source進入到獲取源碼的網址
1.2 下載源碼
在點擊Obtaining the source進入到新的網址之后就會看到下面提示去獲取uboot的源碼:
The source of the U-Boot project is maintained in a Git repository.
You can download the source via
git clone https://source.denx.de/u-boot/u-boot.git
A mirror of the source is maintained on Github
git clone https://github.com/u-boot/u-boot
The released versions are available as tags which use the naming scheme:
v<year>.<month>
Release candidates are named:
v<year>.<month>-rc<number>
To checkout the October 2020 release you would use:
git checkout v2020.10
2 編譯uboot
2.1 配置
目錄“configs/”包含維護的單板模板配置文件,命名如下:
<board name>_defconfig
比如,我想查看arm的公版的板卡配置,在我最新下載的uboot代碼下有以下相關的配置文件:
rlk@rlk:configs$ pwd
/home/rlk/work/u-boot/u-boot/configs
rlk@rlk:configs$ ls vexpress_* -alh
-rw-rw-r-- 1 rlk rlk 1.2K Dec 21 09:48 vexpress_aemv8a_juno_defconfig
-rw-rw-r-- 1 rlk rlk 965 Dec 21 09:48 vexpress_aemv8a_semi_defconfig
-rw-rw-r-- 1 rlk rlk 554 Dec 21 09:48 vexpress_aemv8r_defconfig
-rw-rw-r-- 1 rlk rlk 1.6K Dec 21 09:48 vexpress_ca9x4_defconfig
rlk@rlk:configs$
這些文件已經去掉了默認設置。所以你不能直接使用它們。相反,它們的名稱用作生成實際配置文件.config的make目標。例如,Odroid C2板的配置模板名為Odroid -c2_defconfig。對應的.config文件由下面的方式生成:
make odroid-c2_defconfig
如果當前的配置不能滿足您的需求,您也可以通過下面的命令去調節(jié)相關的配置:
make menuconfig
2.2 編譯
2.2.1 確認編譯工具鏈是否ok
rlk@rlk:u-boot$ aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rlk@rlk:u-boot$
如果沒有安裝,則執(zhí)行下面的命令去安裝一下對應的軟件即可:
sudo apt-get install gcc gcc-aarch64-linux-gnu
2.2.2 配置環(huán)境變量
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
2.2.3 編譯
make -j8
3 注意事項
3.1 uboot 2022.04版本問題
在使用最新的2022.04的uboot源碼編譯的時候存在一些問題,可以先切換到稍微老的版本的上去做測試。
https://www.mail-archive.com/ports@freebsd.org/msg01825.html文章來源:http://www.zghlxwxcb.cn/news/detail-434270.html
3.2 unable to execute ‘swig’: No such file or directory
安裝swig文章來源地址http://www.zghlxwxcb.cn/news/detail-434270.html
sudo apt-get install swig
到了這里,關于uboot源碼下載以及編譯的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!