How to change Linux Kernel configuration file in Yocto Project metalayer
It is common that the metalayer providing a Linux Kernel recipe includes a default configuration file for the Linux Kernel source code (the defconfig file).
There are several approaches to customize the Linux Kernel source code and defconfig file. This article presents the option to patch the defconfig from the Linux Kernel source code and is a good approach to be used with meta-fsl-bsp-release or meta-imx.
Preparing the requirements
The list of requirements:
the target metalayer (in this example, it's meta-imx:imx-5.4.3-2.0.0)
the same Linux Kernel source code, but git cloned
Download the metalayer
For example, take BSP release imx-5.4.3-2.0.0 for meta-imx
Use the very same Linux Kernel source code from the metalayer. In this example, open the file sources/meta-imx/meta-bsp/recipes-kernel/linux/linux-imx_5.4.bb to get the git repository, and git commit.
$ cd ~
$ git clone git://source.codeaurora.org/external/imx/linux-imx.git
$ cd linux-imx
$ git checkout fd263a3edd95dfe812397fabf1059b5f99bba2ab -b change_defconfig
Customize the configuration
Using the default defconfig as a base, configure the Linux Kernel, and then use make menuconfig to change the configuration as desired.
After the customization, generate a new defconfig file and replace the default one.
The step by step with all the commands can be see in next snippet:
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-
$ make defconfig
$ make menuconfig
$ make savedefconfig
$ cp defconfig arch/arm64/configs/defconfig
The customization can be highlighted by git, in this example the result is show in next log:
$ git status
On branch change_defconfig
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(use "git add <file>..." to include in what will be committed)
no changes added to commit (use "git add" and/or "git commit -a")
Review the change and create a commit, with that commit, create a patch.
TIP: The defconfig file can also be directly changed. The make menuconfig can be skipped in that case.