TipsAndTricks/DemystifyingTheLinuxYoctoKernel

From Yocto Project
Revision as of 20:40, 27 June 2016 by Tzanussi (talk | contribs)
Jump to navigationJump to search

Despite the existence of plenty of in-depth documentation out there on working with kernels in Yocto, most people seem to still view the subject as 'a riddle, wrapped in a mystery, inside an enigma'. [1][2]

This is the first in what should be a short series of articles dealing with Yocto kernels, focusing only on the bare essentials.

Let's start first with the kernel itself. When most people think of a kernel in Yocto, they tend to think of it as something that's wrapped inside a kernel recipe, which in turn is something that's wrapped inside the build system and generated into the final image. That's all true and valid, but all those extra layers (let's call them the mystery and the enigma for now) obscure the kernel of truth at the center (the riddle). Let's just look at the riddle and come back some other day to explain the mystery and the enigma.

At its heart, a Yocto kernel is just exactly the same thing as an upstream Linux kernel.

To make that point clear, let's take a quick look at a typical kernel development workflow outside of Yocto (don't let the phrase 'kernel development workflow' scare you off - for the purposes of this article it just refers to compiling and building and possibly configuring a kernel, which is something anyone dealing with a build system like Yocto should be comfortable with).

To configure, build, and boot a new kernel outside of Yocto, you'd typically do something like this[3]:

$ make menuconfig
.
.
select/deselect new config items
.
.
$ make bzImage
$ scp arch/x86/boot/bzImage 10.0.0.18/mnt/bzImage
.
.
reboot target and see changes

The same thing in Yocto would be:

$ bitbake -c menuconfig virtual/kernel
.
.
select/deselect new config items
.
.
$ bitbake -c compile -f virtual/kernel
$ scp tmp/work/core2-32-intel-common-poky-linux/linux-yocto/4.1.26+gitAUTOINC+9f68667031_9195020e57-r0/linux-core2-32-intel-common-standard-build/arch/x86/boot/bzImage 10.0.0.18:/mnt/bzImage
.
.
reboot target and see changes

As you can see, the only differences in the Yocto version are trivial: in Yocto, you use 'bitbake' instead of 'make', and in Yocto, you have to deal with a godawful long and ugly path to the final kernel image. [4]


[1] Yocto kernel labs

[2] Yocto Kernel Development Manual

[3] This assumes that the target is network-connected and you've mounted the boot partition at /mnt on the target, e.g.:

$ mount /dev/mmcblk0p1 /mnt

[4] This is nothing mysterious either. Just start at the build directory and follow the path to the kernel like so (this is just a typical example - there normally aren't many ways to get lost, making it look worse than it is):

$ cd tmp
$ cd work
$ cd core2-32-intel-common-poky-linux
$ cd linux-yocto
$ cd 4.1.26+gitAUTOINC+9f68667031_9195020e57-r0
$ cd linux-core2-32-intel-common-standard-build
$ scp arch/x86/boot/bzImage target:/mnt/bzImage