This guide provides step-by-step instructions for setting up and applying necessary patches to the Linux kernel for the FRDM-IMX93 development board. The process involves cloning the required repositories, applying patches, and preparing the kernel for customization and compilation.
Prerequisites
Required Software:
$ sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 python3-subunit zstd liblz4-tool file locales libacl1
Hardware:
1. Downloading the Repository
Start by downloading the necessary tools and repository. If the ~/bin folder does not already exist, create it:
$ mkdir ~/bin (this step may not be needed if the bin folder already exists)
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH
2. Compile the Yocto SDK:
$: mkdir Yocto_SDK
$: cd Yocto_SDK
$: repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-scarthgap -m imx-6.6.36-2.1.0.xml
$: repo sync
$: MACHINE=imx93evk DISTRO=fsl-imx-xwayland source ./imx-setup-release.sh -b bld-xwayland
$: bitbake imx-image-full -c populate_sdk
Run the generated .sh file to install the SDK:
sudo ./fsl-imx-xwayland-glibc-x86_64-imx-image-full-armv8a-imx93evk-toolchain-6.6-scarthgap.sh
The final .sh file is located in:
bld-xwayland/tmp/deploy/sdk/
3. Creating the Working Directory
First, create a dedicated directory for the kernel setup and navigate into it:
$ mkdir FRDM-IMX93-Kernel
$ cd FRDM-IMX93-Kernel
4. Cloning the Kernel patches
Retrieve the necessary kernel patches from the NXP repository:
$ git clone https://github.com/nxp-imx-support/meta-imx-frdm.git -b lf-6.6.36-2.1.0
5. Cloning the Kernel Repository (linux-imx repository)
Clone the kernel source of Yocto SDK that you built earlier:
$ git clone https://github.com/nxp-imx/linux-imx.git -b lf-6.6.36-2.1.0
6. Applying Kernel Patches
Apply the necessary patches to the kernel:
$ cd linux-imx/
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0001-gpio-pca953x-fix-pca953x_irq_bus_sync_unlock-race.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0002-arm64-dts-add-i.MX93-11x11-FRDM-basic-support.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0003-arm64-dts-add-imx93-11x11-frdm-mt9m114-dts.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0004-Add-DSI-Panel-for-imx93.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0005-Add-CTP-support-for-waveshare-panel.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0006-arm64-dts-add-imx93-11x11-frdm-tianma-wvga-panel-dts.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0007-arm64-dts-add-imx93-11x11-frdm-aud-hat-dts.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0008-arm64-dts-add-button-support.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0009-arm64-dts-add-imx93-11x11-frdm-ov5640-dts.patch
$ cd linux-imx/
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0010-arm64-dts-add-imx93-11x11-frdm-ld.dts-for-lpm.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0011-arm64-dts-add-pwm-function-of-the-LED.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0012-arm64-dts-add-imx93-11x11-frdm-8mic.dts.patch
$ git apply ../meta-imx-frdm/meta-imx-bsp/recipes-kernel/linux/linux-imx/0013-arm64-dts-add-imx93-11x11-frdm-lpuart.dts.patch
7. Customizing the Device Tree
Device trees can be modified or created based on your hardware setup.
Device Tree Locations:
arch/arm64/boot/dts/freescale/
If you create a new device tree, add it to the respective Makefile:
arch/arm64/boot/dts/freescale/Makefile
8. Setting Up the Cross-Compilation Environment
To prepare for kernel compilation, source the environment setup script. Assuming the Yocto SDK is installed in /opt, run:
EXAMPLE:
$ source /opt/fsl-imx-xwayland/6.6-scarthgap/environment-setup-armv8a-poky-linux
9. Configuring the Kernel
Make configuration adjustments as needed in the file:
arch/arm64/configs/imx_v8_defconfig
Use the appropriate configuration command:
$: make imx_v8_defconfig
10. Compiling Device Trees Only
To compile only the device tree files, run:
$: make dtbs
11. Compiling the Kernel
Finally, compile the kernel image using:
$ make -j $(nproc)
The resulting kernel image will be located in:
arch/arm64/boot/
References: