1. 查询可用的Layers
Yocto 提供了很多现成的layer,可以在Layer 索引中查询可用的layer。
OpenEmbedded Layer Index - layers
本节示例添加一个meta-intel的layer, 其对应的git 地址为:git://git.yoctoproject.org/meta-intel
2. 添加一个Layer
我们现在开始准备添加这个meta-intel的layer。
首先初始化poky的环境变量,使得bitbake 命令可用。
$ cd poky
$ source oe-init-build-env
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-full-cmdline
core-image-sato
core-image-weston
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86-64'.
Other commonly useful commands are:
- 'devtool' and 'recipetool' handle common recipe tasks
- 'bitbake-layers' handles common layer tasks
- 'oe-pkgdata-util' handles common target package tasks
用bitbake-layers 查看当前的layer,当前有3个layers。
$ bitbake-layers --help
NOTE: Starting bitbake server...
usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ...
BitBake layers utility
optional arguments:
-d, --debug Enable debug output
-q, --quiet Print only errors
-F, --force Force add without recipe parse verification
--color COLOR Colorize output (where COLOR is auto, always, never)
-h, --help show this help message and exit
subcommands:
<subcommand>
show-layers show current configured layers.
show-overlayed list overlayed recipes (where the same recipe exists in another layer)
show-recipes list available recipes, showing the layer they are provided by
show-appends list bbappend files and recipe files they apply to
show-cross-depends Show dependencies between recipes that cross layer boundaries.
layerindex-fetch Fetches a layer from a layer index along with its dependent layers, and adds them to conf/bblayers.conf.
layerindex-show-depends
Find layer dependencies from layer index.
add-layer Add one or more layers to bblayers.conf.
remove-layer Remove one or more layers from bblayers.conf.
flatten flatten layer configuration into a separate output directory.
save-build-conf Save the currently active build configuration (conf/local.conf, conf/bblayers.conf) as a template into a layer.
create-layer Create a basic layer
create-layers-setup
Writes out a configuration file and/or a script that replicate the directory structure and revisions of the layers in a current build.
Use bitbake-layers <subcommand> --help to get help on a specific command
$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer path priority
========================================================================================================
core /home/mm/Code/poky/meta 5
yocto /home/mm/Code/poky/meta-poky 5
yoctobsp /home/mm/Code/poky/meta-yocto-bsp 5
下载meta-intel的代码,并添加layer
$ cd poky
$ git clone git://git.yoctoproject.org/meta-intel
Cloning into 'meta-intel'...
remote: Enumerating objects: 26925, done.
remote: Counting objects: 100% (123/123), done.
remote: Compressing objects: 100% (117/117), done.
remote: Total 26925 (delta 51), reused 0 (delta 0), pack-reused 26802
Receiving objects: 100% (26925/26925), 6.79 MiB | 1.29 MiB/s, done.
Resolving deltas: 100% (14815/14815), done.
$ cd poky/build
$ bitbake-layers add-layer ../meta-intel/
NOTE: Starting bitbake server...
添加成功后,再次查看layer, 我们能看到meta-intel 已经被添加成功了。
$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer path priority
========================================================================================================
core /home/mm/Code/poky/meta 5
yocto /home/mm/Code/poky/meta-poky 5
yoctobsp /home/mm/Code/poky/meta-yocto-bsp 5
intel /home/mm/Code/poky/meta-intel 5
我们在poky/build/conf/bblayers.conf中也能看到meta-intel layer被添加了进来。
$ cd poky/build
$ cat conf/bblayers.conf
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/home/mm/Code/poky/meta \
/home/mm/Code/poky/meta-poky \
/home/mm/Code/poky/meta-yocto-bsp \
/home/mm/Code/poky/meta-intel \
"
开始编译,能看到这个meta-intel 的layer 也在编译列表中,且其代码在对应的git :master里面。
$ cd poky/build
$ bitbake core-image-minimal
Loading cache: 100% | | ETA: --:--:--
Loaded 0 entries from dependency cache.
Parsing recipes: 100% |#####################################################################################################################################################################| Time: 0:00:41
Parsing of 948 .bb files complete (0 cached, 948 parsed). 1887 targets, 56 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "2.6.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "x86_64-poky-linux"
MACHINE = "qemux86-64"
DISTRO = "poky"
DISTRO_VERSION = "4.3.2"
TUNE_FEATURES = "m64 core2"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "my-nanbield:dbc8727beafe689a99d8b371df98b3c842756065"
meta-intel = "master:69c711ec0af49ff06d97af4f53faa64cfce178a2"
Initialising tasks: 100% |##################################################################################################################################################################| Time: 0:00:02
Checking sstate mirror object availability: 100% |##########################################################################################################################################| Time: 0:01:49
Sstate summary: Wanted 617 Local 0 Mirrors 615 Missed 2 Current 1696 (99% match, 99% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 4897 tasks of which 4897 didn't need to be rerun and all succeeded.
3. 创建一个自己的layer。
$ cd poky
$ bitbake-layers create-layer meta-mylayer
NOTE: Starting bitbake server...
Specified layer directory exists
$ cd build
$ bitbake-layers add-layer ../meta-mylayer/
NOTE: Starting bitbake server...
$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer path priority
========================================================================================================
core /home/mm/Code/poky/meta 5
yocto /home/mm/Code/poky/meta-poky 5
yoctobsp /home/mm/Code/poky/meta-yocto-bsp 5
intel /home/mm/Code/poky/meta-intel 5
meta-mylayer /home/mm/Code/poky/meta-mylayer 6