Back To Basics - The Ultimate Yocto Introduction
Back To Basics - The Ultimate Yocto Introduction
WHOAMI=”Talel BELHAJSALEM”
WHOAMI_LINKS[linkedin] = “https://www.linkedin.com/in/bhstalel/”
WHOAMI_LINKS[stackoverflow] = “https://stackoverflow.com/users/7553704/talel-belhadjsalem”
WHOAMI_LINKS[email] = “[email protected]”
WHOAMI_LINKS[extra] = “https://yoctoleef.xyz/”
Summary
1. Linux Architecture
2. The Global Aim
3. Build System Philosophy
4. The Chef : Bitbake
5. The Story behind Metadata
6. Preparing The Kitchen : oe-init-build-env
7. The Cooking Process
8. Plating The Image
9. Useful Metadata
10. Board Support Package
11. Useful Cooking Techniques
12. What’s Next?
Linux Architecture : Basics
C Lib
USERSPACE
Shell
syscalls
(ABI)
KERNELSPACE
Kernel
Hardware
Linux Architecture : What we need?
ROOTFS C Lib
USERSPACE
BOOTLOADER
Shell
KERNELSPACE
Kernel DTB
ARCH ? Hardware
The Global Aim : Back to boot
Linux Packages
… SDK
● The build system needs some information in order to produce the output:
○ What Linux Kernel to use ?
○ What Bootloader to use ?
○ What Device Tree Source to compile from the Kernel dts sources ?
○ What is the Target architecture ?
■ This helps creating the right toolchain for the compilation process
○ What is the final image file type and structure ?
○ What C Library to use ?
○ What are packages to include in the final rootfs ?
○ What to use for the basic utilities (busybox, coreutils, …) ?
○ What init manager to use (systemd, sysvinit, …) ?
○ Other questions need to be answered
The Chef : BitBake
Timeline 2006 2010-2011
Yocto Project
poky
Tools
bitbake Test Bitbake
Automate Builds/Tests
Reference Distro
License Handling
OpenEmbedded
Core (metadata)
Append
.bbappend .rpm .deb .ipk
Recipe Package
meta-* Bitbake ROOTFS
.bb
Layer Recipe Package
Class Patch
<name>.bbclass <name>.patch
Recipe Include
<name>_<version>.bb <name>.inc
Append Conf
<name>_<version>.bbappend <name>.conf
The Story Behind Metadata : Recipe
meta-*
poky Recipe
recipes-*
base.bbclass *
Image Package
image.bbclass
*.bb
Contains all tasks needed to create a Package from fetching source to actual package creation.
Disables all package tasks and create new tasks to create and assembly the final Rootfs using list of package recipes.
LAYERDEPENDS_skeleton = "core"
LAYERSERIES_COMPAT_skeleton = "kirkstone"
source files
The Story Behind Metadata : The big picture
.inc
meta- Packages
.bb
meta- Build System Images
.bbclass
… SDK
.conf
…
local.conf
bblayers.conf
The chef (BitBake) needs to know:
bitbake
devtool
meta-example
SRC_URI = “git://github.com/bhstalel/yocto-hello-c-makefile;branch=main;protocol=https
SRCREV ?= “c6c81ae747fa72a60ab389c486fa84a09446fdb8”
recipes-example DEPENDS += “hellolib”
RDEPENDS:${PN} += “hellolib”
S = “${WORKDIR}/git”
example
require hello.inc
SRCREV = “3dc0d44b3881cb0a38ecdfc8dcb4b735bc5f7a02”
SRC_URI = “git://github.com/bhstalel/yocto-hello-c-dependency;branch=main;protocol=https”
SRCREV = “6114bcd982672421739cd1d5d9ddfd6d32dc0fe0”
# …
https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake-tasks-map
raspberrypi4-poky-linux
build
git2
MULTIARCH_TARGET_SYS
1- do_fetch
5- do_prepare_recipe_sysroot
10- do_package_write_rpm
3- do_patch Makefile usr lib usr
6- do_configure
7- do_compile hello.c bin include
9- do_package*
8- do_install
custom-image.bb tmp
inherit core-image
IMAGE_INSTALL:append = “ hello”
work deploy
BitBake will:
MACHINE rpm images
● Make sure that all IMAGE_INSTALL recipes are built
correctly
custom-image <target> MACHINE
● Install all packages into the final rootfs
0.1-r0 *rpm
● Create image structure specified with WKS_FILE and
other variables
rootfs oe-rootfs-repo
● Place the final image in the deploy directory
Layers Classes
meta-bsp
○ Target architecture: poky/meta/conf/machine/include/tune*
● These variables are used by virtual/kernel and virtual/bootloader virtual recipes to do their internal
compilation.
Board Support Package : raspberrypi4-64
bitbake -s Show all recipes versions Useful to check available versions and test layers priorities on them
devshell Prepare dev shell in WORKDIR Useful when you want to work manually on the source code after do_unpack:
bitbake <recipe> -c devshell
pydevshell Python dev interpreter Same as devshell (more powerful) you have access to the d object:
d.getVar() d.getVarFlag() …
Tool Comment
devtool The most powerful utility after bitbake, it is used to add and modify recipes automatically.
recipetool Used also to add and/or modify recipes and create bbappend files automatically
oe-pkgdata-util Used to check information about packages, example: find which recipe provides a file
What Is Next?
● PACKAGECONFIG
● Create and test various DISTROs
● Sharing downloads and cache and optimization
● Work with Package Management
● Work with auto wrappers like repo and Kas
● Populate and work with SDK
● Check Documentation: https://docs.yoctoproject.org/
● Welcome to IRC: https://web.libera.chat/?channels=#yocto
● Welcome to Mailing Lists: https://lists.yoctoproject.org/