The Yocto build system handles all the steps needed to build the kernel from scratch by following the Yocto recipes. Making a change to the kernel implies changing these recipes, but sometimes you only want to test a small, temporary change. In this case, run the following commands in your Yocto project folder:
source dey-setup-environment bitbake -c devshell virtual/kernel
Yocto automatically fetches and unpacks the kernel sources. A new terminal opens in <project_folder>/tmp/work-shared/<platform>/kernel-source so you can modify the source code as you see fit. This applies to device trees and kernel configuration files as well.
Once you have made your changes, compile the images as you would with a standard Linux source tree (see Build standalone/external images). The built kernel binary and device tree blobs are available in the devshell directory under arch/arm/boot and arch/arm/boot/dts, respectively. If you want to use the Yocto build system instead, run this command from your project folder:
bitbake -C compile virtual/kernel
|The (capital) -C makes bitbake execute the compile command plus the ones that follow it, and it also forces the build while keeping any changes in the temporary directory. (Using -c discards these changes.)|
You can find the kernel binary and the device tree blobs in tmp/deploy/images/<platform>.
Change kernel configuration
To make a quick and temporary change to the kernel configuration, run:
bitbake -c menuconfig virtual/kernel
Change the kernel configuration as needed, then save and close the configuration tool. Yocto now builds the kernel with your custom configuration.
Once you have tried your changes, you can discard them and let Yocto build the kernel from scratch by issuing the following commands:
bitbake -c cleanall virtual/kernel bitbake virtual/kernel