Yocto Project Quick Build 翻译

Yocto Project Quick Build 翻译

欢迎

版权所有©2010-2019 Linux基金会

欢迎!这个简短的文档通过Yocto Project帮助您一步步构建一个典型镜像文件,该文件还介绍了如何配置特定的硬件构建环境。您将使用Yocto Project构建一个名为Poky的嵌入式OS。

Linux开发环境

确保您的主机满足以下要求:

  • 可用磁盘空间50个GB
  • 运行受Yocto Project支持的Linux发行版(即Fedora、openSUSE、CentOS、Debian、Ubuntu的发行版)
  • Git 1.8.3.1或更高
  • tar 1.27或更高版本
  • Python 3.4.0或更高版本

安装必要的环境

您必须在主机上安装必要的安装包。下面的命令基于Ubuntu环境:

$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \

build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \

xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \

xterm

使用Git克隆Poky

完成上述安装后,您需要从Poky的仓库中克隆到本地,执行下面的命令:

$ git clone git://git.yoctoproject.org/poky

Cloning into 'poky'...

remote: Counting objects: 432160, done.

remote: Compressing objects: 100% (102056/102056), done.

remote: Total 432160 (delta 323116), reused 432037 (delta 323000)

Receiving objects: 100% (432160/432160), 153.81 MiB | 8.54 MiB/s, done.

Resolving deltas: 100% (323116/323116), done.

Checking connectivity... done.

移动到poky目录,并看看标签:

$ cd poky

$ git fetch --tags

$ git tag

1.1_M1.final

1.1_M1.rc1

1.1_M1.rc2

1.1_M2.final

1.1_M2.rc1

.

.

.

yocto-2.5

yocto-2.5.1

yocto-2.5.2

yocto-2.6

yocto-2.6.1

yocto-2.6.2

yocto-2.7

yocto_1.5_M5.rc8

在这个例子中,检查出的分支是基于yocto-2.7版本:

$ git checkout tags/yocto-2.7 -b my-yocto-2.7

Switched to a new branch 'my-yocto-2.7'

以前的Git的checkout命令创建一个本地分支名为my-yocto-2.7。在该分支提供给您的文件正是在Yocto计划yocto-2.7版本发布时的资料库中的文件相匹配的“warrior”的开发分支。

构建软件包

使用下面的步骤来建立软件包。构建过程创建整个Linux发行版,其中包括工具链、源文件。

初始化构建环境:

从poky目录中,运行 oe-init-build-env

$ cd ~/poky

$ source oe-init-build-env

You had no conf/local.conf file. This configuration file has therefore been

created for you with some default values. You may wish to edit it to, for

example, select a different MACHINE (target hardware). See conf/local.conf

for more information as common configuration options are commented.

You had no conf/bblayers.conf file. This configuration file has therefore been

created for you with some default values. To add additional metadata layers

into your configuration please add entries to conf/bblayers.conf.

The Yocto Project has extensive documentation about OE including a reference

manual which can be found at:

http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:

http://www.openembedded.org/

### Shell environment set up for builds. ###

You can now run 'bitbake <target>'/<target>

Common targets are:

core-image-minimal

core-image-sato

meta-toolchain

meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'

除此之外,该脚本将创建build目录,脚本运行后,您的当前工作目录设置为bulid目录。之后初始化完成后,build目录包含初始化过程中创建的所有文件。

检查您的本地配置文件

当你建立构建环境,build下的子目录conf里一个名为local.conf的配置文件变为可用。对于这个例子,默认被设置为建立一个qemux86目标,这是适合于仿真。

开始构建

使用下面命令构建软件包

$ bitbake core-image-sato

使用QEMU模拟您的软件包

构建这个软件包需要很长的时间,取决于计算机运行速度。一旦这个特定的软件包构建,您就可以开始使用QEMU:

$ runqemu qemux86

退出QEMU

通过在关机图标单击或通过Ctrl-C退出QEMU。

自定义生成支持特定硬件的软件包

到目前为止,所有你做的是迅速建立仅适用于模拟的软件包。本节将展示如何通过添加硬件层到Yocto Project开发环境来定制你的构建来支持特定的硬件。

Notes

按照惯例,层名称开头的字符串“meta-”。

请按照以下步骤添加硬件层:

查找层

已经存在的硬件层有很多。Yocto Project源仓库有许多硬件层。本示例添加 meta-altera层。

克隆层

使用git复制硬件层到本地,您可以把副本创建再Poky文件夹下:

$ cd ~/poky

$ git clone https://github.com/kraj/meta-altera.git

Cloning into 'meta-altera'...

remote: Counting objects: 25170, done.

remote: Compressing objects: 100% (350/350), done.

remote: Total 25170 (delta 645), reused 719 (delta 538), pack-reused 24219

Receiving objects: 100% (25170/25170), 41.02 MiB | 1.64 MiB/s, done.

Resolving deltas: 100% (13385/13385), done.

Checking connectivity... done.

更改配置以建立一个特定的机器

该机在local.conf档案变量指定用于构建的计算机。对于此示例,将设备设定为变量“cyclone5”。这些配置用于:https://github.com/kraj/meta-altera/blob/master/conf/machine/cyclone5.conf。

添加图层的图层配置文件

在构建过程中使用层之前,您必须将它添加到您的bblayers.conf文件,该文件是在发现 build目录下

$ cd ~/poky/build

$ bitbake-layers add-layer ../meta-altera

NOTE: Starting bitbake server... Parsingrecipes:100%|######################################| Time: 0:00:32

Parsing of 918 .bb files complete (0 cached, 918 parsed). 1401 targets, 123 skipped, 0 masked, 0 errors.

完成这些步骤后已经添加了 meta-altera 层到您的Yocto Project开发环境,配置并构建"cyclone5"。

构建属于自己的通用层

也许您需要一个应用程序或一组特定的行为来隔离现有开发环境。您可以通过 bitbake-layers create-layer 命令创建一个通用层. 该工具通过设置带有layer.conf配置文件的子目录,包含example.bb菜谱,许可文件和自述文件的recipes-example子目录,自动创建图层。

$ cd ~/poky

$ bitbake-layers create-layer meta-mylayer

NOTE: Starting bitbake server...

Add your new layer with 'bitbake-layers add-layer meta-mylayer'layer”


构建时间真的是特别特别特别特别长


分享到:


相關文章: