參考自:
https://www.jianshu.com/p/f6e0debb5e1f
https://blog.csdn.net/qq_31041847/article/details/90211464
原文設置repo使用鏡像需要翻牆才能下載使用,基於原文修改鏡像源為清華鏡像,另修改build-dir/conf/local.conf配置文件加快yocto編譯速度,親測可用。
目標:搭建支持設備樹的yocto環境,yocto的內核版本更高4.1.5
安裝軟件包
$ 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
安裝u-boot-tools
$ sudo apt-get install u-boot-tools
設置repo()
$ mkdir /work/tools/yocto/bin
$ cd /work/tools/yocto/bin
$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
$ chmod a+x repo
$ export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'
$ export PATH=/work/tools/yocto/bin:$PATH
設置git環境
$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"
$ git config --list
repo同步
$ mkdir /work/tools/yocto/fsl-release-bsp
$ cd /work/tools/yocto/fsl-release-bsp
$ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth
$ repo sync
然后等待同步完成,如果同步過程出錯,可以用ctrl+c中斷執行,並重新執行repo sync直到同步成功。
編譯yocto工程
$ DISTRO= MACHINE= source fsl- setup-release.sh -b
DISTRO有如下四種設置:
fsl-imx-x11
fsl-imx-wayland
fsl-imx-xwayland
fsl-imx-fb
我選擇fsl-imx-x11
MACHINE同樣有多種配置:
imx6qpsabreauto
imx6qpsabresd
imx6ulevk
imx6ull14x14evk
imx6ull9x9evk
imx6dlsabreauto
imx6dlsabresd
imx6qsabreauto
imx6qsabresd
imx6slevk
imx6solosabreauto
imx6solosabresd
imx6sxsabresd
imx6sxsabreauto
imx7dsabresd
我選擇imx6qsabresd。因此我執行的最終命令如下:
$ DISTRO=fsl-imx-x11 MACHINE=imx6qsabresd source fsl-setup-release.sh -b build
修改配置文件加快yocto編譯速度,具體修改如下圖:
編譯鏡像文件
$ bitbake fsl-image-qt5
同樣的bitbake可以編譯以下多種鏡像:
core-image-minimal
core-image-base
core-image-sato
fsl-image-machine-test
fsl-image-gui
fsl-image-qt5,
如未修改build-dir/conf/local.conf配置文件編譯fsl-image-qt5的時間非常長,在網速飛快的情況下也需兩天,如果編譯中途出錯,可以ctrl+c中斷后重新執行命令:
$ bitbake fsl-image-qt5
如果編譯過程中無意關掉了終端,那么重新打開終端進入fsl-release-bsp目錄后只需要執行以下命令就可以重新進入編譯環境:
$ source setup-environment build
編譯結束后會占用80G左右空間,虛擬機默認配置空間會不足
編譯qt5的交叉編譯工具鏈
$ bitbake meta-toolchain-qt5
編譯完成后會在/opt/yocto/fsl-release-bsp/build/tmp/deploy/sdk目錄下
生成文件fsl-imx-fb-glibc-i686-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.0.0.sh。
執行如下命令安裝qt5的交叉編譯工具鏈:
$ cd ~/fsl-release-bsp/build/tmp/deploy/sdk
$ ./fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh
…
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
執行如下命令安裝GCC的交叉編譯工具鏈:
$ source setup-environment build
$ bitbake meta-toolchain
$ cd ~/fsl-release-bsp/build/tmp/deploy/sdk
$ ./fsl-imx-x11-glibc-x86_64-meta-toolchain-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh
一路選擇默認設置,最終將在/opt/fsl-imx-x11/4.1.15-2.1.0/目錄下生成我們所需要的工具鏈。
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
至此,我們所需要的所有文件均已生成,包含了uboot,kernel,rootfs以及交叉編譯qt應用程序的交叉編譯工具。相對應的軟件版本如下:
uboot:v2016.03
kernel:v4.1.15
qt版本:qt5.6.2
當然最重要的是yocto編譯生成的rootfs中包括了imx6所需要的各種庫,特別是有我們所需要的能完整的支持imx6的gpu性能的qt5.6.
設置開機自動運行腳本
cd /opt/fsl-imx-x11/4.1.15-2.1.0
chmod a+x environment-setup-cortexa9hf-neon-poky-linux-gnueabi
vim ~/.bashrc
在最后一行添加
source /opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
