yocto环境搭建记录

主要参考 :《i.MX Yocto Project User’s Guide》Rev.0, 10/2016

0、更新源

备份原来的:

sudo cp /etc/apt/sources.list  /etc/apt/sources.list.bak

使用阿里的源

hedy@ubuntu:~$ cat /etc/apt/sources.list
#aliyun
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
 
#ubuntu 
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
 
#ubuntu other
deb http://archive.canonical.com/ubuntu/ trusty partner
deb http://extras.ubuntu.com/ubuntu/ trusty main
hedy@ubuntu:~$ 

1、无法安装包

hedy@ubuntu:~$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package texinfo is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  info install-info

Package git-core is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package gcc-multilib is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Unable to locate package gawk
E: Package 'git-core' has no installation candidate
E: Package 'texinfo' has no installation candidate
E: Package 'gcc-multilib' has no installation candidate
E: Unable to locate package build-essential

解决:

因为新装的ubuntu系统,没有update的原因。

输入命令:sudo apt-get update

再安装

2、repo 下载不下来

使用别人已经下载好的,直接拷贝过来。
repo下载 : link.

3、不能够下载源码

hedy@ubuntu:~/fsl-arm-yocto-bsp$ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth
gpg: keyring `/home/hedy/.repoconfig/gnupg/secring.gpg' created
gpg: keyring `/home/hedy/.repoconfig/gnupg/pubring.gpg' created
gpg: /home/hedy/.repoconfig/gnupg/trustdb.gpg: trustdb created
gpg: key 920F5C65: public key "Repo Maintainer " imported
gpg: key 692B382C: public key "Conley Owens " imported
gpg: Total number processed: 2
gpg:               imported: 2  (RSA: 1)

fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable

解决:
出现这个问题是因为,在天朝无法正常的访问google的服务器,

修改repo文件,将:

#REPO_URL = 'https://gerrit.googlesource.com/git-repo'

改为

REPO_URL = 'https://mirrors.ustc.edu.cn/aosp/git-repo'

4、下载源码不成功

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'hedy@ubuntu.(none)')

解决:

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

5、repo init 出错解决

 First install the i.MX NXP BSP repo
$: repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth

Download the Yocto Project NXP Layers:
$: repo sync

If errors on repo init, remove the .repo directory and try repo init again.

Note that this downloads the latest release for 4.1.15-2.1.0 plus patches after.

To download only the 4.1.15-2.1.0 release use this for repo init command
$: repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth -m imx-4.1.15-2.1.0.xml

6、编译出错

WARNING: linux-imx-4.1.15-r0 do_fetch: Failed to fetch URL git://git.freescale.com/imx/linux-imx.git;protocol=git;branch=imx_4.1.15_2.0.0_ga, attempting MIRRORS if available
ERROR: linux-imx-4.1.15-r0 do_fetch: Fetcher failure: Fetch command failed with exit code 128, output:
Cloning into bare repository '/home/hedy/fsl-arm-yocto-bsp/downloads//git2/git.freescale.com.imx.linux-imx.git'...
fatal: read error: Connection timed out
fatal: early EOF
fatal: index-pack failed

ERROR: linux-imx-4.1.15-r0 do_fetch: Function failed: Fetcher failure for URL: 'git://git.freescale.com/imx/linux-imx.git;protocol=git;branch=imx_4.1.15_2.0.0_ga'. Unable to fetch URL from any source.
ERROR: Logfile of failure stored in: /home/hedy/fsl-arm-yocto-bsp/build-fb/tmp/work/imx6qsabreauto-poky-linux-gnueabi/linux-imx/4.1.15-r0/temp/log.do_fetch.56902
ERROR: Task 50 (/home/hedy/fsl-arm-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_4.1.15.bb, do_fetch) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2009 tasks of which 0 didn't need to be rerun and 1 failed.
Waiting for 0 running tasks to finish:

Summary: 1 task failed:
  /home/hedy/fsl-arm-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_4.1.15.bb, do_fetch
Summary: There were 41 WARNING messages shown.
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

解决:
yocto会边下载边编译,如果网络环境不好,会出现各种错误。

可以先下载所有需要的软件包而不编译
有的时候我们可能需要先将所有需要的软件包下载下来,等离线回家或者其他时机再编译,对此我们可以使用如下命令来完成:

bitbake fsl-image-qt5 -c fetchall

再编译:

bitbake fsl-image-qt5

7、bitbake fsl-image-qt5 结果

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake fsl-image-qt5
Loading cache: 100% |##########################################################| ETA:  00:00:00
Loaded 2792 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.30.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-14.04"
TARGET_SYS        = "arm-poky-linux-gnueabi"
MACHINE           = "imx6qsabreauto"
DISTRO            = "fsl-imx-fb"
DISTRO_VERSION    = "4.1.15-2.1.0"
TUNE_FEATURES     = "arm armv7a vfp  neon        callconvention-hard        cortexa9"
TARGET_FPU        = "hard"
meta              
meta-poky         = "HEAD:f5da2a5913319ad6ac2141438ba1aa17576326ab"
meta-oe           
meta-multimedia   = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-fsl-arm      = "HEAD:be78894e4682f111575470fb23e51e6ba523508d"
meta-fsl-arm-extra = "HEAD:3dfb82fc7e703eae9891b3ffda0e9393701f2396"
meta-fsl-demos    = "HEAD:a165068f8a0d1cf29aabe4b4053f28be1c2aa492"
meta-bsp          
meta-sdk          = "HEAD:823b26a67261270d2bf22d511e6190641a8a90cf"
meta-browser      = "HEAD:77736988073a5d90fcff9d0005c8477332ede387"
meta-gnome        
meta-networking   
meta-python       
meta-filesystems  = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-qt5          = "HEAD:ccae79be69c5268df3b47e4e14cea0591c39a531"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
WARNING: lttng-modules-2.7.1+gitAUTOINC+45e0ebd91f-r0 do_package: lttng-modules: no modules were created; this may be due to CONFIG_TRACEPOINTS not being enabled in your kernel.
WARNING: gstreamer1.0-plugins-bad-qt-1.8.1-r0 do_configure: QA Issue: gstreamer1.0-plugins-bad-qt: configure was passed unrecognised options: --disable-libssh2 [unknown-configure-option]
WARNING: gstreamer1.0-plugins-bad-qt-1.8.1-r0 do_package_qa: QA Issue: gstreamer1.0-plugins-bad-qt-qmlgl rdepends on libgstgl-1.0, but it isn't a build dependency, missing gstreamer1.0-plugins-bad in DEPENDS or PACKAGECONFIG? [build-deps]
NOTE: Tasks Summary: Attempted 5838 tasks of which 2258 didn't need to be rerun and all succeeded.

Summary: There were 3 WARNING messages shown.
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

8、内核源码目录

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ tree -d -L 1 tmp/work-shared/imx6qsabreauto/kernel-source/
tmp/work-shared/imx6qsabreauto/kernel-source/
├── arch
├── block
├── crypto
├── Documentation
├── drivers
├── firmware
├── fs
├── include
├── init
├── ipc
├── kernel
├── lib
├── mm
├── net
├── samples
├── scripts
├── security
├── sound
├── tools
├── usr
└── virt

21 directories
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake -e linux-imx  | grep ^S=
S="/home/hedy/fsl-arm-yocto-bsp/build-fb/tmp/work/imx6qsabreauto-poky-linux-gnueabi/linux-imx/4.1.15-r0/git"
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

9、镜像目录


hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ ls tmp/deploy/images/imx6qsabreauto/
fsl-image-qt5-imx6qsabreauto-20181224080941.rootfs.ext4
fsl-image-qt5-imx6qsabreauto-20181224080941.rootfs.manifest
fsl-image-qt5-imx6qsabreauto-20181224080941.rootfs.sdcard
fsl-image-qt5-imx6qsabreauto-20181224080941.rootfs.tar.bz2
fsl-image-qt5-imx6qsabreauto.ext4
fsl-image-qt5-imx6qsabreauto.manifest
fsl-image-qt5-imx6qsabreauto.sdcard
fsl-image-qt5-imx6qsabreauto.tar.bz2
modules--4.1.15-r0-imx6qsabreauto-20181224080941.tgz
modules-imx6qsabreauto.tgz
README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
u-boot.imx
u-boot-imx6qsabreauto.imx
u-boot-imx6qsabreauto.imx-sd
u-boot.imx-sd
u-boot-sd-2016.03-r0.imx
zImage
zImage--4.1.15-r0-imx6qsabreauto-20181224080941.bin
zImage--4.1.15-r0-imx6q-sabreauto-20181224080941.dtb
zImage--4.1.15-r0-imx6q-sabreauto-ecspi-20181224080941.dtb
zImage--4.1.15-r0-imx6q-sabreauto-enetirq-20181224080941.dtb
zImage--4.1.15-r0-imx6q-sabreauto-flexcan1-20181224080941.dtb
zImage--4.1.15-r0-imx6q-sabreauto-gpmi-weim-20181224080941.dtb
zImage-imx6qsabreauto.bin
zImage-imx6q-sabreauto.dtb
zImage-imx6q-sabreauto-ecspi.dtb
zImage-imx6q-sabreauto-enetirq.dtb
zImage-imx6q-sabreauto-flexcan1.dtb
zImage-imx6q-sabreauto-gpmi-weim.dtb
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

10、u-boot 源码目录

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake -e u-boot-imx  | grep ^S=
S="/home/hedy/fsl-arm-yocto-bsp/build-fb/tmp/work/imx6qsabreauto-poky-linux-gnueabi/u-boot-imx/2016.03-r0/git"
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

11、rootfs目录

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ ls  tmp/work/imx6qsabreauto-poky-linux-gnueabi/fsl-image-qt5/1.0-r0/rootfs/
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  run  sbin  sys  tmp  unit_tests  usr  var
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

12、内核,u-boot下载地址

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake -e linux-imx | grep ^SRC_URI=
SRC_URI="git://git.freescale.com/imx/linux-imx.git;protocol=git;branch=imx_4.1.15_2.0.0_ga"
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake -e u-boot-imx | grep ^SRC_URI=
SRC_URI="git://git.freescale.com/imx/uboot-imx.git;protocol=git;branch=imx_v2016.03_4.1.15_2.0.0_ga"
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

13、重新编译内核

bitbake -c menuconfig -v linux-imx    //同 make menuconfig 
bitbake linux-imx -C compile  //编译内核
bitbake linux-imx -c compile_kernelmodules -f -v  // 编译内核模块
bitbake -c deploy -f -v linux-imx  //布署到image目录

执行bitbake fsl-image-qt5时会重新生成rootfs

14、单独编译u-boot

bitbake -c compile -f -v u-boot-imx
bitbake -c deploy -f -v u-boot-imx

15、查看可以编译的包

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake -s |grep meta
gst-meta-base                                       :0.10-r13                          
gstreamer1.0-meta-base                                :1.0-r0                          
meta-environment-extsdk-imx6qsabreauto                   :1.0-r8                          
meta-environment-imx6qsabreauto                       :1.0-r8                          
meta-ide-support                                      :1.0-r3                          
meta-toolchain                                        :1.0-r7                          
meta-toolchain-qt5                                    :1.0-r0                          
meta-world-pkgdata                                    :1.0-r0                          
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

16、bitbake meta-toolchain-qt5结果

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake meta-toolchain-qt5
Loading cache: 100% |############################################################| ETA:  00:00:00
Loaded 2792 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.30.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-14.04"
TARGET_SYS        = "arm-poky-linux-gnueabi"
MACHINE           = "imx6qsabreauto"
DISTRO            = "fsl-imx-fb"
DISTRO_VERSION    = "4.1.15-2.1.0"
TUNE_FEATURES     = "arm armv7a vfp  neon        callconvention-hard        cortexa9"
TARGET_FPU        = "hard"
meta              
meta-poky         = "HEAD:f5da2a5913319ad6ac2141438ba1aa17576326ab"
meta-oe           
meta-multimedia   = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-fsl-arm      = "HEAD:be78894e4682f111575470fb23e51e6ba523508d"
meta-fsl-arm-extra = "HEAD:3dfb82fc7e703eae9891b3ffda0e9393701f2396"
meta-fsl-demos    = "HEAD:a165068f8a0d1cf29aabe4b4053f28be1c2aa492"
meta-bsp          
meta-sdk          = "HEAD:823b26a67261270d2bf22d511e6190641a8a90cf"
meta-browser      = "HEAD:77736988073a5d90fcff9d0005c8477332ede387"
meta-gnome        
meta-networking   
meta-python       
meta-filesystems  = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-qt5          = "HEAD:ccae79be69c5268df3b47e4e14cea0591c39a531"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
WARNING: nativesdk-elftosb-10.12.01-r4 do_fetch: Failed to fetch URL http://repository.timesys.com/buildsources/e/elftosb/elftosb-10.12.01/elftosb-10.12.01.tar.gz, attempting MIRRORS if available
NOTE: Tasks Summary: Attempted 3675 tasks of which 2679 didn't need to be rerun and all succeeded.

Summary: There was 1 WARNING message shown.
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ ls tmp/deploy/
images/   licenses/ rpm/      sdk/      
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ ls tmp/deploy/sdk/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.
fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.host.manifest
fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh
fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.target.manifest
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ 

17、bitbake meta-toolchain结果

hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ bitbake meta-toolchain
Loading cache: 100% |#############################################################################| ETA:  00:00:00
Loaded 2792 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.30.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-14.04"
TARGET_SYS        = "arm-poky-linux-gnueabi"
MACHINE           = "imx6qsabreauto"
DISTRO            = "fsl-imx-fb"
DISTRO_VERSION    = "4.1.15-2.1.0"
TUNE_FEATURES     = "arm armv7a vfp  neon        callconvention-hard        cortexa9"
TARGET_FPU        = "hard"
meta              
meta-poky         = "HEAD:f5da2a5913319ad6ac2141438ba1aa17576326ab"
meta-oe           
meta-multimedia   = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-fsl-arm      = "HEAD:be78894e4682f111575470fb23e51e6ba523508d"
meta-fsl-arm-extra = "HEAD:3dfb82fc7e703eae9891b3ffda0e9393701f2396"
meta-fsl-demos    = "HEAD:a165068f8a0d1cf29aabe4b4053f28be1c2aa492"
meta-bsp          
meta-sdk          = "HEAD:823b26a67261270d2bf22d511e6190641a8a90cf"
meta-browser      = "HEAD:77736988073a5d90fcff9d0005c8477332ede387"
meta-gnome        
meta-networking   
meta-python       
meta-filesystems  = "HEAD:247b1267bbe95719cd4877d2d3cfbaf2a2f4865a"
meta-qt5          = "HEAD:ccae79be69c5268df3b47e4e14cea0591c39a531"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 1989 tasks of which 1975 didn't need to be rerun and all succeeded.
hedy@ubuntu:~/fsl-arm-yocto-bsp/build-fb$ ls tmp/deploy/sdk/fsl-imx-fb-glibc-x86_64-meta-toolchain-
fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa9hf-neon-toolchain-4.1.15-2.1.0.host.manifest
fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh
fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa9hf-neon-toolchain-4.1.15-2.1.0.target.manifest
fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.host.manifest
fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.sh
fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0.target.manifest

有用的参考:

https://blog.csdn.net/fei534358549/article/details/50276489
https://blog.csdn.net/cking0906/article/details/76099025
https://blog.csdn.net/encourage2011/article/details/72454582
https://blog.csdn.net/rocky_zhm/article/details/4826665
https://blog.csdn.net/woyimibayi/article/details/52788790

yocto实用技巧:
https://blog.csdn.net/sy373466062/column/info/yocto
imx6q 编译下载指南:
https://blog.csdn.net/wince_lover/article/details/51456745

CSDN bitbake 使用指南
https://blog.csdn.net/lu_embedded/article/details/80634368

Yocto实用技巧
https://www.kancloud.cn/digest/yocto/138628

http://blog.sina.com.cn/s/blog_7880d3350102wvio.html
https://www.kancloud.cn/digest/yocto/138623

Yocto Project 上的 BitBake 用户手册:
https://www.yoctoproject.org/docs/1.6/bitbake-user-manual/bitbake-user-manual.html

你可能感兴趣的:(Linux)