當(dāng)前位置:首頁(yè) > 嵌入式培訓(xùn) > 嵌入式學(xué)習(xí) > 講師博文 > yocto編譯總結(jié)
前言
我們是在64位的ubuntu上編譯3.14.52版本
——》切記相關(guān)配置要求,否則錯(cuò)誤極多!
官方資料:
//www.yoctoproject.org/docs/current/ref-manual/ref-manual.html#structure-core-bitbake
//cgit.openembedded.org/bitbake/
參考資料:
https://github.com/gmacario/easy-build/tree/master/build-yocto
https://maniacbug.wordpress.com/2012/08/03/pandayocto/
1:Host Packages:
note:不同位/版本的ubuntu的安裝準(zhǔn)備包是不一樣的!
$sudo apt-get update
$sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev
$sudo apt-get install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc
$sudo apt-get install u-boot-tools
2:Setting Up the Repo Utility
這一步是生成了repo工具
2.1:★
$ mkdir ~/bin
$ curl //commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
2.2:
Add the following line to the .bashrcfile to ensure that the ~/binfolder is in your PATH variable
//如果你嚴(yán)格按照上邊的操作,下邊的操作可以直接復(fù)制下去
export PATH=~/bin:$PATH
3:安裝Yocto Project Setup
3.1:
$ mkdir fsl-release-bsp
$ cd fsl-release-bsp
//填寫(xiě)自己的相關(guān)信息
$ git config --global user.name "zhaolong"
$ git config --global user.email home_zhaolong@outlook.com
$ git config --list
3.2:★
//注意:這句要求我們選擇要現(xiàn)在的版本,這個(gè)一定根據(jù)自己的要求去填寫(xiě),不要直接拷貝執(zhí)行。這句話也可能會(huì)失敗,它說(shuō)你權(quán)限不夠,那可能是你將fsl-release-bsp文件建在了/下,一旦你切換到root,它又說(shuō)repo命令找不到,要你下載,千萬(wàn)不要sudo apt-get insatll repo,這個(gè)絕對(duì)錯(cuò),不要懷疑絕對(duì)錯(cuò)!!你應(yīng)該修改fsl-release-bsp的權(quán)限就可以了!!這句話也很容易錯(cuò)誤,要么說(shuō):網(wǎng)絡(luò)不可達(dá),要么服務(wù)拒絕!這個(gè)是正常的,要不斷試著安裝。這個(gè)不算是錯(cuò)誤。我們?cè)L問(wèn)是外國(guó)的網(wǎng)站,這個(gè)正常。
$repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-3.14.52-1.1.0_ga --repo-url=//github.com/android/tools_repo
$ repo sync ------->//這條指令會(huì)執(zhí)行很長(zhǎng)很長(zhǎng)時(shí)間,而且是很容易出錯(cuò)誤!
注意:
這一步很容易出錯(cuò),If errors occur during repo initialization, try deleting the .repo directory and running the repo initialization command again.在執(zhí)行這一步的時(shí)候一旦有錯(cuò)誤就要無(wú)條件的將.repo目錄刪除再更新操作。從新走3.2這個(gè)步驟。
3.2報(bào)錯(cuò)總結(jié):
錯(cuò)誤:error: Exited sync due to fetch errors
解決方案1(失敗):repo sync -f -j10
-f 是強(qiáng)制force執(zhí)行的意思。
-jx 就是表示開(kāi)x個(gè)線程來(lái)進(jìn)行編譯。X的數(shù)目是你實(shí)際處理器個(gè)數(shù)的2倍。
解決方案2(失敗):git版本太低
git –version查看相關(guān)git的版本,git版本太低了, repo 升級(jí),不兼容git 1.7.2 以下的版本(git --version,1.7.0.4,貌似是低了點(diǎn)),總之就是git的版本要 >= 1.7.2以上。
修改/etc/apt/sources.list文件(該文件是只讀文件,sudo vi sources.list) 把下面內(nèi)容加到后面
deb //mirrors.163.com/ubuntu/ oneiric main universe restricted multiverse
deb-src //mirrors.163.com/ubuntu/ oneiric main universe restricted multiverse
deb //mirrors.163.com/ubuntu/ oneiric-security universe main multiverse restricted
deb-src //mirrors.163.com/ubuntu/ oneiric-security universe main multiverse restricted
deb //mirrors.163.com/ubuntu/ oneiric-updates universe main multiverse restricted
deb //mirrors.163.com/ubuntu/ oneiric-proposed universe main multiverse restricted
deb-src //mirrors.163.com/ubuntu/ oneiric-proposed universe main multiverse restricted
deb //mirrors.163.com/ubuntu/ oneiric-backports universe main multiverse restricted
deb-src //mirrors.163.com/ubuntu/ oneiric-backports universe main multiverse restricted
deb-src //mirrors.163.com/ubuntu/ oneiric-updates universe main multiverse restricted
執(zhí)行命令:sudo apt-get update
如果出現(xiàn):提示MMap 沒(méi)有空間了。請(qǐng)?jiān)龃?APT::Cache-Limit 的大小。
按下面的方法解決:
編輯 sudo gedit /etc/apt/apt.conf
修改APT::Cache-Limit 99999999;
改完之后,重新執(zhí)行sudo apt-get update
執(zhí)行命令:sudo apt-get install git 好了,執(zhí)行完畢后再重新查看git的版本,
解決方案3(失敗):repo sync --force-sync
repo sync --force-sync system/core
repo sync -j1 -f --force-sync
4:compiling生成bsp
4.1:配置編譯項(xiàng)
4.1.1這個(gè)生成完整的bsp:
$MACHINE=imx6qsabresd source fsl-setup-release.sh -b imx6qsabresd-fb -e fb
$MACHINE=imx6ulevk source fsl-setup-release.sh -b imx6ulevk-fb -e fb
$MACHINE=imx6ulevk source fsl-setup-release.sh -b imx6ulevk2-fb -e fb
DISTRO:發(fā)行版配置 可以定制!
我們可以后將配置項(xiàng)目保存到source/meta-fsl-bsprelease/imx/meta-sdk/conf/distro的配置文件中看到相關(guān)配置。主要支持的發(fā)行版配置:
• fsl-imx-x11 -Only X11 graphics
• fsl-imx-wayland -Wayland weston graphics
• fsl-imx-xwayland -Wayland graphicsand X11.X11 applications using EGL not supported
• fsl-imx-fb -Frame Buffer graphics - no X11 or Way
MACHINE:板子配置項(xiàng)
這個(gè)是機(jī)器的名字,就是你板子的名字。這個(gè)具體可以在meta-fsl-arm and meta-fsl-bsp-release的配置文件conf/machine找到的。實(shí)際上meta-fsl-arm and meta-fsl-bsp-release和meta-fsl-arm-extra是可用的其他的都沒(méi)有用!
可以選項(xiàng)如下:
• imx6qpsabreauto
• imx6qpsabresd
• imx6ulevk
• imx6dlsabreauto
• imx6dlsabresd
• imx6qsabreauto
• imx6qsabresd
• imx6slevk
• imx6solosabreauto
• imx6solosabresd
• imx6sxsabresd
• imx6sxsabreauto
• imx7dsabresd
-b:編譯目錄配置項(xiàng)
這個(gè)是指明了配置編譯時(shí)候的目錄
-e:后端圖像配置項(xiàng)
這個(gè)是指明了顯示平臺(tái)和DISTRO作用一樣,如果你沒(méi)有指定DISTRO,那在后用-e fb 指明的是使用的是DISTRO=fsl-imx-fb否則是DISTRO=fsl-imx-x11可以支持的后端圖像有:
• fb
• dfb
• wayland
• x11
正常執(zhí)行后:
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
meta-toolchain
meta-toolchain-sdk
adt-installer
meta-ide-support
Your build environment has been configured with:
MACHINE=imx6ulevk
SDKMACHINE=i686
DISTRO=fsl-imx-x11
EULA=1
BSPDIR=
BUILD_DIR=.
root@ubuntu:~/fsl-release-bsp-L3.14.52/imx6ul-sabresd-fb#
4.1.2這個(gè)僅僅生成uboot:
$MACHINE=imx6ulevk bitbake -c deploy u-boot-imx
4.2:編譯
//在執(zhí)行這一步的時(shí)候我們可以bitbake –help下看看。能夠顯示說(shuō)明,當(dāng)前環(huán)境還算可以,但絕對(duì)不是就是百分百OK了,只能說(shuō)可以了。
$bitbake fsl-image-machine-test ------》//這個(gè)命令執(zhí)行更費(fèi)時(shí)間!!不要著急。
Build Configuration:
BB_VERSION = "1.26.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "Ubuntu-14.04"
TARGET_SYS = "arm-poky-linux-gnueabi"
MACHINE = "imx6ulevk"
DISTRO = "fsl-imx-fb"
DISTRO_VERSION = "3.14.52-1.1.1"
TUNE_FEATURES = "arm armv7a vfp neon callconvention-hard cortexa7"
TARGET_FPU = "vfp-neon"
meta ----->poky
meta-yocto ----->poky
meta-fsl-arm ----->meta-fsl-arm
meta-fsl-arm-extra ----->meta-fsl-arm-extra
meta-fsl-demos ----->meta-fsl-demos
meta-bsp ----->meta-fsl-bsp-release
meta-sdk ----->meta-fsl-bsp-release
meta-gnome ----->meta-openembedded
meta-networking ----->meta-openembedded
meta-python ----->meta-openembedded
meta-ruby ----->meta-openembedded
meta-filesystems ----->meta-openembedded
meta-oe ----->meta-openembedded
meta-multimedia ----->meta-openembedded
meta-qt5 ----->
meta-browser ----->
4.2報(bào)錯(cuò)總結(jié):
ERROR: OE-core's config sanity checker detected a potential misconfiguration.
Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
Following is the list of potential problems / advisories:
Do not use Bitbake as root.
這個(gè)記住這個(gè)報(bào)錯(cuò)是軟件安全考慮造成的錯(cuò)誤。這個(gè)時(shí)候你一定是root權(quán)限進(jìn)行操作的,你這個(gè)時(shí)候su ubuntu的時(shí)候在去執(zhí)行,他一定會(huì)報(bào)錯(cuò):沒(méi)有bitbake命令這個(gè)時(shí)候切記不要sudo apt-get bitbake一定不要!!你仔細(xì)留意的化你會(huì)發(fā)現(xiàn)你當(dāng)前在你編譯項(xiàng)指定的那個(gè)目錄層次里面,退出去刪除這個(gè)目錄,切換權(quán)限su Ubuntu ,然后在執(zhí)行bitbake 命令。就OK了!!
5:compiling and install sdk
//這個(gè)命令也是耗費(fèi)時(shí)間的!
$bitbake fsl-image-machine-test -c populate_sdk
成功執(zhí)行的:
$cd tmp/deploy/sdk/
//你會(huì)看到下邊的交叉編譯工具鏈,OK了。
./poky-glibc-x86_64-fsl-image-gui-cortexa7hf-vfp-neon-toolchain-1.8.sh
//press enter and Y, do not change the install folder
總結(jié):
(一) 這個(gè)環(huán)境做好了以后就可以不要?jiǎng)h除了,你以后就直接走步驟4就可以了。
(二) 一旦退出再次進(jìn)入,那么bitbake一定不能用了,這個(gè)時(shí)候你要么將編譯目錄刪除重走步驟4,或者source setup-environment ./imx6ulevk-fb/ 后邊的是你的編譯目錄。
文件系統(tǒng)位置:
work/imx6ulevk-poky-linux-gnueabi/base-files/3.0.14-r89/image