# Yocto support

The Qualcomm Linux `meta-qcom-hwe` layer supports `linux-qcom-base_6.6.bb` and `linux-qcom-custom_6.6.bb` recipes that fetch and build the Qualcomm Linux kernel for supported machines.

For more information about available recipes, see [Build the Yocto image recipes and kernel configurations](https://docs.qualcomm.com/doc/80-70018-3/topic/getting_started_chapter2.html#kernel-configuration-image).

## Retrieve the kernel source

Fetch the kernel source from the CodeLinaro repository as a part of BitBake builds.

**Yocto kernel**

MACHINE=<SoC>-<board>-<variant> DISTRO=qcom-wayland source setup-environment
    bitbake qcom-console-image
    
    # kernel source is downloaded under following location
      ls build-qcom-wayland/tmp-glibc/work-shared/<SoC>-<board>-<variant>/kernel-source/
      arch     Documentation  ipc       MAINTAINERS  samples   virt
      block    drivers        Kbuild    Makefile     scripts
      certs    fs             Kconfig   mm           security
      COPYING  include        kernel    net          sound
      CREDITS  init           lib       README       tools
      crypto   io_uring       LICENSES  rust         usr
    Copy to clipboard

Note

Machine name for the previous commands is the same as the SoC-board-variant name. For example, for the QCS6490 SoC, `QCS6490` is the machine name, `rb3gen2` is the board, and `Visionkit` is the variant.

For more information about the setup and obtaining a source, see the
[Qualcomm Linux Build Guide](bundle/publicresource/topics/80-70018-254).

## Retrieve the kernel recipe

Qualcomm Linux maintains the `meta-qcom-hwe` layer and hosts kernel recipe files at the following locations:

- Base BSP: `meta-qcom-hwe/recipes-kernel/linux//linux-qcom-base_6.6.bb` file.
- Custom BSP: `meta-qcom-hwe/recipes-kernel/linux//linux-qcom-custom_6.6.bb` file.

`PREFERRED_PROVIDER_virtual/kernel` is defined as
`linux-qcom-base` or `linux-qcom-custom` in the
`meta-qcom-hwe/conf/machine/include/qcom-base.inc` file.

For the kernel recipe, run the following commands:

# kernel recipe location
       ls -l meta-qcom-hwe/recipes-kernel/linux/
       linux-kernel-headers-install_6.6.bb
       linux-kernel-qcom-headers_6.6.bb
       linux-qcom-base-6.6
       linux-qcom-base_6.6.bb
       linux-qcom-custom
       linux-qcom-custom_6.6.bb
    Copy to clipboard

## Unpack the kernel source

Unpack the kernel source for development and customization after cloning the meta layer.

To unpack the source code, run the following commands:

# unpack kernel
    # checkout kernel source aligned to upstream LTS base with patches applied from recipe
    # Following would checkout kernel source in build-qcom-wayland/workspace/sources/linux-qcom-base/
    $  devtool modify linux-qcom-base
    Copy to clipboard

Note

For the custom BSP variant, use `linux-qcom-custom`.

## Make kernel changes

Kernel changes or customizations are done in the
`build-qcom-wayland/workspace/sources/linux-qcom-base` workspace.

To modify the kernel configuration, run the following commands:

# Modify sources in build-qcom-wayland/workspace/sources/linux-qcom-base, or update kernel configuration by running makemenufonfig
      devtool menuconfig linux-qcom-base
    
    # config fragment is updated in following location
      ls build-qcom-wayland/workspace/sources/linux-qcom-base/oe-local-files/devtool-fragment.cfg
    devtool-fragment.cfg
    
    # you may do other changes to kernel and commit
    Copy to clipboard

Note

For the custom BSP variant, use `linux-qcom-custom`.

## Commit kernel changes

To commit your changes, run the following Git commands:

cd build-qcom-wayland/workspace/sources/linux-qcom-base
    git add .
    git commit -s -m "my changes"
    Copy to clipboard

## Build the kernel image

After the changes are done, to build the kernel and the image, run the following commands:

> 
> 
> # to build kernel use
>       devtool build linux-qcom-base
>     Copy to clipboard

# and following to build the image
      devtool build-image qcom-console-image
    Copy to clipboard

# built images are produced in standard location
      ls build-qcom-wayland/tmp-glibc/deploy/images/<SoC>-<board>-<variant>/
    Copy to clipboard

Note

To compile the custom BSP, use `linux-qcom-custom`.

## Maintain kernel changes

Use Devtool to develop and export the patch and create an append file in
the `meta-mylayer` layer. To create your own layer, first add it to
the host kernel `bbappend` files and make changes.

To create and append kernel patches in the meta layer, run the following commands:

# create your own layer first and add it to host kernel bbappend and changes
      bitbake-layers create-layer ~/meta-mylayer
    # mkdir -p ~/meta-mylayer/recipes-kernel/linux/linux-qcom-base
      bitbake-layers add-layer ~/meta-mylayer
    
    # following would update the meta-mylayer recipe and the change
      devtool finish linux-qcom-base ~/meta-mylayer
    
    # devtool finish shall populate the meta-mylayer recipes along with patches,
    
      ls -R meta-mylayer/recipes-kernel/
    meta-mylayer/recipes-kernel/:
    linux
    
    meta-mylayer/recipes-kernel/linux:
    linux-qcom-base  linux-qcom-base_%.bbappend
    
    meta-mylayer/recipes-kernel/linux/linux-qcom-base:
    0001-my-patch.patch  devtool-fragment.cfg
    
      less meta-mylayer/recipes-kernel/linux/linux-qcom-base%.bbappend
    FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
    
    SRC_URI += "file://devtool-fragment.cfg \
                file://0001-my-patch.patch"
    Copy to clipboard

After running the `devtool finish` command, the `~/meta-mylayer`
layer is updated with the following:

- Corresponding kernel changes hosted as patches in
`meta-mylayer/recipes-kernel/linux/linux-qcom-base/*.patch`.
- Add and update
`meta-mylayer/recipes-kernel/linux/linux-qcom-base_%.bbappend SRC_URI`
with these patches.
- Remove `build-qcom-wayland/workspace` after the development is
completed.

Note

For the custom BSP variant, use `linux-qcom-custom`.

## Clean up the workspace

To clean up the workspace, use the following Devtool and BitBake commands:

# to remove layer
      bitbake-layers remove-layer ~/meta-mylayer
    
    # to clean complete workspace
      bitbake -c cleanall <recipe-name>
    
    # reset using Devtool
      devtool reset linux-qcom-base
    
    # manually delete the workspace directory
      rm -rf build-qcom-wayland/workspace/sources/linux-qcom-base
    Copy to clipboard

Last Published: Apr 10, 2025

[Previous Topic
Real-time (RT) kernel overview](https://docs.qualcomm.com/bundle/publicresource/80-70018-3/topics/real_time_kernel_overview.md) [Next Topic
Customize the kernel](https://docs.qualcomm.com/bundle/publicresource/80-70018-3/topics/customize.md)