Trucrux Inc

Linux Kernel Configuration

Customizing Linux Kernel #

Updating Defconfig #

Default path to kernal

build_xwayland/tmp/work/imx8mq-trux-q01-fslc-linux/linux-trucrux/5.4.142+gitAUTOINC+91e04665c4-r0/git/

Kernel can be customized using bitbake menuconfig command

$ cd ~/CodeSetup/
$ source setup-environment build_xwayland
$ bitbake -c menuconfig virtual/kernel

Now customize kernel by selecting options using

"*" = build in
"M" = Modular
" " = not selected

once finished save and exit.

The .config file is stored in

~/CodeSetup/build_xwayland/tmp/work/imx8mq-trux-q01-fslc-linux/linux-fslc-trucrux/5.4.142-r0/build/.config

Once the configuration is done the file has to be saved as a defconfig file. To save configuration as a defconfig file

$ bitbake -c savedefconfig virtual/kernel

The defconfig will be saved in

~/CodeSetup/build_xwayland/tmp/work/imx8mq-trux-q01-fslc-linux/linux-fslc-trucrux/5.4.142-r0/build/defconfig

now to apply the defconfig during kernel build, copy defconfig file to “meta-trucrux/recipies-kernel/linux/files/” as shown below.

If “files” directory is not present, create a new “files” directory

$ cd CodeSetup/build_xwayland/tmp/work/imx8mq-trux-q01-fslc-linux/linux-fslc-trucrux/5.4.142-r0/build
$ cp defconfig ~/CodeSetup/sources/meta-trucrux/recipies-kernel/linux/files/

Create a bbappend file

$ cd CodeSetup/sources/meta-trucrux/recipes-kernel/linux/
$ touch linux-trucrux_%.bbappend
$ vi linux-trucrux_%.bbappend

now add the following lines in bbappend file

SRC_URI += "file://defconfig"
KBUILD_DEFCONFIG_imx8mq-trux-q01 = "${WORKDIR}/defconfig"

bitbake linux kernel

$ bitbake linux-trucrux

Customizing Source Code #

To make changes in source code creating a local_repos is recommended.

$ cd ~/CodeSetup
$ mkdir local_repos
$ git clone https://github.com/Trucrux/linux-fslc-trucrux.git -b v5.4.142_dunfell

now use git to create a branch or make changes in same branch (creating new branch is recommended)

Make required changes in the kernel.

To include the changes during kernel build create a bbappend file as shown below:

$ cd ~/CodeSetup/sources/meta-trucrux/recipies-kernel/linux
$ touch linux-trucrux_5.4.bbappend

(ignore if bbappend is already exist)
and append the following in bbappend file

KERNEL_SRC = "git://${BSPDIR}/local_repos/linux-fslc-trucrux;protocol=file"
SRCBRANCH = "< branch name > "
SRCREV = "The commit id you'd like to use"

bitbake linux kernel

$ bitbake linux-trucrux

NOTE: bbappend files apply changes during runtime