编译环境: Ubuntu 18
目的: 通过Yocto项目构建Linux OS,并通过qemu模拟运行.
官方网址: [https://www.yoctoproject.org/]
官方教程: [https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html]
1, 搭建编译环境$ 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-dev2, 下载项目源码
$ git clone git://git.yoctoproject.org/poky3, 初始化环境变量
$ 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 their website:
https://www.openembedded.org/
### Shell environment set up for builds. ###
You can now run 'bitbake '
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
4, 编译
初始化环境变量的时候,我们没有指定目录,相关命令会自动在poky目录下创建默认目录build/,并自动进入此目录,我们根据Step 3的提示信息,执行如下编译命令:
例如,编译最小镜像:
# 编译最小镜像 $ bitbake core-image-minimal
又或者,编译带图形UI镜像:
# 编译带图形界面镜像 $ bitbake core-image-sato
当然,可以都编译,只是会占比较多内存.
Note:
编译过程中会从互联网镜像网站,下载相关package源码的资源,其中有一部分资源,当前国内网络环境无法访问,需要科学上网,嫌麻烦的话,我在本文末尾会陆续提供部分资源的可下载链接,希望可以帮助到有需要的人.
$ runqemu qemux86-64
如果,编译了多个工程,则可以显式指定运行哪个工程,如下:
显式运行:core-image-minimal编译工程:
$ runqemu qemux86-64 core-image-minimal ext4
显式运行:core-image-sato编译工程:
$ runqemu qemux86-64 core-image-sato ext46, 效果
core-image-minimal编译工程(无图形界面),运行效果:
core-image-sato编译工程(有图形界面),运行效果:
相关资源下载链接(任选其一):
1, github # 陆续更新
2, pan.baidu.com # 陆续更新



