Introduction to Advanced features of the OpenEmbedded Build System
in the Yocto Project
Behan Webster
behanw@converseincode.com
The Linux Foundation
Mar 05, 2017
1
Yocto Project/OpenEmbedded
Advanced Course
Yocto Project Dev Day Wifi information
If you want to connect to the Internet:
SSID:
The URL for this presentation
http://bit.ly/2mpHMLu
Yocto Project Overview
4
meta (oe-core)
meta-poky
meta-yocto-bsp
other layers
What is the Yocto Project?
5
Yocto Project Release Versions
6
Name | Revision | Poky | Release Date |
Bernard | 1.0 | 5.0 | Apr 5, 2011 |
Edison | 1.1 | 6.0 | Oct 17, 2011 |
Denzil | 1.2 | 7.0 | Apr 30, 2012 |
Danny | 1.3 | 8.0 | Oct 24, 2012 |
Dylan | 1.4 | 9.0 | Apr 26, 2013 |
Dora | 1.5 | 10.0 | Oct 19, 2013 |
Daisy | 1.6 | 11.0 | Apr 24, 2014 |
Dizzy | 1.7 | 12.0 | Oct 31, 2014 |
Fido | 1.8 | 13.0 | April 22, 2015 |
Jethro | 2.0 | 14.0 | Oct 31, 2015 |
Krogoth | 2.1 | 15.0 | April 29, 2016 |
Morty | 2.2 | 16.0 | Oct 28, 2016 |
Pyro | 2.3 | 17.0 | April, 2017 |
Intro to OpenEmbedded
7
meta (oe-core)
meta-poky
meta-yocto-bsp
Other layers
OK, so what is Poky?
8
Poky in Detail
Yocto is based on OpenEmbedded-core
10
Metadata describing approximately 1000 "core" recipes used for building boot images. Includes support for graphics, Qt, networking, kernel recipes, tools, much more.
Yocto is based on OpenEmbedded-core
11
The Layer Index lists all known layers and allows you to search for:
Ties into other tools like Toaster and the upcoming setup tool
BUILDING A FULL EMBEDDED IMAGE WITH YOCTO
This section will introduce the concept of building an initial system image, which we will be using later...
12
Cheating a Little
$ mkdir $HOME/yocto/
$ cd $HOME/yocto/
$ tar xvf downloads.tar
$ tar xvf sstate-cache.tar
13
Getting a copy of Poky
Download the Yocto Project release “Morty”:
~/$ cd yocto
~/yocto$ git clone -b morty git://git.yoctoproject.org/poky.git
14
Setting up a Build Directory
$ cd $HOME/yocto/
$ source ./poky/oe-init-build-env build
15
Host System Layout
$HOME/yocto/
|---build (or whatever name you choose)
Project build directory
|---downloads (DL_DIR)
Downloaded source cache
|---poky (Do Not Modify anything in here*)
Poky, bitbake, scripts, oe-core, metadata
|---sstate-cache (SSTATE_DIR)
Binary build cache
16
Build directory Layout
$HOME/yocto/build/
|---bitbake.lock
|---cache/ (bitbake cache files)
|---conf/
| |--bblayers.conf (bitbake layers)
| |--local.conf (local configuration)
| `--site.conf (optional site conf)
`---tmp/ (Build artifacts)
17
Note: A few files have been items omitted to facility the presentation on this slide
Using Layers
$HOME/yocto/build/conf/bblayers.conf
BBLAYERS ?= " \
${HOME}/yocto/poky/meta \
${HOME}/yocto/poky/meta-poky \
${HOME}/yocto/poky/meta-yocto-bsp \
"
18
Update Build Configuration
$HOME/yocto/build/conf/local.conf
MACHINE = "beaglebone"
DL_DIR = "${TOPDIR}/../downloads"
SSTATE_DIR = "${TOPDIR}/../sstate-cache"
19
Building an Embedded Image
$ bitbake -k core-image-minimal
20
SD-card installation
$ cd tmp/deploy/images/beaglebone/
$ sudo dd if=core-image-minimal-beaglebone.wic of=/dev/<YourSDCard> bs=1M
$ eject /dev/<YourSDCard>
(YourSDCard will be something like /dev/sdc or /dev/mmcblk0)
21
BEAGLEBONE SETUP
This section will show you how to setup your board
22
BeagleBone Walkthrough
23
Cable installation
24
Boot from external uSD
25
Connect to serial port
$ sudo screen /dev/ttyUSB0 115200
26
Board Support packages
This section will introduce the concept of board support packages
27
Board Support Packages
28
Board Support Packages (2)
29
Board Support Packages (3)
meta-mybsp/conf/machine/mybsp.conf
30
Board Support Packages (4)
$ yocto-bsp list karch
$ yocto-bsp create boardfoo arm
31
The yocto-kernel tool
32
Yocto Kernels
This section will introduce the concept of kernel recipes
33
Booting Your Image with QEMU
34
Yocto Project Release | Kernel |
2.0 | linux-yocto-4.1 |
2.1 | linux-yocto-4.4 |
2.2 | linux-yocto-4.8 |
Yocto Kernel branches
35
http://git.yoctoproject.org/
Config fragments
$ cat smp.cfg
CONFIG_SMP=y
36
Default configuration
SRC_URI += defconfig
FILESPATH = "${FILE_DIRNAME}/${PF}:\
${FILE_DIRNAME}/${P}:\
${FILE_DIRNAME}/${PN}: \ ${FILE_DIRNAME}/files:${FILE_DIRNAME}"
37
Config fragments
$ cat smp.cfg
CONFIG_SMP=y
38
menuconfig
“bitbake -c menuconfig linux-yocto”
39
Kernel excercise with menuconfig
$ cd $HOME/yocto
$ source poky/oe-init-build-env build
$ bitbake -c menuconfig linux-yocto
$ bitbake -C compile linux-yocto
$ bitbake core-image-minimal
40
Kernel excercise config fragments
Please enter the layer priority you'd like to use for the layer: [default: 6]
Would you like to have an example recipe created? (y/n) [default: n]
Would you like to have an example bbappend file created? (y/n) [default: n]
New layer created in meta-mylayer.
Don't forget to add it to your BBLAYERS (for details see meta-mylayer/README).
41
Kernel excercise config fragments (2)
Add layer to ${TOPDIR}/conf/bblayers.conf
/home/<USER>/yocto/meta-mylayer \
yocto$ mkdir -p \
meta-mylayer/recipes-kernel/linux
42
Kernel excercise config fragments (2)
$ cd meta-mylayer/recipes-kernel/linux
$ echo ‘CONFIG_LOCALVERSION=“-SCaLE15x”’ \
> localversion.cfg
Create “linux-yocto_4.8.bbappend” containing:
FILESEXTRAPATHS_prepend := "${THISDIR}:"
SRC_URI += "file://localversion.cfg"
43
Kernel excercise with menuconfig
$ bitbake -c clean linux-yocto
$ bitbake core-image-minimal
# uname -r
4.8.12-SCaLE15x
44
wic
This section will introduce the concept of kernel recipes
45
What is wic?
46
And Example .wks file
# short-description: Create SD card image with a boot partition
# long-description: Creates a partitioned SD card image. Boot files
# are located in the first vfat partition.
part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat \
--label boot --active --align 4 --size 16
part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 4
47
Running wic
$ wic create -o OUTPUTFILE \
-e core-image-minimal sdimage-bootpart
48
devtool
This section will introduce devtool
49
devtool
$ devtool add https://github.com/msgpack/msgpack-c.git;tag=cpp-2.1.1
$ devtool edit-recipe msgpack-c
$ devtool build msgpack-c
$ devtool build-image -p msgpack-c core-image-minimal
$ devtool deploy-target msgpack-c beaglebone
$ devtool undeploy-target msgpack-c beaglebone
$ devtool finish msgpack-c meta-mylayer
You can learn more from the yocto documentation:
4.3.1.1. Use devtool add to Add an Application
50
Alternate devtool workflow
$ devtool search <pkgname> or http://layers.openembedded.org
$ devtool modify -x <pkgname> <sourcepath-to-extract-to>
Apply patches to the sources
Commit changes to VCS (git)
$ devtool build <pkgname>
$ devtool build-image <imagename>
$ devtool update-recipe <pkgname>
$ devtool finish <pkgname> <layername>
51
eSDK
This section will introduce the extensible Software Development Kit
52
Building the eSDK
$ bitbake -c populate_sdk_ext core-image-minimal
$ bitbake -c populate_sdk core-image-minimal
53
Building the eSDK
$ bitbake -c populate_sdk_ext core-image-minimal
$ bitbake -c populate_sdk core-image-minimal
54
Installing the eSDK
$ cd tmp/deploy/sdk
$ source ./poky-glibc-x86_64-core-image-minimal-\
cortexa8hf-neon-toolchain-ext-2.2.1.sh
55
Licensing and SPDX
This section will show off the Licensing mechanism in OpenEmbedded
56
Simple licensing
LICENSE = "licname1 licname2"
LIC_FILES_CHECKSUM = "file://COPYING;md5=xxxx \
file://licfile.txt;beginline=5;endline=29;md5=yyyy \
file://src/module.h;endline=45;md5=zzzz \
file://../license.html;md5=aaaa \
..."
core-image-minimal-beaglebone.manifest
57
Simple licensing
LICENSE_FLAGS = "commercial"
LICENSE_FLAGS = "license_${PN}_${PV}�
LICENSE_FILE_WHITELIST = "commercial_gst-plugins-ugly"�LICENSE_FILE_WHITELIST = "commercial"
58
SPDX
59
60
It’s not an Embedded
Linux Distribution
It Creates a
Custom One For You
Embedded Linux Development with Yocto Project
Training from The Linux Foundation
Want to learn how to use Yocto Project like a Pro?
https://training.linuxfoundation.org/
Embedded Linux Platform Development with Yocto Project
TIPS HINTS AND OTHER RESOURCES
The following slides contain reference material that will help you climb the Yocto Project learning curve
62
Common Gotchas When Getting Started
63
Project Resources
64
Tip: ack-grep
65
Tip: ack-grep
66
alias bback='ack-grep --type bitbake'
TIP: VIM Syntax Highlighting
$ tree ~/.vim/
/Users/chris/.vim/
├── ftdetect
│ └── bitbake.vim
├── ftplugin
│ └── bitbake.vim
├── plugin
│ └── newbb.vim
└── syntax
└── bitbake.vim
67
TIP: VIM Syntax Highlighting
68