Debian Edit Modify Build and Flash Kernel

From Variscite Wiki
DART-6UL - Customizing the Debian Linux kernel


This section describes how to build a new kernel configuration using menuconfig and deploy it.

Building a custom device tree

To build and install a custom device tree, add the filename to the variable G_LINUX_DTB of the machine-specific file.

We will demonstrate it here exemplarily with the VAR-SOM-MX8M-NANO, but the same applies also to other modules.
Assuming you have created a custom device tree arch/arm64/boot/dts/freescale/imx8mn-var-som-custom.dts, you can add this to the G_LINUX_DTB list

G_LINUX_DTB="freescale/imx8mn-var-som-symphony.dtb
	freescale/imx8mn-var-som-symphony-root.dtb
	freescale/imx8mn-var-som-symphony-m7.dtb
	freescale/imx8mn-var-som-symphony-legacy.dtb
	freescale/imx8mn-var-som-symphony-legacy-root.dtb
	freescale/imx8mn-var-som-symphony-legacy-m7.dtb
	freescale/imx8mn-var-som-inmate.dtb"

for example, at the end:

G_LINUX_DTB="freescale/imx8mn-var-som-symphony.dtb
	freescale/imx8mn-var-som-symphony-root.dtb
	freescale/imx8mn-var-som-symphony-m7.dtb
	freescale/imx8mn-var-som-symphony-legacy.dtb
	freescale/imx8mn-var-som-symphony-legacy-root.dtb
	freescale/imx8mn-var-som-symphony-legacy-m7.dtb
	freescale/imx8mn-var-som-inmate.dtb
	freescale/imx8mn-var-som-custom.dtb"

File: ~/var_mx6ul_dart_debian/variscite/imx8mn-var-som/imx8mn-var-som.sh

After running the build script:

sudo MACHINE=imx8mn-var-som ./var_make_debian.sh -c kernel

the custom device tree should appear in the output folder: ~/var_mx6ul_dart_debian/output/imx8mn-var-som-custom.dtb

Configuring the kernel

The default kernel configuration file used by Debian is part of the kernel source tree and is located at:

~/var_mx6ul_dart_debian/src/kernel/arch/arm/configs/imx_v7_var_defconfig

Modifying the kernel configuration

To modify the kernel configuration (add/remove features and drivers) please follow the steps below:

$ cd ~/var_mx6ul_dart_debian/src/kernel
$ sudo make ARCH=arm mrproper
$ sudo make ARCH=arm imx_v7_var_defconfig
$ sudo make ARCH=arm menuconfig

Navigate the menu and select the desired kernel functionality

Exit the menu and answer "Yes" when asked "Do you wish to save your new configuration?"

$ sudo make ARCH=arm savedefconfig
$ sudo cp arch/arm/configs/imx_v7_var_defconfig arch/arm/configs/imx_v7_var_defconfig.orig
$ sudo cp defconfig arch/arm/configs/imx_v7_var_defconfig

Building a new kernel configuration

Build the kernel image, dtb files and kernel modules

$ cd ~/var_mx6ul_dart_debian
$ sudo ./make_var_mx6ul_dart_debian.sh -c kernel
$ sudo ./make_var_mx6ul_dart_debian.sh -c modules
$ sudo ./make_var_mx6ul_dart_debian.sh -c kernelheaders


Note: If you have modules newly added / removed, make sure you run the following command:
$ sudo ./make_var_mx6ul_dart_debian.sh -c rtar
$ sudo ./make_var_mx6ul_dart_debian.sh -c rubi

This will create rootfs.tar.gz and rootfs.ubi.img files that contain your new modules.

Deploy the kernel image, dtb files and kernel modules

Deploy Kernel, dtb via network

Updating Device tree to target

Transfer dtbs to target
On PC:

$ cd ~/var_mx6ul_dart_debian
$ scp output/*.dtb root@<yourboard-ip>:/tmp/

Once prompted give root as password. <yourboard-ip> is ipaddress of your board.
Once transfer is done, follow below commands
On Target Console:

# mkdir -p /media/boot/
# mount /dev/mmcblk1p1 /media/boot/
# cp /tmp/*.dtb /media/boot/;sync;reboot
Note: If you just intend to do dtb, then only follow this section and reboot the target


Updating kernel Image to target

Transfer the output/zImage kernel image to target
On PC:

$ scp output/zImage root@<yourboard-ip>:/tmp/

Once prompted give root as password. <yourboard-ip> is ipaddress of your board.
Once transfer is done, follow below commands
On Target Console:

# mkdir -p /media/boot/
# mount /dev/mmcblk1p1 /media/boot/
# cp /tmp/*.dtb /media/boot/;sync;reboot