yocto环境没了,重新构建一下。说来惭愧,先写了后面的文章,才来补环境搭建~~~
文章参考官方手册:https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html
准备环境
我的系统是ubuntu20.04,执行以下命令安装依赖包。
sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool
其他发行版环境依赖可查看这个网址。
提醒:后续所有操作均不需要root权限!!!后续所有操作均不需要root权限!!!后续所有操作均不需要root权限!!!
选择yocto版本
1.下载需要使用Git,配置方法网上有太多教程了,自行百度一下。
2.找个空闲的目录下载yocto。
mkdir yocto
cd yocto
git clone git://git.yoctoproject.org/poky
3.选择一个长期支持的版本,点击这个网站查看。
上图可以看到后续稳定支持的版本所有三个,我们选择一个新的,即kirkstone版本。
注意:新版本的yocto语法有些改动,比如操作符分割不再使用下划线_
了,而是使用:
符号,在编写yocto配方时候需要特别注意!!!
cd poky
git branch -a #查看所有分支
git checkout -t origin/kirkstone -b my-kirkstone #选择kirstone分支
后续如果需要更新yocto的话执行:
git pull
构建yocto
$ 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:
https://docs.yoctoproject.org
For more information about OpenEmbedded see the website:
https://www.openembedded.org/
### 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'
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
source oe-init-build-env
命令将设置环境变量,这意味着每次打开新的终端都需要执行它。由于没有设置MACHINE
,默认为qemux86
。
开始构建吧。
bitbake core-image-sato
第一次编译时间取决于编译设备和网络,一般需要2小时左右,后续再次编译就会很快了。
依赖出错
编译刚开始可能会提示依赖包未安装,安装相应依赖即可。还有可能提示依赖版本不对,这样就需要移除之前的依赖包,再安装新版本依赖。
下载出错
第一次构建需要非常长的时间,因为我们前面下载的yocto工程只是一些配置文件(配方文件),没有源码包的,所以第一次构建时要去下载源码包,这也意味着可能下载失败。
下载失败可能存在一下情况:
1)你当前的网络无法访问对应的URL。
2)代理有问题。
3)对应的URL就是失效了。
4)当前ubuntu软件源有问题,尽量使用学校的源,比如清华源。
注意
安装过程中如果想要强制停止,尽量只按一下 Ctrl + c
,之后yocto会结束后续的任务,但会把当前编译的任务完成。如果多次按Ctrl + c
将会强制停止yocto,这样容易导致下次无法编译,但一般只需去build目录下删除*.sock和*.lcok文件即可,如下:
$ ls build/
bitbake-cookerdaemon.log bitbake.lock bitbake.sock cache conf downloads hashserve.sock sstate-cache tmp
运行
编译完成后如下所示:
runqemu qemux86-64
然后会看到一个弹窗,如下图所示:
启动完成之后,就进入了yocto编译出来的系统了,不过。。。有点卡~~~
常见问题
有个中文网址(参考使用,非yocto官方),里面汇总了各类常见问题,详情查阅网址。
当然,官方也有一个网站,但是这个网站是英文的,点击网站。