Yocto 添加layer和创建layer

本文介绍了如何在Yocto项目中查询可用的Layers,添加meta-intel层的过程,以及使用`bitbake-layers`工具进行层管理。还展示了如何创建自己的Layer并将其添加到构建配置中。
摘要由CSDN通过智能技术生成

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

Yocto添加模块的具体步骤如下: 1. 首先要确定需要添加的模块,比如需要添加一个新的 Linux 内核模块。 2. 将模块源代码复制到 Yocto 工程目录下的一个新文件夹中,一般建议将其放在 meta-layer 中。 3. 在 meta-layer 中的 recipes-kernel 目录下创建一个新的文件夹,并在其中创建一个新的 .bb 文件,用于定义如何构建该模块。 4. 在 .bb 文件中添加以下内容: ``` SUMMARY = "A brief description of the module" DESCRIPTION = "A longer description of the module" LICENSE = "License type" LIC_FILES_CHKSUM = "file://LICENSE;md5=..." PR = "r0" SRC_URI = "file://module_source_code.tar.gz" SRC_URI[md5sum] = "md5_hash_value" SRC_URI[sha256sum] = "sha256_hash_value" S = "${WORKDIR}/module_source_code" do_compile() { # Compile the module } do_install() { # Install the module } FILES_${PN} += "/lib/modules/${KERNEL_VERSION}/extra/module_name.ko" ``` 其中,SUMMARY 和 DESCRIPTION 分别为模块的简要描述和详细描述;LICENSE 为模块的许可证类型;LIC_FILES_CHKSUM 为许可证文件的校验和;SRC_URI 为模块源代码的 URL;S 为源代码解压后的路径;do_compile() 和 do_install() 分别为编译和安装模块的函数;FILES_${PN} 定义了需要安装的文件。 5. 修改 meta-layer 中的 conf/layer.conf 文件,将新的 recipes-kernel 目录添加到 BBFILES 中。 ``` BBFILES += " \ ${LAYERDIR}/recipes-*/*/*.bb \ ${LAYERDIR}/recipes-kernel/module_name/module_name.bb \ " ``` 6. 在 Yocto 工程目录中运行 bitbake 命令,构建镜像并将模块添加到镜像中。 ``` $ bitbake core-image-minimal ``` 运行完毕后,可以在构建目录下的 tmp/deploy/images/ 目录中找到生成的镜像文件和模块文件。 以上就是在 Yocto添加模块的基本步骤。需要注意的是,具体操作可能会因为模块类型和版本等不同而有所不同。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值