Welcome to the Yocto Project Summit 2023.11
The beginner class will start at 12:30 UTC
The slides for this presentation → http://bit.ly/3sS8Jf6
The URL for this presentation
Intro to Yocto Project
https://bit.ly/3sS8Jf6
bit.ly/3sS8Jf6
Creating a Custom Embedded Linux Distribution for Any Embedded Device Using the Yocto Project
Behan Webster
Tom King
The Linux Foundation
November 29, 2023
(CC BY-SA 4.0)
3
Yocto Project Summit 2023.11
Intro to Yocto Project
bit.ly/3sS8Jf6
Yocto Project Overview
4
meta (oe-core)
meta-poky
meta-yocto-bsp
other layers
bit.ly/3sS8Jf6
What is the Yocto Project?
5
bit.ly/3sS8Jf6
Yocto Project Governance
6
bit.ly/3sS8Jf6
Yocto Project Member Organizations
PLATINUM MEMBERS
GOLD MEMBERS
SILVER MEMBERS
bit.ly/3sS8Jf6
Yocto Project Overview
8
bit.ly/3sS8Jf6
Yocto Project Release Versions
9
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 | Apr 22, 2015 |
Jethro | 2.0 | 14.0 | Oct 31, 2015 |
Krogoth | 2.1 | 15.0 | Apr 29, 2016 |
Morty | 2.2 | 16.0 | Oct 28, 2016 |
Pyro | 2.3 | 17.0 | Apr, 2017 |
Rocko | 2.4 | 18.0 | Oct, 2017 |
Name | Revision | Poky | Release Date |
Sumo | 2.5 | 19.0 | Apr, 2018 |
Thud | 2.6 | 20.0 | Oct, 2018 |
Warrior | 2.7 | 21.0 | Apr, 2019 |
Zeus | 3.0 | 22.0 | Oct, 2019 |
Dunfell (LTS) | 3.1 | 23.0 | Apr, 2020 |
Gatesgarth | 3.2 | | Oct, 2020 |
Hardknott | 3.3 | | Apr, 2021 |
Honister | 3.4 | | Oct, 2021 |
Kirkstone (LTS) | 4.0 | | Apr, 2022 |
Langdale | 4.1 | | Oct, 2022 |
Mickledore | 4.2 | | Apr, 2023 |
Nanbield | 4.3 | | Oct, 2023 |
Scarthgap | 5.0 | | Apr, 2024 |
bit.ly/3sS8Jf6
Yocto is based on OpenEmbedded-core
10
Metadata describing approximately 800 "core" recipes used for building boot images. Includes support for graphics, networking, kernel recipes, tools, much more.
bit.ly/3sS8Jf6
Intro to OpenEmbedded
11
bit.ly/3sS8Jf6
What is Bitbake?
12
Metadata – a structured collection of "recipes" which tell BitBake what to build, organized in layers
bit.ly/3sS8Jf6
meta (oe-core)
meta-poky
meta-yocto-bsp
Other layers
OK, so what is Poky?
13
bit.ly/3sS8Jf6
Poky in Detail
bit.ly/3sS8Jf6
Putting It All Together
15
bit.ly/3sS8Jf6
Build System Workflow
16
http://bit.ly/YPS202105Intro
bit.ly/3sS8Jf6
BITBAKE
This section will introduce the concept of the bitbake build tool and how it can be used to build recipes
17
bit.ly/3sS8Jf6
Metadata and bitbake
busybox
glibc
sysvinit
coreutils
libgtk
Metadata
BitBake
bit.ly/3sS8Jf6
What is Metadata?
bit.ly/3sS8Jf6
Other Metadata
bit.ly/3sS8Jf6
OE-CORE Breakdown
21
*.bb: 839
packagegroup*: 25
*.bbclass: 210
*.conf: 72
*.inc: 300
core-image-*: 20
bit.ly/3sS8Jf6
Introduction to Bitbake
$ bitbake myrecipe
$ bitbake -c clean myrecipe�$ bitbake -c cleanall myrecipe
$ bitbake -c listtasks myrecipe
bit.ly/3sS8Jf6
Building Recipes
$ bitbake myrecipe
$ bitbake myrecipe-1.0
$ bitbake myrecipe-1.0-r0
$ bitbake -b mydir/myrecipe.bb
bit.ly/3sS8Jf6
Running bitbake for the First Time
$ bitbake -k core-image-minimal
$ bitbake core-image-minimal
bit.ly/3sS8Jf6
Bitbake is a Task Scheduler
$ bitbake recipe
25
bit.ly/3sS8Jf6
Recipe Basics – Default Tasks*
Create binary package(s)
do_fetch
do_unpack
do_patch
do_configure
do_install
do_compile
*Simplified for illustration
Note: to see the list of all possible tasks for a recipe, do this:
$ bitbake -c listtasks <recipe_name>
do_populate_sysroot
do_package_*
Locate and download source code
Unpack source into working directory
Apply any patches
Perform any necessary pre-build configuration
Compile the source code
Installation of resulting build artifacts in WORKDIR
Copy artifacts to sysroot
bit.ly/3sS8Jf6
Simple recipe task list*
27
*Simplified for illustration
$ bitbake hello
NOTE: Running task 337 of 379 (ID: 4, hello_1.0.0.bb, do_fetch)
NOTE: Running task 368 of 379 (ID: 0, hello_1.0.0.bb, do_unpack)
NOTE: Running task 369 of 379 (ID: 1, hello_1.0.0.bb, do_patch)
NOTE: Running task 370 of 379 (ID: 5, hello_1.0.0.bb, do_configure)
NOTE: Running task 371 of 379 (ID: 7, hello_1.0.0.bb, do_populate_lic)
NOTE: Running task 372 of 379 (ID: 6, hello_1.0.0.bb, do_compile)
NOTE: Running task 373 of 379 (ID: 2, hello_1.0.0.bb, do_install)
NOTE: Running task 374 of 379 (ID: 11, hello_1.0.0.bb, do_package)
NOTE: Running task 375 of 379 (ID: 3, hello_1.0.0.bb, do_populate_sysroot)
NOTE: Running task 376 of 379 (ID: 8, hello_1.0.0.bb, do_packagedata)
NOTE: Running task 377 of 379 (ID: 12, hello_1.0.0.bb, do_package_write_ipk)
NOTE: Running task 378 of 379 (ID: 9, hello_1.0.0.bb, do_package_qa)
*Output has been formatted to fit this slide.
bit.ly/3sS8Jf6
SSTATE CACHE
28
do_packagedata | Creates package metadata used by the build system to generate the final packages |
do_package | Analyzes the content of the holding area and splits it into subsets based on available packages and files |
do_package_write_rpm | Creates the actual RPM packages and places them in the Package Feed area |
do_populate_lic | Writes license information for the recipe that is collected later when the image is constructed |
do_populate_sysroot | Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes |
bit.ly/3sS8Jf6
Simple recipe build from sstate cache*
29
*Simplified for illustration
$ bitbake -c clean hello
$ bitbake hello
NOTE: Running setscene task 69 of 74 (hello_1.0.0.bb, do_populate_sysroot_setscene)
NOTE: Running setscene task 70 of 74 (hello_1.0.0.bb, do_populate_lic_setscene)
NOTE: Running setscene task 71 of 74 (hello_1.0.0.bb, do_package_qa_setscene)
NOTE: Running setscene task 72 of 74 (hello_1.0.0.bb, do_package_write_ipk_setscene)
NOTE: Running setscene task 73 of 74 (hello_1.0.0.bb, do_packagedata_setscene)
*Output has been formatted to fit this slide.
bit.ly/3sS8Jf6
RECIPES
This section will introduce the concept of metadata and recipes and how they can be used to automate the building of packages
30
bit.ly/3sS8Jf6
What is a Recipe?
31
bit.ly/3sS8Jf6
Example Recipe – ethtool_3.15.bb
32
bit.ly/3sS8Jf6
What can a Recipe Do?
33
bit.ly/3sS8Jf6
Recipe Operators
A = “foo” (late assignment)
B ?= “0t” (default value)
C ??= “abc” (late default)
D := “xyz” (Immediate assignment)
A .= “bar” “foobar” (append)
B =. “W0” “W00t” (prepend)
C += “def” “abc def” (append)
D =+ “uvw” “uvw xyz” (prepend)
34
bit.ly/3sS8Jf6
More Recipe Operators
A = “foo”
A:append = “bar” “foobar”
B = “0t”
B:prepend = “W0” “W00t”
A:remove = “oob” “far”
B:remove = “00” “Wt”
35
bit.ly/3sS8Jf6
Recipe Override Operators
OVERRIDES = “os:arch:machine”
A = “abc”
A:os = “ABC” (Override)
A:append:arch = “def” (Conditional append)
A:prepend:os = “XYZ” (Conditional prepend)
36
bit.ly/3sS8Jf6
Unsetting Variables
unset DATE (unset Variable)
unset do_fetch[noexec] (unset task attribute)
37
bit.ly/3sS8Jf6
Bitbake Variables/Metadata
38
bit.ly/3sS8Jf6
Build Time Metadata
39
bit.ly/3sS8Jf6
Build Time Metadata
40
bit.ly/3sS8Jf6
Dependency Metadata
41
bit.ly/3sS8Jf6
Common Metadata
42
bit.ly/3sS8Jf6
Examining Recipes: bc
poky/meta/recipes-extended/bc/bc_1.06.bb
43
bit.ly/3sS8Jf6
Examining Recipes: bc_1.6.bb
SUMMARY = "Arbitrary precision calculator language"
HOMEPAGE = "http://www.gnu.org/software/bc/bc.html"
LICENSE = "GPLv2+ & LGPLv2.1"
LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
file://COPYING.LIB;md5=d8045f3b8f929c1cb29a1e3fd737b499 \
file://bc/bcdefs.h;endline=31;md5=46dffdaf10a99728dd8ce358e45d46d8 \
file://dc/dc.h;endline=25;md5=2f9c558cdd80e31b4d904e48c2374328 \
file://lib/number.c;endline=31;md5=99434a0898abca7784acfd36b8191199"
SECTION = "base"
DEPENDS = "flex"
SRC_URI = " ${GNU_MIRROR}/bc/bc-${PV}.tar.gz \
file://fix-segment-fault.patch "
SRC_URI[sha256sum] = "4ef6d9f17c3c0d92d8798e35666175ecd3d8efac4009d6457b5c99cea72c0e33"
inherit autotools texinfo update-alternatives
ALTERNATIVE_${PN} = "dc"
ALTERNATIVE_PRIORITY = "100"
BBCLASSEXTEND = "native"
44
bit.ly/3sS8Jf6
Building upon bbclass
inherit autotools
45
bit.ly/3sS8Jf6
Examining Recipes: flac
poky/meta/recipes-multimedia/flac/flac_1.3.2.bb
46
bit.ly/3sS8Jf6
Examining Recipes: flac.bb
SUMMARY = "Free Lossless Audio Codec"
DESCRIPTION = "FLAC stands for Free Lossless Audio Codec, a lossless audio compression format."
HOMEPAGE = "https://xiph.org/flac/"
BUGTRACKER = "http://sourceforge.net/p/flac/bugs/"
SECTION = "libs"
LICENSE = "GFDL-1.2 & GPLv2+ & LGPLv2.1+ & BSD"
LIC_FILES_CHKSUM = "file://COPYING.FDL;md5=ad1419ecc56e060eccf8184a87c4285f \
file://src/Makefile.am;beginline=1;endline=17;md5=09501c864f89dfc7ead65553129817ca \
file://COPYING.GPL;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
file://src/flac/main.c;beginline=1;endline=18;md5=09777e2934947a36f13568d0beb81199 \
file://COPYING.LGPL;md5=fbc093901857fcd118f065f900982c24 \
file://src/plugin_common/all.h;beginline=1;endline=18;md5=f56cb4ba9a3bc9ec6102e8df03215271 \
file://COPYING.Xiph;md5=b59c1b6d7fc0fb7965f821a3d36505e3 \
file://include/FLAC/all.h;beginline=65;endline=70;md5=64474f2b22e9e77b28d8b8b25c983a48"
DEPENDS = "libogg"
SRC_URI = "http://downloads.xiph.org/releases/flac/${BP}.tar.xz"
SRC_URI[sha256sum] = "91cfc3ed61dc40f47f050a109b08610667d73477af6ef36dcad31c31a4a8d53f"
(con't next page)
47
bit.ly/3sS8Jf6
Examining Recipes: flac.bb (con't)
(con't from previous page)
CVE_PRODUCT = "libflac"
inherit autotools gettext
EXTRA_OECONF = "--disable-oggtest \
--with-ogg-libraries=${STAGING_LIBDIR} \
--with-ogg-includes=${STAGING_INCDIR} \
--disable-xmms-plugin \
--without-libiconv-prefix \
ac_cv_prog_NASM=’’ \
"
EXTRA_OECONF += "${@bb.utils.contains("TUNE_FEATURES", "altivec", " --enable-altivec", " --disable-altivec", d)}"
EXTRA_OECONF += "${@bb.utils.contains("TUNE_FEATURES", "core2", " --enable-sse", "", d)}"
EXTRA_OECONF += "${@bb.utils.contains("TUNE_FEATURES", "corei7", " --enable-sse", "", d)}"
PACKAGES += "libflac libflac++ liboggflac liboggflac++"
FILES_${PN} = "${bindir}/*"
FILES_libflac = "${libdir}/libFLAC.so.*"
FILES_libflac++ = "${libdir}/libFLAC++.so.*"
FILES_liboggflac = "${libdir}/libOggFLAC.so.*"
FILES_liboggflac++ = "${libdir}/libOggFLAC++.so.*"
48
bit.ly/3sS8Jf6
Grouping Local Metadata
include file.inc
require file.inc
49
bit.ly/3sS8Jf6
Examining Recipes: ofono
poky/meta/recipes-connectivity/ofono/ofono_1.19.bb
50
bit.ly/3sS8Jf6
Examining Recipes: ofono.bb
require ofono.inc
SRC_URI = "\
${KERNELORG_MIRROR}/linux/network/${BPN}/${BP}.tar.xz \
file://ofono \
"
SRC_URI[md5sum] = "a5f8803ace110511b6ff5a2b39782e8b"
SRC_URI[sha256sum] = "a0e09bdd8b53b8d2e4b54f1863ecd9aebe4786477a6cbf8f655496e8edb31c81"
CFLAGS:append:libc-uclibc = " -D_GNU_SOURCE"
51
bit.ly/3sS8Jf6
Examining Recipes: ofono.inc
HOMEPAGE = "http://www.ofono.org"
SUMMARY = "open source telephony"
DESCRIPTION = "oFono is a stack for mobile telephony devices on Linux. oFono supports speaking to telephony devices through specific drivers, or with generic AT commands."
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a \
file://src/ofono.h;beginline=1;endline=20;md5=3ce17d5978ef3445def265b98899c2ee"
inherit autotools pkgconfig update-rc.d systemd bluetooth
DEPENDS = "dbus glib-2.0 udev mobile-broadband-provider-info"
INITSCRIPT_NAME = "ofono"
INITSCRIPT_PARAMS = "defaults 22"
PACKAGECONFIG ??= "\
${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \
"
PACKAGECONFIG[systemd] = "--with-systemdunitdir=${systemd_unitdir}/system/,--with-systemdunitdir="
PACKAGECONFIG[bluez] = "--enable-bluetooth, --disable-bluetooth, ${BLUEZ}"
(con't next page)
52
bit.ly/3sS8Jf6
Examining Recipes: ofono.inc
(con't from previous page)
EXTRA_OECONF += "--enable-test"
SYSTEMD_SERVICE_${PN} = "ofono.service"
do_install:append() {
install -d ${D}${sysconfdir}/init.d/
install -m 0755 ${WORKDIR}/ofono ${D}${sysconfdir}/init.d/ofono
# Ofono still has one test tool that refers to Python 2 in the shebang
sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/ofono/test/set-ddr
}
PACKAGES =+ "${PN}-tests"
RDEPENDS_${PN} += "dbus"
RRECOMMENDS_${PN} += "kernel-module-tun mobile-broadband-provider-info"
FILES_${PN} += "${systemd_unitdir}"
FILES_${PN}-tests = "${libdir}/${BPN}/test"
RDEPENDS_${PN}-tests = "python3 python3-pygobject python3-dbus"
53
bit.ly/3sS8Jf6
WHEN THINGS GO WRONG
Some useful tools to help guide you when something goes wrong
54
bit.ly/3sS8Jf6
Bitbake Environment
bit.ly/3sS8Jf6
Examine a Recipe's Environment
$ bitbake -e myrecipe
$ bitbake -e virtual/kernel | grep “^S=”
S="${HOME}/yocto/build/tmp/work-shared/qemuarm/kernel-source"
$ bitbake -e netbase | grep “^FILE=”
FILE="${HOME}/yocto/poky/meta/recipes-core/netbase/netbase_5.3.bb"
56
bit.ly/3sS8Jf6
Examine a Recipe's Environment (cont'd)
$ bitbake -e netbase | grep “^PF=”
PF="netbase-1_5.3-r0"
$ bitbake -e virtual/kernel | grep “^B=”
B="${HOME}/yocto/build/tmp/work/qemuarm-poky-linux-\
gnueabi/linux-yocto/3.19.2+gitAUTOINC+9e70b482d3\
_473e2f3788-r0/linux-qemuarm-standard-build"
$ bitbake -e virtual/kernel | grep “^PACKAGES=”
PACKAGES="kernel kernel-base kernel-vmlinux kernel-image \ kernel-dev kernel-modules kernel-devicetree"
57
bit.ly/3sS8Jf6
BitBake Log Files
$ cat tmp/log/cooker/qemuarm/20160119073325.log | grep 'NOTE:.*task.*Started'
NOTE: recipe hello-1.0.0-r0: task do_fetch: Started
NOTE: recipe hello-1.0.0-r0: task do_unpack: Started
NOTE: recipe hello-1.0.0-r0: task do_patch: Started
NOTE: recipe hello-1.0.0-r0: task do_configure: Started
NOTE: recipe hello-1.0.0-r0: task do_populate_lic: Started
NOTE: recipe hello-1.0.0-r0: task do_compile: Started
NOTE: recipe hello-1.0.0-r0: task do_install: Started
NOTE: recipe hello-1.0.0-r0: task do_populate_sysroot: Started
NOTE: recipe hello-1.0.0-r0: task do_package: Started
NOTE: recipe hello-1.0.0-r0: task do_packagedata: Started
NOTE: recipe hello-1.0.0-r0: task do_package_write_rpm: Started
NOTE: recipe hello-1.0.0-r0: task do_package_qa: Started
NOTE: recipe ypdd-image-1.0-r0: task do_rootfs: Started
58
bit.ly/3sS8Jf6
BitBake Per-Recipe Log Files
$ bitbake -e hello | grep “^T=”
T="${HOME}yocto/build/tmp/work/armv5e-poky-linux-gnueabi/hello/1.0.0-r0/temp"
${WORKDIR}/temp
59
bit.ly/3sS8Jf6
BitBake Per-Recipe Log Files
$ cd ${T} (See definition of T in previous slide)
$ find . -type l -name 'log.*'
./log.do_package_qa
./log.do_package_write_rpm
./log.do_package
./log.do_fetch
./log.do_populate_lic
./log.do_install
./log.do_configure
./log.do_unpack
./log.do_populate_sysroot
./log.do_compile
./log.do_packagedata
./log.do_patch
60
These files contain the output of the respective tasks for each recipe
bit.ly/3sS8Jf6
BitBake Per-Recipe Log Files
$ cd ${T} (See definition of T in previous slide)
$ find . -type l -name 'run.*'
./run.do_fetch
./run.do_patch
./run.do_configure
./run.do_populate_sysroot
./run.do_package_qa
./run.do_unpack
./run.do_compile
./run.do_install
./run.do_packagedata
./run.do_populate_lic
./run.do_package
./run.do_package_write_rpm
61
These files contain the commands executed which produce the build results
bit.ly/3sS8Jf6
BUILDING A FULL EMBEDDED IMAGE WITH YOCTO
This section will introduce the concept of building an initial system image
62
bit.ly/3sS8Jf6
Quick Start Guide in one Slide
$ git clone -b kirkstone git://git.yoctoproject.org/poky.git
$ source poky/oe-init-build-env mybuild
mybuild$ bitbake -k core-image-minimal
mybuild$ runqemu qemux86
63
bit.ly/3sS8Jf6
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
64
* We will cover how to use layers to make changes later
bit.ly/3sS8Jf6
oe-core (meta)
meta-poky
meta-yocto-bsp
Poky Layout
$HOME/yocto/poky/
|---LICENSE
|---README
|---README.hardware
|---bitbake/ (The build tool)
|---documentation/
|---meta/ (oe-core)
|---meta-poky/ (Yocto distro metadata)
|---meta-yocto-bsp/ (Yocto Reference BSPs)
|---oe-init-build-env (Project setup script)
|---scripts/ (Scripts and utilities)
65
Note: A few files have been items omitted to facility the presentation on this slide
bit.ly/3sS8Jf6
Setting up a Build Directory
$ cd $HOME/yocto/
$ source ./poky/oe-init-build-env build
66
bit.ly/3sS8Jf6
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)
67
Note: A few files have been items omitted to facility the presentation on this slide
bit.ly/3sS8Jf6
Building a Linux Image
68
bit.ly/3sS8Jf6
Update Build Configuration
$HOME/yocto/build/conf/local.conf
MACHINE = "qemuarm"
DL_DIR = "${TOPDIR}/../downloads"
SSTATE_DIR = "${TOPDIR}/../sstate-cache/${MACHINE}"
69
bit.ly/3sS8Jf6
Building an Embedded Image
$ bitbake -k core-image-minimal
70
bit.ly/3sS8Jf6
Booting Your Image with QEMU
$ runqemu qemuarm [nographic]
$ killall qemu-system-arm
71
bit.ly/3sS8Jf6
LAYERS
This section will introduce the concept of layers and how important they are in the overall build architecture
72
bit.ly/3sS8Jf6
Layers
73
bit.ly/3sS8Jf6
Layer Hierarchy
74
meta (oe-core)
meta-poky
BSP layer
UI/GUI layer
Commercial layers (OSV or middleware)
Developer layer(s)
bit.ly/3sS8Jf6
Using Layers
$HOME/yocto/build/conf/bblayers.conf
BBLAYERS ?= " \
${HOME}/yocto/poky/meta \
${HOME}/yocto/poky/meta-poky \
${HOME}/yocto/poky/meta-yocto-bsp \
"
75
bit.ly/3sS8Jf6
Board Support Packages
76
bit.ly/3sS8Jf6
Notes on using Layers
77
bit.ly/3sS8Jf6
Creating a Custom Layer
$ bitbake-layers create-layer meta-ypdd
78
bit.ly/3sS8Jf6
Create a Custom Layer
$ cd yocto
yocto$ source poky/oe-init-build-env build
yocto/build$ bitbake-layers create ypdd
Please enter the layer priority you'd like to use for the layer: [default: 6] 6
Would you like to have an example recipe created? (y/n) [default: n] y
Please enter the name you'd like to use for your example recipe: [default: example] example
Would you like to have an example bbappend file created? (y/n) [default: n] n
New layer created in meta-ypdd.
Don't forget to add it to your BBLAYERS (for details see meta-ypdd\README).
yocto/build$
79
bit.ly/3sS8Jf6
The new Custom Layer
yocto/build$ tree meta-ypdd
meta-ypdd/
|--COPYING.MIT (The license file)
|--README (Starting point for README)
|--conf
| `--layer.conf (Layer configuration file)
`--recipes-example (A grouping of recipes)
`--example (The example package)
|--example-0.1 (files for v0.1 of example)
| |--example.patch
| `--helloworld.c
`--example_0.1.bb (The example recipe)
80
bit.ly/3sS8Jf6
Layer.conf
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "ypdd"
BBFILE_PATTERN_ypdd = "^${LAYERDIR}/"
BBFILE_PRIORITY_ypdd = "6"
81
bit.ly/3sS8Jf6
Adding Layers to Your Build
BBLAYERS ?= " \
${HOME}/yocto/poky/meta \
${HOME}/yocto/poky/meta-poky \
${HOME}/yocto/poky/meta-yocto-bsp \
${HOME}/yocto/build/meta-ypdd \
“
82
bit.ly/3sS8Jf6
Adding Layers to Your Build
> bitbake-layers --help
usage: bitbake-layers [-d] [-q] [--color COLOR] [-h] <subcommand> ...
BitBake layers utility
optional arguments:
-d, --debug Enable debug output
-q, --quiet Print only errors
--color COLOR Colorize output (where COLOR is auto, always, never)
-h, --help show this help message and exit
subcommands:
<subcommand>
layerindex-fetch Fetches a layer from a layer index along with its
dependent layers, and adds them to conf/bblayers.conf.
layerindex-show-depends
Find layer dependencies from layer index.
add-layer Add a layer to bblayers.conf.
remove-layer Remove a layer from bblayers.conf.
flatten flatten layer configuration into a separate output
directory.
show-layers show current configured layers.
show-overlayed list overlayed recipes (where the same recipe exists
in another layer)
show-recipes list available recipes, showing the layer they are
provided by
show-appends list bbappend files and recipe files they apply to
show-cross-depends Show dependencies between recipes that cross layer
boundaries.
83
bit.ly/3sS8Jf6
layers.openembedded.org
84
bit.ly/3sS8Jf6
Adding Layers to Your Build
bitbake-layers add-layer \
${HOME}/yocto/build/meta-ypdd
85
bit.ly/3sS8Jf6
Build Your New Recipe
$ bitbake example
meta-ypdd/recipes-example/example/example_0.1.bb
Note: Build fails w/o ${CFLAGS} and ${LDFLAGS} meanwhile (QA-error) in the recipe.
86
bit.ly/3sS8Jf6
IMAGES
This section will introduce the concept of images; recipes which build embedded system images
87
bit.ly/3sS8Jf6
What is an Image?
88
bit.ly/3sS8Jf6
Extending an Image
89
bit.ly/3sS8Jf6
A Simple Image Recipe
$ mkdir -p ${HOME}/yocto/build/meta-ypdd/recipes-core/images
$ vi ${HOME}/yocto/build/meta-ypdd/recipes-core/images/ypdd-image.bb
DESCRIPTION = "A core image for YPDD"
LICENSE = "MIT"
# Core files for basic console boot
IMAGE_INSTALL = "packagegroup-core-boot"
# Add our desired packages
IMAGE_INSTALL += "psplash dropbear"
inherit core-image
IMAGE_ROOTFS_SIZE ?= "8192"
90
bit.ly/3sS8Jf6
Build and Boot Your Custom Image
(example in the next slide)
91
bit.ly/3sS8Jf6
Add Your Layer
$HOME/yocto/build/conf/bblayers.conf
BBLAYERS ?= " \
${HOME}/yocto/poky/meta \
${HOME}/yocto/poky/meta-poky \
${HOME}/yocto/poky/meta-yocto-bsp \
${HOME}/yocto/build/meta-ypdd \
"
92
bit.ly/3sS8Jf6
Build and Boot Your Custom Image
$ bitbake -k ypdd-image
(If your SSTATE_DIR is configured correctly from a previous build this should take less than 5 minutes)
$ runqemu qemuarm \
tmp/deploy/images/qemuarm/ypdd-image-qemuarm.ext4 \
[nographic]
93
Use nographic if using ssh environment
bit.ly/3sS8Jf6
Build and Boot Your Custom Image
$ which dropbear
94
bit.ly/3sS8Jf6
Toaster
The following section introduces toaster
95
bit.ly/3sS8Jf6
bit.ly/3sS8Jf6
toaster in one slide
$ mkdir -p ${HOME}/toaster ; cd ${HOME}/toaster �$ git clone -b kirkstone git://git.yoctoproject.org/poky
# Note: git checkout is required by toaster - do not use the release tarball
$ sudo apt-get install python-virtualenv�$ virtualenv venv�$ source venv/bin/activate # you’ll have to activate it every time to enter the environment�(venv)$ pip3 install -r poky/bitbake/toaster-requirements.txt
(venv)$ source poky/oe-init-build-env toasterprjdir
(venv)$ source toaster start # wait 2 minutes …
$ firefox http://localhost:8000
97
bit.ly/3sS8Jf6
TODO Toaster
98
bit.ly/3sS8Jf6
Create new build ...
1)
2)
3)
99
bit.ly/3sS8Jf6
Toaster demo/walkthrough
100
bit.ly/3sS8Jf6
BUILD AN APPLICATION
Adding a "hello world" application to our custom image
101
bit.ly/3sS8Jf6
Building an Application
102
bit.ly/3sS8Jf6
Add Application Code
$ mkdir -p ${HOME}/yocto/build/meta-ypdd/\
recipes-core/hello/files
$ vi /scratch/sandbox/meta-ypdd/recipes-core/\
hello/files/hello.c
103
bit.ly/3sS8Jf6
Application Code
104
#include <stdio.h>
int main(int argc, char **argv) {
printf("Hello World\n");
return 0;
}
$ vi /scratch/sandbox/meta-ypdd/recipes-core/hello/files/hello.c
bit.ly/3sS8Jf6
Add Application Recipe
$ mkdir -p ${HOME}/yocto/build/meta-ypdd/\
recipes-core/hello
$ vi ${HOME}/yocto/build/meta-ypdd/\
recipes-core/hello/hello_1.0.bb
105
bit.ly/3sS8Jf6
Application Recipe
106
DESCRIPTION = "Hello World example"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
S = "${WORKDIR}"
SRC_URI = "file://hello.c"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} hello.c -o hello
}
do_install() {
install -d -m 0755 ${D}/${bindir}
install -m 0755 hello ${D}/${bindir}/hello
}
$ vi ${HOME}/yocto/build/meta-ypdd/recipes-core/hello/hello_1.0.bb
bit.ly/3sS8Jf6
Add Application to the Image
107
bit.ly/3sS8Jf6
Add hello to Image
108
DESCRIPTION = "A core image for YPDD"
LICENSE = "MIT"
# Core files for basic console boot
IMAGE_INSTALL = "packagegroup-core-boot"
# Add our desired extra files
IMAGE_INSTALL += "psplash dropbear hello"
inherit core-image
IMAGE_ROOTFS_SIZE ?= "8192"
$ vi ${HOME}/yocto/build/meta-ypdd/recipes-core/images/ypdd-image.bb
Add the package 'hello'�to your image recipe
bit.ly/3sS8Jf6
Build and Test Application
$ bitbake -k ypdd-image
$ runqemu qemuarm tmp/deploy/images/\
qemuarm/ypdd-image-qemuarm.ext4 nographic
109
bit.ly/3sS8Jf6
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
bit.ly/3sS8Jf6
111
It’s not an Embedded
Linux Distribution
It Creates a
Custom One For You
bit.ly/3sS8Jf6
TIPS HINTS AND OTHER RESOURCES
The following slides contain reference material that will help you climb the Yocto Project learning curve
112
bit.ly/3sS8Jf6
Common Gotchas When Getting Started
113
bit.ly/3sS8Jf6
Project Resources
114
bit.ly/3sS8Jf6
Tip: ack-grep
115
bit.ly/3sS8Jf6
Tip: ack-grep
116
alias bback='ack-grep --type bitbake'
bit.ly/3sS8Jf6
TIP: VIM Syntax Highlighting
$ tree ~/.vim/
/Users/chris/.vim/
├── ftdetect
│ └── bitbake.vim
├── ftplugin
│ └── bitbake.vim
├── plugin
│ └── newbb.vim
└── syntax
└── bitbake.vim
117
bit.ly/3sS8Jf6
TIP: VIM Syntax Highlighting
118
bit.ly/3sS8Jf6
End
HAVE FUN and thank you for joining !
119
bit.ly/3sS8Jf6