Yocto實踐(1): 基於Dunfell 構建Yocto專案

csdn1013發表於2020-10-15

因為工作中很多時候需要基於Yocto來改程式碼、編譯SDK,很久之前就想徹底搞明白Yocto的理念、整個構建的細節。

現在開坑,基於Yocto官方文件,以實踐記錄+網路資料整理的方式,希望加深對Yocto的理解。

操作基於2020年4月份發行的3.1版本(Dunfell)。 Yocto的版本release記錄:https://wiki.yoctoproject.org/wiki/Releases

 

系統要求:參考Yocto官方的參考文件https://www.yoctoproject.org/docs/current/brief-yoctoprojectqs/brief-yoctoprojectqs.html PC最好是Linux發行版,要求如下:

硬碟:至少50GB

發行版:最近的Fedora, openSUSE, CentOS, Debian, or Ubuntu

常用工具:

  • Git 1.8.3.1 or greater

  • tar 1.28 or greater

  • Python 3.5.0 or greater.

  • gcc 5.0 or greater.

需要安裝如下軟體包(我用的是Ubuntu 18.04, 以Ubuntu18.04為例。其他發行版請參考上面的連結):

$ 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 libsdl1.2-dev xterm

獲取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資料夾。從這個資料夾裡可以看到Git commit history。你可以在預設的分支上構建你的系統,也可以新建一個分支。如下:

$ git checkout tags/yocto-3.1 -b csdn1013-yocto-3.1
Switched to a new branch 'csdn1013-yocto-3.1'
~/poky$ git branch
* csdn1013-yocto-3.1
  dunfell

開始構建

1. 首先需要初始化編譯環境source oe-init-build-env

~/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>'

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'

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編譯工具可以編譯一些目標image了:

    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

$bitbake core-image-sato

相關文章