SlideShare una empresa de Scribd logo
1 de 86
Descargar para leer sin conexión
Yocto Project®
Kernel Lab, Hands-On
Trevor Woerner, Nautel Ltd
Yocto Project Virtual Summit Europe, October 29-30, 2020
Yocto Project | The Linux Foundation
Ignoring TheYocto Project (briefly)
3 Yocto Project®
| The Linux Foundation®
Kernel Workflow - first pass
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
4 Yocto Project®
| The Linux Foundation®
Kernel Workflow - later
• edit kernel
• write kernel module
• do -rt stuff
5 Yocto Project®
| The Linux Foundation®
Kernel Workflow - first pass
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
6 Yocto Project®
| The Linux Foundation®
Obtain Kernel
• upstream Linus
• upstream linux-stable
• vendor kernel (tries to be good)
• evil vendor kernel (franken-kernel)
7 Yocto Project®
| The Linux Foundation®
Kernel Workflow - first pass
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
8 Yocto Project®
| The Linux Foundation®
Obtain Cross-Toolchain
• source

gnu.gcc.org (compile your own, good luck)

crosstool-NG (compile your own, with help)
• binary

cross-compiler from your distro

ARM/Linaro

Bootlin

kernel.org (NOTE: kernel only)

vendor
9 Yocto Project®
| The Linux Foundation®
Obtain Cross-Toolchain
ARM/Linaro
10 Yocto Project®
| The Linux Foundation®
Obtain Cross-Toolchain
Bootlin - https://toolchains.bootlin.com
11 Yocto Project®
| The Linux Foundation®
Obtain Cross-Toolchain
kernel.org - https://www.kernel.org/pub/tools/crosstool
12 Yocto Project®
| The Linux Foundation®
Kernel Workflow - first pass
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
13 Yocto Project®
| The Linux Foundation®
Setup Toolchain/Environment
$ export ARCH=arm
$ export CROSS_COMPILE=<toolchain-prefix>
• (compile +) install toolchain
• setup $PATH
either:
• tweak environment
• specify on cmdline
$ ARCH=arm CROSS_COMPILE=<toolchain-prefix> make
14 Yocto Project®
| The Linux Foundation®
Kernel Workflow - first pass
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
15 Yocto Project®
| The Linux Foundation®
Build Kernel, Modules, DTB
$ ARCH=arm CROSS_COMPILE=<toolchain-prefix> make menuconfig
16 Yocto Project®
| The Linux Foundation®
Kernel Workflow - first pass
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
17 Yocto Project®
| The Linux Foundation®
Build Kernel, Modules, DTB
$ ARCH=arm CROSS_COMPILE=<toolchain-prefix> make
18 Yocto Project®
| The Linux Foundation®
Kernel Workflow - first pass
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
19 Yocto Project®
| The Linux Foundation®
Install Kernel, Modules, DTB
• by default:
• kernel: $INSTALL_PATH (default: /boot)
• modules: $INSTALL_MOD_PATH/lib/modules/$VER
• dtb: $INSTALL_PATH/dtbs/$VER
• this doesn't work for embedded
• each board is… "unique"
20 Yocto Project®
| The Linux Foundation®
Install Kernel, Modules, DTB
• how and where these various parts are installed is highly
board-specific:
• extlinux.conf
• uEnv.txt
• separate partitions
• APPENDED_DTB (i.e. "bundled")
• U-Boot FIT image
21 Yocto Project®
| The Linux Foundation®
Install Kernel, Modules, DTB
• how and where these various parts are installed is highly
board-specific:
• "magic" offsets on storage device
• multi-partition UBI (raw flash)
• initial FAT/VFAT partition
22 Yocto Project®
| The Linux Foundation®
Install Kernel, Modules, DTB
• there is a very tight coupling between
• bootloader
• kernel cmdline
• kernel + modules + dtb
• final image assembly (e.g. wic)
23 Yocto Project®
| The Linux Foundation®
Kernel Workflow - later
• edit kernel
• write kernel module
• do -rt stuff
24 Yocto Project®
| The Linux Foundation®
Edit Kernel
• not too difficult, locate and edit kernel sources
• just make sure you're editing the correct sources
(multiple boards, multiple projects, multiple
configurations) and using the correct toolchain
(correctly)
25 Yocto Project®
| The Linux Foundation®
Kernel Workflow - later
• edit kernel
• write kernel module
• do -rt stuff
26 Yocto Project®
| The Linux Foundation®
Write Kernel Module
• need to copy+paste an example Makefile to get the out-
of-kernel-tree build plumbing correct
• otherwise the mechanics aren't too complicated
27 Yocto Project®
| The Linux Foundation®
Kernel Workflow - later
• edit kernel
• write kernel module
• do -rt stuff
28 Yocto Project®
| The Linux Foundation®
Do -rt Stuff
• I hope the kernel version you're using is one for which
there is an -rt patch available, otherwise forget it
• if the above is true, manually applying the -rt patch
against an unmodified base isn't too difficult
29 Yocto Project®
| The Linux Foundation®
Kernel Workflow Without Yocto
• it's not too hard if you've done it once or twice before
• but can be tricky to get it right the first time
• the amount of work compounds with the number of
boards you need to support
• multiple toolchains
• multiple configurations
• multiple install layouts
Yocto Project | The Linux Foundation
How Can TheYocto Project Help?
31 Yocto Project®
| The Linux Foundation®
Kernel Workflow - multiple scenarios
• using an existing BSP
• creating a BSP
32 Yocto Project®
| The Linux Foundation®
Kernel Workflow - existing BSP
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
DO
N
E!
33 Yocto Project®
| The Linux Foundation®
Kernel Workflow TODO - existing BSP
• change kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
• edit kernel sources
• write a kernel module
34 Yocto Project®
| The Linux Foundation®
Kernel Workflow TODO - existing BSP
change kernel
• many kernels from which to choose (upstream, vendor,
stable)
• The Yocto Project provides its own (linux-yocto) plus
tooling for use with linux-yocto, or your own
• linux-yocto comes in a couple variants:
• (base)
• -dev
• -tiny
• -rt
35 Yocto Project®
| The Linux Foundation®
• use your own defconfig
• use an in-kernel _defconfig
• generate one or more config "fragments" which are
applied on top of the base configuration
Kernel Workflow TODO - existing BSP
tweak config
36 Yocto Project®
| The Linux Foundation®
Kernel Workflow TODO - existing BSP
edit kernel code
• good for pr_notice() debugging
• edit/add device IDs (PCI, USB) for new hardware
37 Yocto Project®
| The Linux Foundation®
Kernel Workflow TODO - existing BSP
write a module
• a frequent activity with embedded devices
• autoload on boot with KERNEL_MODULE_AUTOLOAD
• be sure to include your modules into your image
(MACHINE_EXTRA_RRECOMMENDS)
38 Yocto Project®
| The Linux Foundation®
Kernel Workflow - new BSP
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
DO
N
E!
39 Yocto Project®
| The Linux Foundation®
Kernel Workflow - new BSP
• obtain kernel
• obtain cross-toolchain
• setup cross-toolchain/environment
• configure kernel/tweak DT
• build kernel/modules/dtb
• install kernel/modules/dtb
• … but with a lot of help!
DO
N
E!
40 Yocto Project®
| The Linux Foundation®
Kernel Workflow - new BSP
• obtain kernel
• implicit understanding of how to fetch code
• setup cross-toolchain/environment
• set the processor "TUNE" in $MACHINE
• configure kernel/tweak DT
• lots of linux-yocto tooling
• install kernel/modules/dtb
• lots of kernel-handling classes
Yocto Project | The Linux Foundation
Hands On:
Existing BSP
42 Yocto Project®
| The Linux Foundation®
Hands-On: Prep
ilab01:~/scratch$ cd scratch
ilab01:~/scratch$ . poky/oe-init-build-env poky/build-kernel
...
### Shell environment set up for builds. ###
...
ilab01:~/scratch/build$
ilab01:~/scratch/build$ export PS1="${PS1}lab> "
ilab01:~/scratch/build$ lab>
• I like to remind myself this is now a modified-
environment shell for builds:
43 Yocto Project®
| The Linux Foundation®
Hands-On: Prep
ilab01:~/scratch/build$ lab> $EDITOR conf/local.conf
• here's what you need to double-check:
MACHINE = "qemuarm"
DL_DIR = "/scratch/downloads"
SSTATE_DIR = "/scratch/sstate-cache"
SDKMACHINE = "x86_64"
OE_TERMINAL = "screen"
44 Yocto Project®
| The Linux Foundation®
Hands-On: Prep
ilab01:~/scratch/build$ lab> bitbake core-image-minimal
Build Configuration:
BB_VERSION = "1.48.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-poky-linux-gnueabi"
MACHINE = "qemuarm"
DISTRO = "poky"
DISTRO_VERSION = "3.2"
TUNE_FEATURES = "arm armv7ve vfp thumb neon callconvention-hard"
TARGET_FPU = "hard"
meta
meta-poky
meta-yocto-bsp = "gatesgarth:4e4a302e37ac06543e9983773cdb4caf7728330d"
• baseline build:
45 Yocto Project®
| The Linux Foundation®
Hands-On: Prep
ilab01:~/scratch/build$ lab> runqemu slirp nographic serial
...
[ 5.284685] hid-generic 0003:0627:0001.0002: input: USB HID v1.11 Keyboard
[QEMU QEMU USB Keyboard] on usb-0000:00:03.0-2/input0
Starting udev
[ 5.750381] udevd[135]: starting version 3.2.9
[ 5.839873] udevd[136]: starting eudev-3.2.9
[ 7.705072] EXT4-fs (vda): re-mounted. Opts: (null)
Poky (Yocto Project Reference Distro) 3.2 qemuarm ttyAMA0
qemuarm login:
• verify it runs
46 Yocto Project®
| The Linux Foundation®
Hands-On: Prep
Poky (Yocto Project Reference Distro) 3.2 qemuarm ttyAMA0
qemuarm login: root
root@qemuarm:~# uname -a
Linux qemuarm 5.8.13-yocto-standard #1 SMP PREEMPT Tue Oct 6 12:23:42 UTC
2020 armv7l armv7l armv7l GNU/Linux
root@qemuarm:~# shutdown -h now
...
[ 130.239174] EXT4-fs (vda): re-mounted. Opts: (null)
[ 130.242375] reboot: Power down
runqemu - INFO - Cleaning up
ilab01:~/scratch/build$ lab>
• shutdown
47 Yocto Project®
| The Linux Foundation®
Hands-On: Prep
ilab01:~/scratch/build$ lab> bitbake-layers create-layer meta-mytweaks
NOTE: Starting bitbake server...
Add your new layer with 'bitbake-layers add-layer meta-mytweaks'
ilab01:~/scratch/build$ lab> bitbake-layers add-layer meta-mytweaks
NOTE: Starting bitbake server...
ilab01:~/scratch/build$ lab>
• create/add a layer for your changes
48 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
49 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> devtool modify virtual/kernel
...
INFO: Mapping virtual/kernel to linux-yocto
...
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 410 tasks of which 399 didn't need to be rerun
and all succeeded.
INFO: Copying kernel config to srctree
INFO: Source tree extracted to /scratch/build/workspace/sources/linux-yocto
INFO: Recipe linux-yocto now set up to build from
/scratch/build/workspace/sources/linux-yocto
• use devtool (emphasis mine)
50 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> $EDITOR workspace/sources/linux-yocto/init/main.c
1431 /*
1432 * We try each of these until one succeeds.
1433 *
1434 * The Bourne shell can be used instead of init if we are
1435 * trying to recover a really broken machine.
1436 */
1437 pr_notice("*** --- >>> edit <<< --- ***n");
1438 if (execute_command) {
1439 ret = run_init_process(execute_command);
1440 if (!ret)
1441 return 0;
1442 panic("Requested init %s failed (error %d).",
1443 execute_command, ret);
• edit init/main.c
51 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> bitbake core-image-minimal
...
NOTE: linux-yocto: compiling from external source tree
/scratch/build/workspace/sources/linux-yocto
...
• build (emphasis mine)
52 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> runqemu slirp nographic serial
...
[ 4.499808] EXT4-fs (vda): mounted filesystem with ordered data mode.
Opts: (null)
[ 4.501350] VFS: Mounted root (ext4 filesystem) on device 253:0.
[ 4.503554] devtmpfs: mounted
[ 4.566689] Freeing unused kernel memory: 2048K
[ 4.580415] *** --- >>> edit <<< --- ***
[ 4.580672] Run /sbin/init as init process
[ 4.675352] usb 1-1: new high-speed USB device number 2 using xhci_hcd
INIT: version 2.97 booting
...
• test (you might have to scroll up)
53 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> pushd workspace/sources/linux-yocto
/scratch/build/workspace/sources/linux-yocto /scratch/build
ilab01:~/scratch/build$ lab> git commit -avs -m "init/main.c: add my tweaks"
[v5.8/standard/arm-versatile-926ejs c12b5fb34a7c] init/main.c: add my tweaks
1 file changed, 1 insertion(+)
ilab01:~/scratch/build$ lab> popd
/scratch/build
• commit your changes (don't forget upstream-status)
54 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> devtool finish linux-yocto meta-mytweaks
...
NOTE: Writing append file
/scratch/build/meta-mytweaks/recipes-kernel/linux/linux-yocto_%.bbappend
NOTE: Copying 0001-init-main.c-add-my-tweaks.patch to /scratch/build/meta-
mytweaks/recipes-kernel/linux/linux-yocto/0001-init-main.c-add-my-
tweaks.patch
INFO: Cleaning sysroot for recipe linux-yocto...
INFO: Leaving source tree /scratch/build/workspace/sources/linux-yocto as-is;
if you no longer need it then please delete it manually
ilab01:~/scratch/build$ lab> rm -fr workspace/sources/linux-yocto
• update your metadata (emphasis mine)
55 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> tree meta-mytweaks
meta-mytweaks/
├── COPYING.MIT
├── README
├── conf
│   └── layer.conf
└── recipes-kernel
└── linux
├── linux-yocto
│   └── 0001-init-main.c-add-my-tweaks.patch
└── linux-yocto_%.bbappend
4 directories, 5 files
• check
56 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux-
yocto/0001-init-main.c-add-my-tweaks.patch
...
diff --git a/init/main.c b/init/main.c
index bf27d2045ea3..5b03552ff7e6 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1434,6 +1434,7 @@ static int __ref kernel_init(void *unused)
* The Bourne shell can be used instead of init if we are
* trying to recover a really broken machine.
*/
+ pr_notice("*** --- >>> edit <<< --- ***n");
if (execute_command) {
ret = run_init_process(execute_command);
• check
57 Yocto Project®
| The Linux Foundation®
Hands-On: Edit the Kernel
ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux-
yocto_%.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-init-main.c-add-my-tweaks.patch"
• check
58 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
59 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
ilab01:~/scratch/build$ lab> devtool modify virtual/kernel
...
NOTE: Tasks Summary: Attempted 410 tasks of which 399 didn't need to be rerun
and all succeeded.
INFO: Copying kernel config to srctree
INFO: Source tree extracted to /scratch/build/workspace/sources/linux-yocto
INFO: Recipe linux-yocto now set up to build from
/scratch/build/workspace/sources/linux-yocto
• use devtool, setup
60 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
ilab01:~/scratch/build$ lab> devtool menuconfig linux-yocto
• use devtool
61 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
• navigate to:
General Setup
Preemption Model
• select:
No Forced Preemption (Server)
• hit double-esc or <Exit> and save your changes
INFO: Updating config fragment
/scratch/build/workspace/sources/linux-yocto/oe-local-files/devtool-
fragment.cfg
62 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
ilab01:~/scratch/build$ lab> bitbake core-image-minimal
NOTE: linux-yocto: compiling from external source tree
/scratch/build/workspace/sources/linux-yocto
ilab01:~/scratch/build$ lab> runqemu slirp nographic serial
...
[ 0.037703] rcu: Hierarchical SRCU implementation.
...
qemuarm login: root
root@qemuarm:~# uname -a
Linux qemuarm 5.8.13-yocto-standard #1 SMP Tue Oct 27 04:00:52 UTC 2020
armv7l armv7l armv7l GNU/Linux
• test
• NOTE: missing "Preemptible hierarchical RCU" and
"PREEMPT" in "uname -a"
63 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
ilab01:~/scratch/build$ lab> devtool finish linux-yocto meta-mytweaks
...
NOTE: Writing append file
/scratch/build/meta-mytweaks/recipes-kernel/linux/linux-yocto_%.bbappend
NOTE: Copying devtool-fragment.cfg to /scratch/build/meta-mytweaks/recipes-
kernel/linux/linux-yocto/devtool-fragment.cfg
INFO: Cleaning sysroot for recipe linux-yocto...
INFO: Leaving source tree /scratch/build/workspace/sources/linux-yocto as-is;
if you no longer need it then please delete it manually
ilab01:~/scratch/build$ lab> rm -fr workspace/sources/linux-yocto
• update metadata
64 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
ilab01:~/scratch/build$ lab> tree meta-mytweaks
meta-mytweaks/
├── COPYING.MIT
├── README
├── conf
│   └── layer.conf
└── recipes-kernel
└── linux
├── linux-yocto
│   ├── 0001-init-main.c-add-my-tweaks.patch
│   └── devtool-fragment.cfg
└── linux-yocto_%.bbappend
4 directories, 6 files
• check
65 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux-
yocto/devtool-fragment.cfg
CONFIG_PREEMPT_NONE=y
# CONFIG_PREEMPT is not set
CONFIG_TREE_RCU=y
CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
CONFIG_INLINE_READ_UNLOCK=y
CONFIG_INLINE_READ_UNLOCK_IRQ=y
CONFIG_INLINE_WRITE_UNLOCK=y
CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
• check
66 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux-
yocto_%.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-init-main.c-add-my-tweaks.patch 
file://devtool-fragment.cfg 
"
• check (emphasis mine)
67 Yocto Project®
| The Linux Foundation®
Hands-On: Tweak the Kernel Configuration
• NOTE: subsequent menuconfig changes clobber previous
changes, so you'll need to move/rename them if you're
generating more than one
68 Yocto Project®
| The Linux Foundation®
Hands-On: alt
ilab01:~/scratch/build$ lab> bitbake core-image-minimal -c populate_sdk
• if you're not "sold" on the devtool workflow, you could
generate an SDK and use that instead
• it is then very much like using any other SDK, but this one
is tailored to your image
• it comes with an environment file that you source which
includes (among other things) settings for ARCH and
CROSS_COMPILE
Yocto Project | The Linux Foundation
The Yocto Project Kernel Metadata
70 Yocto Project®
| The Linux Foundation®
Kernel Metadata
• in the hands-on portion you saw an example of a kernel
configuration fragment and a patch
• the Linux kernel configuration system has always had the
ability to handle config fragments, but few have made use
of it
• patches and configs can be grouped into features
• we have tooling to help organize and apply fragments and
patches in various conditions
71 Yocto Project®
| The Linux Foundation®
Kernel Metadata
• 3 types of kernel metadata:
 scc files
 patches
 config fragments
72 Yocto Project®
| The Linux Foundation®
Kernel Metadata - config fragments
• we saw this in the hands-on
• use devtool or -c menuconfig/-c diffconfig to generate
• filename has a *.cfg extension
73 Yocto Project®
| The Linux Foundation®
Kernel Metadata - patches
• we also saw this in the hands-on
• use devtool+git or patch or manually use git --format-patch
to generate
• filename has a *.patch extension
74 Yocto Project®
| The Linux Foundation®
Kernel Metadata - scc
• "scc" = Series Configuration Control
• ties together config fragments and/or patches with extra
metadata that is useful to the build
• filename has an *.scc extension
75 Yocto Project®
| The Linux Foundation®
Kernel Metadata - e.g. 1
• you have a set of 6 boards:
 2 have graphics capabilities
 3 can make sounds
 1 uses raw flash
 4 have DVD devices
• you could create sets of *.cfg/*.patch for each feature,
described in *scc files, then apply them as required
76 Yocto Project®
| The Linux Foundation®
Kernel Metadata - e.g. 2
• you have "development" and "production" builds
• for development builds you might want to enable more
kernel debugging and/or verbosity or NFS or lax security
• for production builds you might want to enable more
kernel hardening and disable potential security things
(i.e. disable modules)
77 Yocto Project®
| The Linux Foundation®
Kernel Metadata - e.g. 3
• you're creating a BSP layer and some of your boards use
one GPU while others use a second GPU and the rest use
yet another GPU
• you can create metadata for each GPU and include them
in your builds as required
78 Yocto Project®
| The Linux Foundation®
Kernel Metadata - storage
• there are 2 places you can store the kernel metadata:
 in-tree
 in a separate repository
• regardless, add the location of the metadata to your
SRC_URI variable and be sure to specify "type=kmeta"
79 Yocto Project®
| The Linux Foundation®
Kernel Metadata - enabling
• reference the *.scc file with KERNEL_FEATURES

conf/machine

recipes-kernel/linux
80 Yocto Project®
| The Linux Foundation®
Kernel Metadata - down the rabbit hole
• it's much more sophisticated
• you can define kernel types (i.e. KTYPE) and have
features enabled based on the kernel type (e.g. -tiny, -dev,
-rt)
• *.scc files can include other *.scc files but there are ways
to say "include this *.scc file but not anything it wants to
include"
81 Yocto Project®
| The Linux Foundation®
Kernel Metadata
• examples of in-tree kmeta include:
 https://github.com/akuster/meta-odroid
 http://git.yoctoproject.org/cgit/cgit.cgi/meta-arm
• http://git.yoctoproject.org/cgit/cgit.cgi/meta-raspberrypi
is an example of just using *.cfg files without *.scc
82 Yocto Project®
| The Linux Foundation®
Kernel Metadata
• an example of out-of-tree kmeta is:
 http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-
cache
Yocto Project | The Linux Foundation
Recommendations
84 Yocto Project®
| The Linux Foundation®
Recommendations
• use linux-yocto if at all possible
 your users will appreciate being able to take
advantage of the tooling and features that come with
The Yocto Project (i.e. they can tweak the config)
• otherwise base your kernel recipe on poky/meta-
skeleton/recipes-kernel/linux/linux-yocto-custom.bb
inherit kernel
require recipes-kernel/linux/linux-yocto.inc
Thanks for your time
Yocto Project Kernel Lab hands-on

Más contenido relacionado

La actualidad más candente

Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded Linux
Sherif Mousa
 
linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrix
Sherif Mousa
 
001 linux revision
001 linux revision001 linux revision
001 linux revision
Sherif Mousa
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to Yocto
Sherif Mousa
 

La actualidad más candente (20)

Eclipse IDE Yocto Plugin
Eclipse IDE Yocto PluginEclipse IDE Yocto Plugin
Eclipse IDE Yocto Plugin
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
 
Yocto and IoT - a retrospective
Yocto and IoT - a retrospectiveYocto and IoT - a retrospective
Yocto and IoT - a retrospective
 
Introduction to yocto
Introduction to yoctoIntroduction to yocto
Introduction to yocto
 
Why you should use the Yocto Project
Why you should use the Yocto ProjectWhy you should use the Yocto Project
Why you should use the Yocto Project
 
Yocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerYocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution Maker
 
Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded Linux
 
linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrix
 
Embedded Linux primer
Embedded Linux primerEmbedded Linux primer
Embedded Linux primer
 
Building Emmbedded Linux with Yocto project
Building Emmbedded Linux with Yocto projectBuilding Emmbedded Linux with Yocto project
Building Emmbedded Linux with Yocto project
 
Building Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 ArchBuilding Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 Arch
 
Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...
Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...
Embedded Recipes 2017 - Introduction to Yocto Project/OpenEmbedded - Mylène J...
 
Generating a Reproducible and Maintainable Embedded Linux Environment with Po...
Generating a Reproducible and Maintainable Embedded Linux Environment with Po...Generating a Reproducible and Maintainable Embedded Linux Environment with Po...
Generating a Reproducible and Maintainable Embedded Linux Environment with Po...
 
001 linux revision
001 linux revision001 linux revision
001 linux revision
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to Yocto
 
Yocto Project Open Source Build System and Collaboration Initiative
Yocto Project Open Source Build System and Collaboration InitiativeYocto Project Open Source Build System and Collaboration Initiative
Yocto Project Open Source Build System and Collaboration Initiative
 
Building Embedded Linux UDOONEO
Building Embedded Linux UDOONEOBuilding Embedded Linux UDOONEO
Building Embedded Linux UDOONEO
 
Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems Introduction
 
Crafting GNU/ linux distributions for embedded target using Builroot
Crafting GNU/ linux distributions for embedded target using BuilrootCrafting GNU/ linux distributions for embedded target using Builroot
Crafting GNU/ linux distributions for embedded target using Builroot
 
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/SourceCrafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
 

Similar a Yocto Project Kernel Lab hands-on

OpenEmbedded & BitBake - Denx
OpenEmbedded & BitBake - DenxOpenEmbedded & BitBake - Denx
OpenEmbedded & BitBake - Denx
yang firo
 

Similar a Yocto Project Kernel Lab hands-on (20)

Stefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto ProjectStefano Cordibella - An introduction to Yocto Project
Stefano Cordibella - An introduction to Yocto Project
 
Autobuilder2 Yocto Project Summit Lyon 2019
Autobuilder2 Yocto Project Summit Lyon 2019Autobuilder2 Yocto Project Summit Lyon 2019
Autobuilder2 Yocto Project Summit Lyon 2019
 
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily JobLuca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
Luca Ceresoli - Buildroot vs Yocto: Differences for Your Daily Job
 
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDKYocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
 
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
 The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
 
OpenEmbedded & BitBake - Denx
OpenEmbedded & BitBake - DenxOpenEmbedded & BitBake - Denx
OpenEmbedded & BitBake - Denx
 
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
Marco Cavallini - Yocto Project, an automatic generator of embedded Linux dis...
 
Marco Cavallini @ LinuxLab 2018 : Workshop Yocto Project, an automatic genera...
Marco Cavallini @ LinuxLab 2018 : Workshop Yocto Project, an automatic genera...Marco Cavallini @ LinuxLab 2018 : Workshop Yocto Project, an automatic genera...
Marco Cavallini @ LinuxLab 2018 : Workshop Yocto Project, an automatic genera...
 
Run Qt on Linux embedded systems using Yocto
Run Qt on Linux embedded systems using YoctoRun Qt on Linux embedded systems using Yocto
Run Qt on Linux embedded systems using Yocto
 
Yocto Project introduction
Yocto Project introductionYocto Project introduction
Yocto Project introduction
 
Makefile+VersionControl
Makefile+VersionControlMakefile+VersionControl
Makefile+VersionControl
 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?
 
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
 
Buildroot easy embedded system
Buildroot easy embedded systemBuildroot easy embedded system
Buildroot easy embedded system
 
Design, Build,and Maintain the Embedded Linux Platform
Design, Build,and Maintain the Embedded Linux PlatformDesign, Build,and Maintain the Embedded Linux Platform
Design, Build,and Maintain the Embedded Linux Platform
 
Package your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and KubernetesPackage your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and Kubernetes
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Poky meets Debian: Understanding how to make an embedded Linux by using an ex...
Poky meets Debian: Understanding how to make an embedded Linux by using an ex...Poky meets Debian: Understanding how to make an embedded Linux by using an ex...
Poky meets Debian: Understanding how to make an embedded Linux by using an ex...
 
1212312232
12123122321212312232
1212312232
 
Achieving CI/CD with Kubernetes
Achieving CI/CD with KubernetesAchieving CI/CD with Kubernetes
Achieving CI/CD with Kubernetes
 

Más de Trevor Woerner (7)

Sensing Temperature with a RaspberryPi
Sensing Temperature with a RaspberryPiSensing Temperature with a RaspberryPi
Sensing Temperature with a RaspberryPi
 
GSoC/EVoC Overview
GSoC/EVoC OverviewGSoC/EVoC Overview
GSoC/EVoC Overview
 
Getting Started with Buildroot - Lab
Getting Started with Buildroot - LabGetting Started with Buildroot - Lab
Getting Started with Buildroot - Lab
 
Getting Started with Buildroot
Getting Started with BuildrootGetting Started with Buildroot
Getting Started with Buildroot
 
Using OpenEmbedded
Using OpenEmbeddedUsing OpenEmbedded
Using OpenEmbedded
 
OE Hands-On
OE Hands-OnOE Hands-On
OE Hands-On
 
Using OpenEmbedded
Using OpenEmbeddedUsing OpenEmbedded
Using OpenEmbedded
 

Último

Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 

Último (20)

Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 

Yocto Project Kernel Lab hands-on

  • 1. Yocto Project® Kernel Lab, Hands-On Trevor Woerner, Nautel Ltd Yocto Project Virtual Summit Europe, October 29-30, 2020
  • 2. Yocto Project | The Linux Foundation Ignoring TheYocto Project (briefly)
  • 3. 3 Yocto Project® | The Linux Foundation® Kernel Workflow - first pass • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb
  • 4. 4 Yocto Project® | The Linux Foundation® Kernel Workflow - later • edit kernel • write kernel module • do -rt stuff
  • 5. 5 Yocto Project® | The Linux Foundation® Kernel Workflow - first pass • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb
  • 6. 6 Yocto Project® | The Linux Foundation® Obtain Kernel • upstream Linus • upstream linux-stable • vendor kernel (tries to be good) • evil vendor kernel (franken-kernel)
  • 7. 7 Yocto Project® | The Linux Foundation® Kernel Workflow - first pass • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb
  • 8. 8 Yocto Project® | The Linux Foundation® Obtain Cross-Toolchain • source  gnu.gcc.org (compile your own, good luck)  crosstool-NG (compile your own, with help) • binary  cross-compiler from your distro  ARM/Linaro  Bootlin  kernel.org (NOTE: kernel only)  vendor
  • 9. 9 Yocto Project® | The Linux Foundation® Obtain Cross-Toolchain ARM/Linaro
  • 10. 10 Yocto Project® | The Linux Foundation® Obtain Cross-Toolchain Bootlin - https://toolchains.bootlin.com
  • 11. 11 Yocto Project® | The Linux Foundation® Obtain Cross-Toolchain kernel.org - https://www.kernel.org/pub/tools/crosstool
  • 12. 12 Yocto Project® | The Linux Foundation® Kernel Workflow - first pass • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb
  • 13. 13 Yocto Project® | The Linux Foundation® Setup Toolchain/Environment $ export ARCH=arm $ export CROSS_COMPILE=<toolchain-prefix> • (compile +) install toolchain • setup $PATH either: • tweak environment • specify on cmdline $ ARCH=arm CROSS_COMPILE=<toolchain-prefix> make
  • 14. 14 Yocto Project® | The Linux Foundation® Kernel Workflow - first pass • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb
  • 15. 15 Yocto Project® | The Linux Foundation® Build Kernel, Modules, DTB $ ARCH=arm CROSS_COMPILE=<toolchain-prefix> make menuconfig
  • 16. 16 Yocto Project® | The Linux Foundation® Kernel Workflow - first pass • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb
  • 17. 17 Yocto Project® | The Linux Foundation® Build Kernel, Modules, DTB $ ARCH=arm CROSS_COMPILE=<toolchain-prefix> make
  • 18. 18 Yocto Project® | The Linux Foundation® Kernel Workflow - first pass • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb
  • 19. 19 Yocto Project® | The Linux Foundation® Install Kernel, Modules, DTB • by default: • kernel: $INSTALL_PATH (default: /boot) • modules: $INSTALL_MOD_PATH/lib/modules/$VER • dtb: $INSTALL_PATH/dtbs/$VER • this doesn't work for embedded • each board is… "unique"
  • 20. 20 Yocto Project® | The Linux Foundation® Install Kernel, Modules, DTB • how and where these various parts are installed is highly board-specific: • extlinux.conf • uEnv.txt • separate partitions • APPENDED_DTB (i.e. "bundled") • U-Boot FIT image
  • 21. 21 Yocto Project® | The Linux Foundation® Install Kernel, Modules, DTB • how and where these various parts are installed is highly board-specific: • "magic" offsets on storage device • multi-partition UBI (raw flash) • initial FAT/VFAT partition
  • 22. 22 Yocto Project® | The Linux Foundation® Install Kernel, Modules, DTB • there is a very tight coupling between • bootloader • kernel cmdline • kernel + modules + dtb • final image assembly (e.g. wic)
  • 23. 23 Yocto Project® | The Linux Foundation® Kernel Workflow - later • edit kernel • write kernel module • do -rt stuff
  • 24. 24 Yocto Project® | The Linux Foundation® Edit Kernel • not too difficult, locate and edit kernel sources • just make sure you're editing the correct sources (multiple boards, multiple projects, multiple configurations) and using the correct toolchain (correctly)
  • 25. 25 Yocto Project® | The Linux Foundation® Kernel Workflow - later • edit kernel • write kernel module • do -rt stuff
  • 26. 26 Yocto Project® | The Linux Foundation® Write Kernel Module • need to copy+paste an example Makefile to get the out- of-kernel-tree build plumbing correct • otherwise the mechanics aren't too complicated
  • 27. 27 Yocto Project® | The Linux Foundation® Kernel Workflow - later • edit kernel • write kernel module • do -rt stuff
  • 28. 28 Yocto Project® | The Linux Foundation® Do -rt Stuff • I hope the kernel version you're using is one for which there is an -rt patch available, otherwise forget it • if the above is true, manually applying the -rt patch against an unmodified base isn't too difficult
  • 29. 29 Yocto Project® | The Linux Foundation® Kernel Workflow Without Yocto • it's not too hard if you've done it once or twice before • but can be tricky to get it right the first time • the amount of work compounds with the number of boards you need to support • multiple toolchains • multiple configurations • multiple install layouts
  • 30. Yocto Project | The Linux Foundation How Can TheYocto Project Help?
  • 31. 31 Yocto Project® | The Linux Foundation® Kernel Workflow - multiple scenarios • using an existing BSP • creating a BSP
  • 32. 32 Yocto Project® | The Linux Foundation® Kernel Workflow - existing BSP • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb DO N E!
  • 33. 33 Yocto Project® | The Linux Foundation® Kernel Workflow TODO - existing BSP • change kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb • edit kernel sources • write a kernel module
  • 34. 34 Yocto Project® | The Linux Foundation® Kernel Workflow TODO - existing BSP change kernel • many kernels from which to choose (upstream, vendor, stable) • The Yocto Project provides its own (linux-yocto) plus tooling for use with linux-yocto, or your own • linux-yocto comes in a couple variants: • (base) • -dev • -tiny • -rt
  • 35. 35 Yocto Project® | The Linux Foundation® • use your own defconfig • use an in-kernel _defconfig • generate one or more config "fragments" which are applied on top of the base configuration Kernel Workflow TODO - existing BSP tweak config
  • 36. 36 Yocto Project® | The Linux Foundation® Kernel Workflow TODO - existing BSP edit kernel code • good for pr_notice() debugging • edit/add device IDs (PCI, USB) for new hardware
  • 37. 37 Yocto Project® | The Linux Foundation® Kernel Workflow TODO - existing BSP write a module • a frequent activity with embedded devices • autoload on boot with KERNEL_MODULE_AUTOLOAD • be sure to include your modules into your image (MACHINE_EXTRA_RRECOMMENDS)
  • 38. 38 Yocto Project® | The Linux Foundation® Kernel Workflow - new BSP • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb DO N E!
  • 39. 39 Yocto Project® | The Linux Foundation® Kernel Workflow - new BSP • obtain kernel • obtain cross-toolchain • setup cross-toolchain/environment • configure kernel/tweak DT • build kernel/modules/dtb • install kernel/modules/dtb • … but with a lot of help! DO N E!
  • 40. 40 Yocto Project® | The Linux Foundation® Kernel Workflow - new BSP • obtain kernel • implicit understanding of how to fetch code • setup cross-toolchain/environment • set the processor "TUNE" in $MACHINE • configure kernel/tweak DT • lots of linux-yocto tooling • install kernel/modules/dtb • lots of kernel-handling classes
  • 41. Yocto Project | The Linux Foundation Hands On: Existing BSP
  • 42. 42 Yocto Project® | The Linux Foundation® Hands-On: Prep ilab01:~/scratch$ cd scratch ilab01:~/scratch$ . poky/oe-init-build-env poky/build-kernel ... ### Shell environment set up for builds. ### ... ilab01:~/scratch/build$ ilab01:~/scratch/build$ export PS1="${PS1}lab> " ilab01:~/scratch/build$ lab> • I like to remind myself this is now a modified- environment shell for builds:
  • 43. 43 Yocto Project® | The Linux Foundation® Hands-On: Prep ilab01:~/scratch/build$ lab> $EDITOR conf/local.conf • here's what you need to double-check: MACHINE = "qemuarm" DL_DIR = "/scratch/downloads" SSTATE_DIR = "/scratch/sstate-cache" SDKMACHINE = "x86_64" OE_TERMINAL = "screen"
  • 44. 44 Yocto Project® | The Linux Foundation® Hands-On: Prep ilab01:~/scratch/build$ lab> bitbake core-image-minimal Build Configuration: BB_VERSION = "1.48.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "universal" TARGET_SYS = "arm-poky-linux-gnueabi" MACHINE = "qemuarm" DISTRO = "poky" DISTRO_VERSION = "3.2" TUNE_FEATURES = "arm armv7ve vfp thumb neon callconvention-hard" TARGET_FPU = "hard" meta meta-poky meta-yocto-bsp = "gatesgarth:4e4a302e37ac06543e9983773cdb4caf7728330d" • baseline build:
  • 45. 45 Yocto Project® | The Linux Foundation® Hands-On: Prep ilab01:~/scratch/build$ lab> runqemu slirp nographic serial ... [ 5.284685] hid-generic 0003:0627:0001.0002: input: USB HID v1.11 Keyboard [QEMU QEMU USB Keyboard] on usb-0000:00:03.0-2/input0 Starting udev [ 5.750381] udevd[135]: starting version 3.2.9 [ 5.839873] udevd[136]: starting eudev-3.2.9 [ 7.705072] EXT4-fs (vda): re-mounted. Opts: (null) Poky (Yocto Project Reference Distro) 3.2 qemuarm ttyAMA0 qemuarm login: • verify it runs
  • 46. 46 Yocto Project® | The Linux Foundation® Hands-On: Prep Poky (Yocto Project Reference Distro) 3.2 qemuarm ttyAMA0 qemuarm login: root root@qemuarm:~# uname -a Linux qemuarm 5.8.13-yocto-standard #1 SMP PREEMPT Tue Oct 6 12:23:42 UTC 2020 armv7l armv7l armv7l GNU/Linux root@qemuarm:~# shutdown -h now ... [ 130.239174] EXT4-fs (vda): re-mounted. Opts: (null) [ 130.242375] reboot: Power down runqemu - INFO - Cleaning up ilab01:~/scratch/build$ lab> • shutdown
  • 47. 47 Yocto Project® | The Linux Foundation® Hands-On: Prep ilab01:~/scratch/build$ lab> bitbake-layers create-layer meta-mytweaks NOTE: Starting bitbake server... Add your new layer with 'bitbake-layers add-layer meta-mytweaks' ilab01:~/scratch/build$ lab> bitbake-layers add-layer meta-mytweaks NOTE: Starting bitbake server... ilab01:~/scratch/build$ lab> • create/add a layer for your changes
  • 48. 48 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel
  • 49. 49 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> devtool modify virtual/kernel ... INFO: Mapping virtual/kernel to linux-yocto ... NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 410 tasks of which 399 didn't need to be rerun and all succeeded. INFO: Copying kernel config to srctree INFO: Source tree extracted to /scratch/build/workspace/sources/linux-yocto INFO: Recipe linux-yocto now set up to build from /scratch/build/workspace/sources/linux-yocto • use devtool (emphasis mine)
  • 50. 50 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> $EDITOR workspace/sources/linux-yocto/init/main.c 1431 /* 1432 * We try each of these until one succeeds. 1433 * 1434 * The Bourne shell can be used instead of init if we are 1435 * trying to recover a really broken machine. 1436 */ 1437 pr_notice("*** --- >>> edit <<< --- ***n"); 1438 if (execute_command) { 1439 ret = run_init_process(execute_command); 1440 if (!ret) 1441 return 0; 1442 panic("Requested init %s failed (error %d).", 1443 execute_command, ret); • edit init/main.c
  • 51. 51 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> bitbake core-image-minimal ... NOTE: linux-yocto: compiling from external source tree /scratch/build/workspace/sources/linux-yocto ... • build (emphasis mine)
  • 52. 52 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> runqemu slirp nographic serial ... [ 4.499808] EXT4-fs (vda): mounted filesystem with ordered data mode. Opts: (null) [ 4.501350] VFS: Mounted root (ext4 filesystem) on device 253:0. [ 4.503554] devtmpfs: mounted [ 4.566689] Freeing unused kernel memory: 2048K [ 4.580415] *** --- >>> edit <<< --- *** [ 4.580672] Run /sbin/init as init process [ 4.675352] usb 1-1: new high-speed USB device number 2 using xhci_hcd INIT: version 2.97 booting ... • test (you might have to scroll up)
  • 53. 53 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> pushd workspace/sources/linux-yocto /scratch/build/workspace/sources/linux-yocto /scratch/build ilab01:~/scratch/build$ lab> git commit -avs -m "init/main.c: add my tweaks" [v5.8/standard/arm-versatile-926ejs c12b5fb34a7c] init/main.c: add my tweaks 1 file changed, 1 insertion(+) ilab01:~/scratch/build$ lab> popd /scratch/build • commit your changes (don't forget upstream-status)
  • 54. 54 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> devtool finish linux-yocto meta-mytweaks ... NOTE: Writing append file /scratch/build/meta-mytweaks/recipes-kernel/linux/linux-yocto_%.bbappend NOTE: Copying 0001-init-main.c-add-my-tweaks.patch to /scratch/build/meta- mytweaks/recipes-kernel/linux/linux-yocto/0001-init-main.c-add-my- tweaks.patch INFO: Cleaning sysroot for recipe linux-yocto... INFO: Leaving source tree /scratch/build/workspace/sources/linux-yocto as-is; if you no longer need it then please delete it manually ilab01:~/scratch/build$ lab> rm -fr workspace/sources/linux-yocto • update your metadata (emphasis mine)
  • 55. 55 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> tree meta-mytweaks meta-mytweaks/ ├── COPYING.MIT ├── README ├── conf │   └── layer.conf └── recipes-kernel └── linux ├── linux-yocto │   └── 0001-init-main.c-add-my-tweaks.patch └── linux-yocto_%.bbappend 4 directories, 5 files • check
  • 56. 56 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux- yocto/0001-init-main.c-add-my-tweaks.patch ... diff --git a/init/main.c b/init/main.c index bf27d2045ea3..5b03552ff7e6 100644 --- a/init/main.c +++ b/init/main.c @@ -1434,6 +1434,7 @@ static int __ref kernel_init(void *unused) * The Bourne shell can be used instead of init if we are * trying to recover a really broken machine. */ + pr_notice("*** --- >>> edit <<< --- ***n"); if (execute_command) { ret = run_init_process(execute_command); • check
  • 57. 57 Yocto Project® | The Linux Foundation® Hands-On: Edit the Kernel ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux- yocto_%.bbappend FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += "file://0001-init-main.c-add-my-tweaks.patch" • check
  • 58. 58 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration
  • 59. 59 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration ilab01:~/scratch/build$ lab> devtool modify virtual/kernel ... NOTE: Tasks Summary: Attempted 410 tasks of which 399 didn't need to be rerun and all succeeded. INFO: Copying kernel config to srctree INFO: Source tree extracted to /scratch/build/workspace/sources/linux-yocto INFO: Recipe linux-yocto now set up to build from /scratch/build/workspace/sources/linux-yocto • use devtool, setup
  • 60. 60 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration ilab01:~/scratch/build$ lab> devtool menuconfig linux-yocto • use devtool
  • 61. 61 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration • navigate to: General Setup Preemption Model • select: No Forced Preemption (Server) • hit double-esc or <Exit> and save your changes INFO: Updating config fragment /scratch/build/workspace/sources/linux-yocto/oe-local-files/devtool- fragment.cfg
  • 62. 62 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration ilab01:~/scratch/build$ lab> bitbake core-image-minimal NOTE: linux-yocto: compiling from external source tree /scratch/build/workspace/sources/linux-yocto ilab01:~/scratch/build$ lab> runqemu slirp nographic serial ... [ 0.037703] rcu: Hierarchical SRCU implementation. ... qemuarm login: root root@qemuarm:~# uname -a Linux qemuarm 5.8.13-yocto-standard #1 SMP Tue Oct 27 04:00:52 UTC 2020 armv7l armv7l armv7l GNU/Linux • test • NOTE: missing "Preemptible hierarchical RCU" and "PREEMPT" in "uname -a"
  • 63. 63 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration ilab01:~/scratch/build$ lab> devtool finish linux-yocto meta-mytweaks ... NOTE: Writing append file /scratch/build/meta-mytweaks/recipes-kernel/linux/linux-yocto_%.bbappend NOTE: Copying devtool-fragment.cfg to /scratch/build/meta-mytweaks/recipes- kernel/linux/linux-yocto/devtool-fragment.cfg INFO: Cleaning sysroot for recipe linux-yocto... INFO: Leaving source tree /scratch/build/workspace/sources/linux-yocto as-is; if you no longer need it then please delete it manually ilab01:~/scratch/build$ lab> rm -fr workspace/sources/linux-yocto • update metadata
  • 64. 64 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration ilab01:~/scratch/build$ lab> tree meta-mytweaks meta-mytweaks/ ├── COPYING.MIT ├── README ├── conf │   └── layer.conf └── recipes-kernel └── linux ├── linux-yocto │   ├── 0001-init-main.c-add-my-tweaks.patch │   └── devtool-fragment.cfg └── linux-yocto_%.bbappend 4 directories, 6 files • check
  • 65. 65 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux- yocto/devtool-fragment.cfg CONFIG_PREEMPT_NONE=y # CONFIG_PREEMPT is not set CONFIG_TREE_RCU=y CONFIG_INLINE_SPIN_UNLOCK_IRQ=y CONFIG_INLINE_READ_UNLOCK=y CONFIG_INLINE_READ_UNLOCK_IRQ=y CONFIG_INLINE_WRITE_UNLOCK=y CONFIG_INLINE_WRITE_UNLOCK_IRQ=y • check
  • 66. 66 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration ilab01:~/scratch/build$ lab> cat meta-mytweaks/recipes-kernel/linux/linux- yocto_%.bbappend FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += "file://0001-init-main.c-add-my-tweaks.patch file://devtool-fragment.cfg " • check (emphasis mine)
  • 67. 67 Yocto Project® | The Linux Foundation® Hands-On: Tweak the Kernel Configuration • NOTE: subsequent menuconfig changes clobber previous changes, so you'll need to move/rename them if you're generating more than one
  • 68. 68 Yocto Project® | The Linux Foundation® Hands-On: alt ilab01:~/scratch/build$ lab> bitbake core-image-minimal -c populate_sdk • if you're not "sold" on the devtool workflow, you could generate an SDK and use that instead • it is then very much like using any other SDK, but this one is tailored to your image • it comes with an environment file that you source which includes (among other things) settings for ARCH and CROSS_COMPILE
  • 69. Yocto Project | The Linux Foundation The Yocto Project Kernel Metadata
  • 70. 70 Yocto Project® | The Linux Foundation® Kernel Metadata • in the hands-on portion you saw an example of a kernel configuration fragment and a patch • the Linux kernel configuration system has always had the ability to handle config fragments, but few have made use of it • patches and configs can be grouped into features • we have tooling to help organize and apply fragments and patches in various conditions
  • 71. 71 Yocto Project® | The Linux Foundation® Kernel Metadata • 3 types of kernel metadata:  scc files  patches  config fragments
  • 72. 72 Yocto Project® | The Linux Foundation® Kernel Metadata - config fragments • we saw this in the hands-on • use devtool or -c menuconfig/-c diffconfig to generate • filename has a *.cfg extension
  • 73. 73 Yocto Project® | The Linux Foundation® Kernel Metadata - patches • we also saw this in the hands-on • use devtool+git or patch or manually use git --format-patch to generate • filename has a *.patch extension
  • 74. 74 Yocto Project® | The Linux Foundation® Kernel Metadata - scc • "scc" = Series Configuration Control • ties together config fragments and/or patches with extra metadata that is useful to the build • filename has an *.scc extension
  • 75. 75 Yocto Project® | The Linux Foundation® Kernel Metadata - e.g. 1 • you have a set of 6 boards:  2 have graphics capabilities  3 can make sounds  1 uses raw flash  4 have DVD devices • you could create sets of *.cfg/*.patch for each feature, described in *scc files, then apply them as required
  • 76. 76 Yocto Project® | The Linux Foundation® Kernel Metadata - e.g. 2 • you have "development" and "production" builds • for development builds you might want to enable more kernel debugging and/or verbosity or NFS or lax security • for production builds you might want to enable more kernel hardening and disable potential security things (i.e. disable modules)
  • 77. 77 Yocto Project® | The Linux Foundation® Kernel Metadata - e.g. 3 • you're creating a BSP layer and some of your boards use one GPU while others use a second GPU and the rest use yet another GPU • you can create metadata for each GPU and include them in your builds as required
  • 78. 78 Yocto Project® | The Linux Foundation® Kernel Metadata - storage • there are 2 places you can store the kernel metadata:  in-tree  in a separate repository • regardless, add the location of the metadata to your SRC_URI variable and be sure to specify "type=kmeta"
  • 79. 79 Yocto Project® | The Linux Foundation® Kernel Metadata - enabling • reference the *.scc file with KERNEL_FEATURES  conf/machine  recipes-kernel/linux
  • 80. 80 Yocto Project® | The Linux Foundation® Kernel Metadata - down the rabbit hole • it's much more sophisticated • you can define kernel types (i.e. KTYPE) and have features enabled based on the kernel type (e.g. -tiny, -dev, -rt) • *.scc files can include other *.scc files but there are ways to say "include this *.scc file but not anything it wants to include"
  • 81. 81 Yocto Project® | The Linux Foundation® Kernel Metadata • examples of in-tree kmeta include:  https://github.com/akuster/meta-odroid  http://git.yoctoproject.org/cgit/cgit.cgi/meta-arm • http://git.yoctoproject.org/cgit/cgit.cgi/meta-raspberrypi is an example of just using *.cfg files without *.scc
  • 82. 82 Yocto Project® | The Linux Foundation® Kernel Metadata • an example of out-of-tree kmeta is:  http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel- cache
  • 83. Yocto Project | The Linux Foundation Recommendations
  • 84. 84 Yocto Project® | The Linux Foundation® Recommendations • use linux-yocto if at all possible  your users will appreciate being able to take advantage of the tooling and features that come with The Yocto Project (i.e. they can tweak the config) • otherwise base your kernel recipe on poky/meta- skeleton/recipes-kernel/linux/linux-yocto-custom.bb inherit kernel require recipes-kernel/linux/linux-yocto.inc