下载好fsl-release-yocto代码后,就可以开始构建了,根据官方文档,使用命令如下:

$ DISTRO=fsl-imx-fb MACHINE=imx6ull14x14evk source fsl-setup-release.sh -b build

然后会要求阅读EULA,结束后提示按'y'即可。创建build目录作为构建目录,同时准备好相关配置文件。

└── conf
    ├── bblayers.conf
    ├── bblayers.conf.org
    ├── local.conf
    ├── local.conf.org
    ├── local.conf.sample
    └── templateconf.cfg
  • bblayers.conf是当前project包含的所有layer的声明。bblayers.conf.org是备份文件。
  • local.conf是当前project的构建描述声明。local.conf.org是备份文件,local.conf.sample是poky中的默认配置文件。
  • templateconf.cfg是Yocto中用来声明*.conf.sample文件的位置,默认是在poky/meta-poky/conf目录内。

bblayers.conf文件

TOPDIR表示的是构建目录的路径,这里就是build目录的路径。BBPATH表示bitbake查找conf和bb文件的路径。BSPDIR是表示当前project的root路径,里面的FILE='/home/blackrose/i2SOM/fsl-release-bsp/build/conf/bblayers.conf',所以也就明白后面要向上两个目录层级了。

后面就是告诉BBLAYERS有哪些layer是被当前项目引用的。FSL官方为了评估,加入了很多软件包,对于产品开发时,可以自由取舍这些layer。

那个BBFILES变量在加载完这些layer之后,就存储了所有layer中的bb和bbappend文件的路径。

LCONF_VERSION = "6"

BBPATH = "${TOPDIR}"
BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"

BBFILES ?= ""
BBLAYERS = " \
  ${BSPDIR}/sources/poky/meta \
  ${BSPDIR}/sources/poky/meta-yocto \
  \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  \
  ${BSPDIR}/sources/meta-fsl-arm \
  ${BSPDIR}/sources/meta-fsl-arm-extra \
  ${BSPDIR}/sources/meta-fsl-demos \
"
##Freescale Yocto Project Release layer
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-bsp "
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-sdk "
BBLAYERS += " ${BSPDIR}/sources/meta-browser "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-gnome "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-networking "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-python "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-filesystems "
BBLAYERS += " ${BSPDIR}/sources/meta-qt5 "

local.conf文件

同样也是声明了当前project构建时的DISTRO,MACHINE参数。Yocto支持将软件包打包成rpm,deb,ipkg格式,方便其他设备使用软件包,这里选择是rpm格式。

Yocto对IMAGE支持多种特性,具体看官方文档就好了,http://www.yoctoproject.org/docs/2.3.2/mega-manual/mega-manual.html#ref-features-image。

PATCHRESOLVE表示当Yocto在构建时应用patch文件时出错的处理方式。Yocto支持两种noop和user。noop表示不处理直接报错,user表示会启动相应的shell和工具由用户来解决。

BB_DISKMON_DIRS表示Yocto在构建中会占用硬盘空间,这里定义达到阀值的处理方式。书写格式如下:

BB_DISKMON_DIRS = "action,dir,threshold [...]"
  • action: 对于达到阀值时的处理行为,ABORT,STOPTASKS,WARN
  • dir:需要监控的目录
  • threshold:阀值。有两位表示,最小的空间和剩余可用的inode数量。
MACHINE ??= 'imx6ull14x14evk'
DISTRO ?= 'fsl-imx-fb'
PACKAGE_CLASSES ?= "package_rpm"
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats image-mklibs"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS = "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    ABORT,${TMPDIR},100M,1K \
    ABORT,${DL_DIR},100M,1K \
    ABORT,${SSTATE_DIR},100M,1K \
    ABORT,/tmp,10M,1K"
PACKAGECONFIG_append_pn-qemu-native = " sdl"
PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
CONF_VERSION = "1"

DL_DIR ?= "${BSPDIR}/downloads/"
ACCEPT_FSL_EULA = "1"

PACKAGE_CONFIG的这两个表示,分别对qemu-native和nativesdk-qemu启用sdl的配置。

DL_DIR是Yocto从网络下载的软件包源码的存放位置。如果是多个项目构建可以放在项目外面,这样可以用同一份,可以节省硬盘空间。
ACCEPT_FSL_EULA就不多说了,别无选择嘛。

Layers层级关系

Yocto中的每个Layer是有优先级的概念的,由BBFILE_PRIORITY变量来声明。这个除了表征Yocto的核心理念的层级关系,对于相同层的先后顺度也有规定。用数字1~10来表示,10为最高优先级。同优先级时根据bblayers.conf文件定义的先后顺序来判定。

当前project中的层级关系,可以用bitbake-layers来查看。

$ bitbake-layers show-layers
layer                 path                                      priority
==========================================================================
meta                  /home/blackrose/fsl-release-bsp/sources/poky/meta  5
meta-oe               /home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-oe  6
meta-multimedia       /home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-multimedia  6
meta-fsl-arm          /home/blackrose/fsl-release-bsp/sources/meta-fsl-arm  5
meta-fsl-arm-extra    /home/blackrose/fsl-release-bsp/sources/meta-fsl-arm-extra  4
meta-fsl-demos        /home/blackrose/fsl-release-bsp/sources/meta-fsl-demos  4
meta-bsp              /home/blackrose/fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp  8
meta-sdk              /home/blackrose/fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk  8
meta-browser          /home/blackrose/fsl-release-bsp/sources/meta-browser  7
meta-gnome            /home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-gnome  7
meta-networking       /home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-networking  5
meta-python           /home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-python  7
meta-filesystems      /home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-filesystems  6
meta-qt5              /home/blackrose/fsl-release-bsp/sources/meta-qt5  7

我们重新整理下这个层级关系

Priority | Layer | Path
-------- | ----- | ----
8 | meta-bsp | fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp
8 | mets-sdk | fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk
7 | meta-browser | fsl-release-bsp/sources/meta-browser
7 | meta-gnome | fsl-release-bsp/sources/meta-openembedded/meta-gnome
7 | meta-python | fsl-release-bsp/sources/meta-openembedded/meta-python
7 | meta-qt5 | fsl-release-bsp/sources/meta-qt5
6 | meta-oe | fsl-release-bsp/sources/meta-openembedded/meta-oe
6 | meta-multimedia | fsl-release-bsp/sources/meta-openembedded/meta-multimedia
6 | meta-filesystems | fsl-release-bsp/sources/meta-openembedded/meta-filesystems
5 | meta | fsl-release-bsp/sources/poky/meta
5 | meta-fsl-arm | fsl-release-bsp/sources/meta-fsl-arm
5 | meta-networking | fsl-release-bsp/sources/meta-openembedded/meta-networking
4 | meta-fsl-arm-extra | fsl-release-bsp/sources/meta-fsl-arm-extra
4 | meta-fsl-demos | fsl-release-bsp/sources/meta-fsl-demos

这个层级表也符合BBLAYERS变量中的顺序。这个表在后面分析时起到帮助作用,也就可以理解很多bbappend是从哪个bb扩展或inherit的了。

BBLAYERS=" /home/blackrose/fsl-release-bsp/sources/poky/meta
/home/blackrose/fsl-release-bsp/sources/poky/meta-yocto
/home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-oe 
/home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-multimedia 
/home/blackrose/fsl-release-bsp/sources/meta-fsl-arm 
/home/blackrose/fsl-release-bsp/sources/meta-fsl-arm-extra 
/home/blackrose/fsl-release-bsp/sources/meta-fsl-demos

/home/blackrose/fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp
/home/blackrose/fsl-release-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk
/home/blackrose/fsl-release-bsp/sources/meta-browser
/home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-gnome
/home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-networking
/home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-python
/home/blackrose/fsl-release-bsp/sources/meta-openembedded/meta-filesystems
/home/blackrose/fsl-release-bsp/sources/meta-qt5 "