In the previous lesson from this guide, you have learned the basics of cross C/C++ application development with the Yocto Project and the Eclipse IDE.
In this lesson, you will learn how to customize the Linux kernel configuration and add an out-of-tree module with the Yocto Project. You will:
Even though it is a common request from our customers, it may not apply to your project. If that is the case, feel free to skip this lesson.
The Verdin iMX8M Plus has been released on April 2021. As of this date, the software support for this Computer on Module is in an early stage of development and a few features are currently a work-in-progress:
Our teams are working at a fast pace to bring all of those features to you in the next weeks. To follow-up on the latest status, you can:
For this Quickstart Guide:
For this Quickstart Guide:
For this lesson:
On the board, get the current kernel configuration into a file named defconfig
:
# zcat /proc/config.gz > /home/root/defconfig
Create a bbappend file for the Linux kernel inside your custom layer:
Your recipe recipes-kernel/linux/linux-toradex_%.bbappend
only needs the first line from the example. It will look like this:
recipes-kernel/linux/linux-toradex_%.bbappend# Use our own defconfig instead of the ones provided by default FILESEXTRAPATHS_prepend := "${THISDIR}/linux-toradex:" SRC_URI += " \ file://defconfig \ " # Prevent the use of in-tree defconfig unset KBUILD_DEFCONFIG
This will instruct the Yocto Project/OpenEmbedded to use files from your custom layer first if they also exist on other layers.
On your PC, copy the file from the board into your layer:
$ mkdir -p <path to your layer>/recipes-kernel/linux/linux-toradex
$ scp root@<board IP address>:/home/root/defconfig <path to your layer>/recipes-kernel/linux/linux-toradex/
To make sure that your kernel configuration applies, change the value of CONFIG_CONSOLE_LOGLEVEL_DEFAULT
from 7 to 6 in the defconfig
file.
Create a recipe for a custom kernel module:
The example states to add the kernel module to your machine configuration file. Since we want to make it simple, let's ignore it and just add the kernel-module-hello
to your custom image file for the moment:
custom-multimedia-hello-image.bb... IMAGE_INSTALL_append = " \ hello-world \ kernel-module-hello \ "
Rebuild the image:
$ bitbake custom-multimedia-hello-image
Install the new image as described on previous lessons from this Quickstart Guide.
After booting the new image, check that your custom kernel configuration has been applied:
# zcat /proc/config.gz | grep CONFIG_CONSOLE_LOGLEVEL_DEFAULT
CONFIG_CONSOLE_LOGLEVEL_DEFAULT=6
Load the custom kernel module to confirm that it has been deployed correctly:
# modprobe hello
[ 155.403451] Hello World!
See it loaded:
# lsmod
Module Size Used by
hello 16384 0
...
Unload it:
# modprobe -r hello
[ 296.610590] Goodbye Cruel World!
Often while doing kernel development, you might want to manually download the kernel sources and iteratively compile and deploy to the board until you are satisfied with the result, as described on Build U-Boot and Linux Kernel from Source Code. Only then you will add your final customization to the Yocto Project/OpenEmbedded.
In this lesson, you have focused on modifying the kernel configuration and deploying a custom, out-of-tree, kernel module. Nevertheless, it is also possible to deploy custom device trees and apply patches to the kernel and the U-Boot bootloader. We provide a starting point for some of those operations on Custom meta layers, recipes and images in Yocto Project (hello-world examples), and we strongly recommend you to study the Yocto Project Documentation, especially the Yocto Project Linux Kernel Development Manual.