# Yocto support 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 on available recipes, see [Build the Yocto image recipes and kernel configurations](https://docs.qualcomm.com/doc/80-70015-3/topic/getting_started_chapter2.html#kernel-configuration-image). ## Kernel source Fetch the kernel source from the CodeLinaro repository as a part of BitBake builds. **Yocto kernel** $ MACHINE=-- 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/--/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 QCS6490 SoC, the machine name is `QCS6490`, `rb3gen2` is the board, and `Visionkit` is the variant. For more information on the setup and obtaining a source, see the [Qualcomm Linux Build Guide](bundle/publicresource/topics/80-70015-254). ## Kernel recipe Qualcomm Linux maintains `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. The `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 kernel source Unpack the kernel source for development and customization after cloning the meta layer. To unpack the source code, use 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 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, use 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 custom BSP variant, use `linux-qcom-custom`. ## Commit kernel changes Use the following Git commands to commit your changes: $ cd build-qcom-wayland/workspace/sources/linux-qcom-base $ git add . $ git commit -s -m "my changes" Copy to clipboard ## Build kernel image After the changes are done, to build the kernel and the image, use the following procedure: # to build kernel use $ devtool build linux-qcom-base # and following to build the image $ devtool build-image qcom-console-image # built images are produced in standard location $ ls build-qcom-wayland/tmp-glibc/deploy/images/--/ 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, `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 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 # 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: Oct 15, 2024 [Previous Topic Features](https://docs.qualcomm.com/bundle/publicresource/80-70015-3/topics/features.md) [Next Topic Customize](https://docs.qualcomm.com/bundle/publicresource/80-70015-3/topics/customize.md)