Debian Customizing the Linux kernel
Introduction
This guide demonstrates how to patch and rebuild Debian Linux images.
After customizing the kernel by following the instructions below, you can either build your complete image with var_build_image or you can build the kernel alone by running:
$ bld -f sdk-var.yml -m MACHINE=imx8mm-var-dart linux
(see the Build Debian from source code page for the initial setup and for more info on using Flexbuild commands).
Requirements
Before modifying the Kernel source code, follow steps 1-3.1 of the Build Linux from source code page.
Modifying the Kernel
Make the desired changes to the Kernel source code
Example:
$ cd ${WORKDIR}/ $ vim ./drivers/net/can/m_can/m_can.c $ vim ./drivers/net/can/m_can/m_can.h
Configuring the Kernel
The default kernel configuration file used by Flexbuild is part of the kernel source tree and is located at:
arch/arm64/configs/imx8_var_defconfig
Clean and prepare the kernel:
$ cd ${WORKDIR}/ $ make mrproper $ make imx8_var_defconfig
Customize the kernel configuration:
$ make menuconfig (Ps: Once you finish configuring the Kernel, save it to the .config file.) $ make savedefconfig $ mv defconfig arch/arm64/configs/imx8_var_defconfig
Generate a patch
Commit the changes locally and generate a patch
$ git add . $ git commit -e $ git format-patch -1
Build modified Linux
Make sure you set up the Flexbuild Docker environment properly. Follow the instructions from step 5 of the Build Debian from source code page.
Add your patches on top of the Variscite source code
Flexbuild will retrieve the source code from our default remote repository and apply your patches before building it.
Once the patch is created, copy it to the Linux patch folder, which is inside the Flexbuild directory:
$ mkdir -p [...]/flexbuild/patch/linux/ $ cp 0001-my-changes.patch [...]/flexbuild/patch/linux/
Build Linux individually
Do not run any 'git am' or 'git apply' command. That will be done inside the Linux Makefile.
Now, if you're not inside the container, get in with the following commands:
$ cd [...]/flexbuild (Outside Docker environment) $ . setup.env (Outside Docker environment) $ bld docker (Outside Docker environment) $ . setup.env (Inside Docker environment)
Once you've entered the Docker environment, run:
$ bld -f sdk-var.yml -m imx8mm-var-dart linux (Inside Docker environment)
Rebuild Linux
Once you've built Linux, a clean step is needed if a rebuild is required:
$ bld clean-linux (Inside Docker environment)
Then, build Linux normally with:
$ bld -f sdk-var.yml -m imx8mm-var-dart linux (Inside Docker environment)