When we have a small amount of changes or we don't own the source repository, we may be forced to work with patches and use the Yocto build system to build the Linux kernel.
A typical workflow when working on a modification would be as follows:
- Start the kernel package compilation from scratch:
$ cd /opt/yocto/fsl-community-bsp/ $ source setup-environment wandboard $ bitbake -c cleanall virtual/kernel
This will erase the build folder, shared state cache, and downloaded package source.
- Configure the kernel as follows:
$ bitbake -c configure virtual/kernel
This will convert the machine defconfig file into a .config file and call oldconfig to validate the configuration with the kernel source.
- You can optionally add your own configuration changes with the following:
$ bitbake -c menuconfig virtual/kernel
- Now, to modify the kernel source, start a development shell on the kernel:
$ bitbake -c devshell virtual/kernel
This spawns a new shell with the environment ready for kernel compilation. The new shell will change to the kernel build directory, which contains a local Git repository.
We can then perform our modifications, including kernel configuration changes.
- Go back to the Terminal with the sourced Yocto environment to compile the source without erasing our modifications as follows:
$ bitbake -C compile virtual/kernel
Note the capital C. This invokes the compile task but also all the tasks that follow it.
The kernel source is placed under the tmp/work-shared/wandboard folder. A kernel-source directory contains the checked-out source, and kernel-build-artifacts contains the build output, defconfig file, map file, and everything required to build external modules. The work-shared directory is used for packages that need to be kept outside of the shared state control.
The newly compiled kernel image is available under tmp/deploy/images/wandboard.