3.2. Using Kernel Metadata in a Recipe

As mentioned in the introduction, the Yocto Project contains kernel Metadata, which is located in the yocto-kernel-cache Git repository. This Metadata defines Board Support Packages (BSPs) that correspond to definitions in linux-yocto recipes for corresponding BSPs. A BSP consists of an aggregation of kernel policy and enabled hardware-specific features. The BSP can be influenced from within the linux-yocto recipe.

Note

A Linux kernel recipe that contains kernel Metadata (e.g. inherits from the linux-yocto.inc file) is said to be a "linux-yocto style" recipe.

Every linux-yocto style recipe must define the KMACHINE variable. This variable is typically set to the same value as the MACHINE variable, which is used by BitBake. However, in some cases, the variable might instead refer to the underlying platform of the MACHINE.

Multiple BSPs can reuse the same KMACHINE name if they are built using the same BSP description. Multiple Corei7-based BSPs could share the same "intel-corei7-64" value for KMACHINE. It is important to realize that KMACHINE is just for kernel mapping, while MACHINE is the machine type within a BSP Layer. Even with this distinction, however, these two variables can hold the same value. See the BSP Descriptions section for more information.

Every linux-yocto style recipe must also indicate the Linux kernel source repository branch used to build the Linux kernel. The KBRANCH variable must be set to indicate the branch.

Note

You can use the KBRANCH value to define an alternate branch typically with a machine override as shown here from the meta-yocto-bsp layer:
     KBRANCH_edgerouter = "standard/edgerouter"
            

The linux-yocto style recipes can optionally define the following variables:

     KERNEL_FEATURES
     LINUX_KERNEL_TYPE
        

LINUX_KERNEL_TYPE defines the kernel type to be used in assembling the configuration. If you do not specify a LINUX_KERNEL_TYPE, it defaults to "standard". Together with KMACHINE, LINUX_KERNEL_TYPE defines the search arguments used by the kernel tools to find the appropriate description within the kernel Metadata with which to build out the sources and configuration. The linux-yocto recipes define "standard", "tiny", and "preempt-rt" kernel types. See the "Kernel Types" section for more information on kernel types.

During the build, the kern-tools search for the BSP description file that most closely matches the KMACHINE and LINUX_KERNEL_TYPE variables passed in from the recipe. The tools use the first BSP description it finds that match both variables. If the tools cannot find a match, they issue a warning.

The tools first search for the KMACHINE and then for the LINUX_KERNEL_TYPE. If the tools cannot find a partial match, they will use the sources from the KBRANCH and any configuration specified in the SRC_URI.

You can use the KERNEL_FEATURES variable to include features (configuration fragments, patches, or both) that are not already included by the KMACHINE and LINUX_KERNEL_TYPE variable combination. For example, to include a feature specified as "features/netfilter/netfilter.scc", specify:

     KERNEL_FEATURES += "features/netfilter/netfilter.scc"
        

To include a feature called "cfg/sound.scc" just for the qemux86 machine, specify:

     KERNEL_FEATURES_append_qemux86 = " cfg/sound.scc"
        

The value of the entries in KERNEL_FEATURES are dependent on their location within the kernel Metadata itself. The examples here are taken from the yocto-kernel-cache repository. Each branch of this repository contains "features" and "cfg" subdirectories at the top-level. For more information, see the "Kernel Metadata Syntax" section.