DEV Community

Pavan Kumar
Pavan Kumar

Posted on • Originally published at itspavan.dev on

Yocto Build with RT Kernel Patch for BeagleBone: A Comprehensive Guide

Introduction

Real-time (RT) systems are crucial in many industries, from automotive to robotics, and even aerospace. This blog will guide you on how to build Yocto with a Real-Time kernel patch for BeagleBone - a powerful open hardware computer.

Setting Up the Build Environment

Before we can dive into the details, we need to set up the build environment. This involves cloning Poky and setting up the environment as per the official Yocto Project documentation.

Now, to configure the build environment, we need to modify a few lines in the conf/local.conf file. I've used the following

# Change or verify these following lines
MACHINE ?= "beaglebone-yocto"

PACKAGE_CLASSES ?= "package_deb"
EXTRA_IMAGE_FEATURES ?= "debug-tweaks tools-sdk package-management"

# Add the following
PREFERRED_VERSION_linux-yocto ?= "5.15%"
MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
CORE_IMAGE_EXTRA_INSTALL += "usbinit"

Enter fullscreen mode Exit fullscreen mode

Patching the Kernel and Configuring It

To apply a real-time patch to the kernel and configure it, we have to work with a new layer in Yocto. This layer-creation process includes setting up several directories and adding configuration files, for example, create a new layer called meta-mylayer

mkdir meta-mylayer
mkdir meta-mylayer/conf
mkdir meta-mylayer/recipes-kernel
mkdir meta-mylayer/recipes-kernel/linux
mkdir meta-mylayer/recipes-kernel/linux/linux-yocto

Enter fullscreen mode Exit fullscreen mode

Now, fill the configuration of the layer in meta-mylayer/conf/layer.conf as follows

# 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 += "mylayer"
BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"
BBFILE_PRIORITY_mylayer = "5"

Enter fullscreen mode Exit fullscreen mode

add a file called linuxyocto_5.15.bbappend in meta-mylayer/recipes-kernel/linux and add the following

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

KBRANCH:genericx86 = "v5.15/standard/base"
KBRANCH:genericx86-64 = "v5.15/standard/base"
KBRANCH:edgerouter = "v5.15/standard/edgerouter"
KBRANCH:beaglebone-yocto = "v5.15/standard/beaglebone"

KMACHINE:genericx86 ?= "common-pc"
KMACHINE:genericx86-64 ?= "common-pc-64"
KMACHINE:beaglebone-yocto ?= "beaglebone"

SRCREV_machine:genericx86 ?= "efe20512212b0e85b5f884b1bfc8fbba2b43541a"
SRCREV_machine:genericx86-64 ?= "efe20512212b0e85b5f884b1bfc8fbba2b43541a"
SRCREV_machine:edgerouter ?= "90f1ee6589264545f548d731c2480b08a007230f"
SRCREV_machine:beaglebone-yocto ?= "9aabbaa89fcb21af7028e814c1f5b61171314d5a"

COMPATIBLE_MACHINE:genericx86 = "genericx86"
COMPATIBLE_MACHINE:genericx86-64 = "genericx86-64"
COMPATIBLE_MACHINE:edgerouter = "edgerouter"
COMPATIBLE_MACHINE:beaglebone-yocto = "beaglebone-yocto"

LINUX_VERSION:genericx86 = "5.15.59"
LINUX_VERSION:genericx86-64 = "5.15.59"
LINUX_VERSION:edgerouter = "5.15.54"
LINUX_VERSION:beaglebone-yocto = "5.15.54"

SRC_URI += "file://usbeth.cfg"
SRC_URI += "file://patch-5.15.55-rt48.patch"

Enter fullscreen mode Exit fullscreen mode

Now, we need to get the patch and add the configuration file usbeth.cfg in meta-mylayer/recipes-kernel/linux/linux-yocto

Please get the patch from here (you can get a newer version, but ensure it is compatible with your kernel) and unzip it in the above directory and add the following for the usbeth.cfg in the same directory as well to configure USB, USB ethernet

CONFIG_USB_ETH=y
CONFIG_USB_G_NCM=m
CONFIG_USB_MASS_STORAGE=y

Enter fullscreen mode Exit fullscreen mode

Now, go back to the poky build directory and add this new layer to the belayers by running the following

cd ~/poky/build
bitbake-layers add-layer ../../meta-mylayer

Enter fullscreen mode Exit fullscreen mode

Building the Image and Transferring It to an SD Card

With everything set up and configured, the next step is building the image using bitbake core-image-minimal. Please note that this process can be quite time-consuming, so be patient.

Once completed, the image files are stored in the <build directory>/tmp/deploy/images/beaglebone-yocto/ directory. Then you need to transfer this image onto your SD card using the dd command.

Conclusion

Building Yocto with a Real-Time kernel patch for BeagleBone might seem like a complex task, but with this comprehensive guide, you can handle it with ease. Remember to login into Yocto via serial as root.

Top comments (0)