Standalone Kernel Development

Building the BSP in its entirety has a fairly large learning curve and significantly larger system requirements on the Host Machine when compared to building just the individual components of the image. For these reasons (and others), the Yocto Project can be very cumbersome to use as your primary means of developing things like the Linux kernel. When possible, it is best to clone the kernel repo independently of the overall BSP in order to customize it for your application requirements.

The goal of this guide is to provide you with a quick reference for setting up and building the stock PD21.1.0 kernel independently, without The Yocto Project. This can then serve as a starting point for kernel development.

Note

Eventually, you will have a set of patches that modify the Linux kernel such that phyCORE-i.MX8X SOM is able to meet your unique application requirements. This collection of patches should eventually be consolidated into a custom Meta-Layer specific to your system and added in a modular way to the BSP so that they are incorporated into the production-ready software image automatically. Checkout the Create a Custom Meta Layer guide when you are ready to begin finalizing your production image.

Requirements

In order to build the kernel repository independently of the overall BSP, you will need to install a compatible toolchain for the phyCORE-i.MX8X.

  • A toolchain is conveniently included in the pre-built SDK so head over to the Install the SDK guide and run through those steps first if you haven’t already done so.

  • Remember to source the cross-compilation environment if you previously installed the SDK but are using a new terminal session.

Clone the Linux kernel

Clone the PHYTEC kernel repository using the release tag corresponding to the BSP PD21.1.0:

Host (Ubuntu)
cd ~
git clone https://stash.phytec.com/scm/pub/linux-phytec-fsl.git --branch BSP-Yocto-FSL-i.MX8X-PD21.1.0

Make

The kernel build system leverages various environment variables and makefiles to build the kernel and it’s components for a specific target architecture. Reference the following commands when building for the phyCORE-i.MX8X:

Host (Ubuntu)
make imx8x_phycore_kit_defconfig                                         #configure the kernel build system to use PHYTEC's provided kernel configuration for the default pyCORe-i.MX8X development kit

make menuconfig                                                          #make kernel configuration changes (enable/disable drivers)

make savedefconfig                                                       #save the kernel configuration from .config to a file named "defconfig"

make                                                                     #build everything (Image, DTB, kernel modules, etc):

sudo make INSTALL_MOD_PATH=/media/user/root/ modules_install             #install kernel modules to the mounted bootable SD Card

The new Image kernel binary can be found at arch/arm64/boot/Image and the device tree blobs (and overlays) can be found at arch/arm64/boot/dts/phytec/.

For installing the new kernel image and device tree files, head over to the create a bootable SD Card guide.