Attention

You are viewing an older version of the documentation. The latest version is v3.1.

Configure and Build Linux Kernel

This section guide will explain the procedure to configure the Linux* kernel and build it using the ECI Build Engine. It is recommended to read ECI Development Practices to gain a better understanding of the basic development principles.

Step 1: Environment Prerequisites

In this step, you will set up your build environment.

  1. Setup the Build System, if not done already.

  2. Identify the Linux kernel that you want to configure. ECI offers a few options for various distributions. Refer to ECI Linux Intel LTS Kernel for a list of available kernels and their respective distribution. In this section, linux-image-intel-rt for Debian bullseye distribution will be used. If you are using a different kernel, you will need to modify the example commands accordingly.

  3. Locate the pre-built Linux kernel Deb package:

    $ find ./targets/packages/ -name linux-image-intel*.deb
    

    The find command should display a list of available Linux kernel Deb packages:

    ./targets/packages/bullseye/eci-bullseye/pool/main/l/linux-intel-acrn-sos/linux-image-intel-acrn-sos_5.10.115-bullseye-2_amd64.deb
    ./targets/packages/bullseye/eci-bullseye/pool/main/l/linux-intel-rt/linux-image-intel-rt_5.10.115-rt67-bullseye-2_amd64.deb
    ./targets/packages/bullseye/eci-bullseye/pool/main/l/linux-intel-xenomai/linux-image-intel-xenomai_5.10.100-bullseye-2_amd64.deb
    ./targets/packages/jammy/eci-jammy/pool/main/l/linux-intel-acrn-sos/linux-image-intel-acrn-sos_5.15.36-jammy-2_amd64.deb
    ./targets/packages/jammy/eci-jammy/pool/main/l/linux-intel-rt/linux-image-intel-rt_5.15.36-rt41-jammy-2_amd64.deb
    

    Export the path of the desired Linux kernel Deb package, so that you can reference it in the later commands:

    $ export PACKAGE=./targets/packages/bullseye/eci-bullseye/pool/main/l/linux-intel-rt/linux-image-intel-rt_5.10.115-rt67-bullseye-2_amd64.deb
    
  4. Extract the Linux kernel Deb package to obtain the Linux kernel default configuration:

    $ TDIR=$(mktemp -d -p .)
    $ ar x ${PACKAGE} --output ${TDIR}
    $ tar --directory=${TDIR} -xf ${TDIR}/data.tar*
    $ cp ${TDIR}/boot/config-* . && rm -r ${TDIR}
    

    Now, you will find a file named config-* in the directory:

    $ ls config-*
    config-5.10.115-rt67-intel-ese-standard-lts-rt+
    
  5. Locate the existing Linux kernel default configuration, backup the existing Linux kernel default configuration, and copy the new one:

    $ RDIR=./targets/layers/meta-tgr/meta-eci-isar/recipes-kernel/linux/files
    $ DEFAULT=$(find ${RDIR} -name *_intel_defconfig)
    $ mv ${DEFAULT} ${RDIR}/$(basename ${DEFAULT})_backup
    $ cp config-* ${DEFAULT}
    

    You will find two *intel_defconfig* files in the ${RDIR} directory:

    $ ls ${RDIR}/*_intel_defconfig*
    ./targets/layers/meta-tgr/meta-eci-isar/recipes-kernel/linux/files/amd64_5.10_intel_defconfig
    ./targets/layers/meta-tgr/meta-eci-isar/recipes-kernel/linux/files/amd64_5.10_intel_defconfig_backup
    
  6. Start a bitbake Environment.

    Note: You do not have to append any meta-layer YAML meta-vendor-application.yml to build the Linux kernel. The example uses bullseye targets, but use jammy targets instead if you are building a Linux kernel for the Ubuntu* distribution.

Step 2: Use Linux Menu Tool

In this step, you will use the Linux menuconfig tool to modify the Linux kernel configuration.

  1. Export the Linux kernel image recipe name, so that you can reference it in the later commands:

    export RECIPE=linux-image-intel-rt
    
  2. Clean the recipe build cache to ensure a known initial state:

    $ bitbake ${RECIPE} -c cleansstate
    
  3. Instantiate the recipe build environment by using the devshell command:

    $ bitbake ${RECIPE} -c devshell
    
  4. Open the Linux kernel menuconfig tool:

    $ make menuconfig
    
    ../_images/menuconfig_init.png
  5. Use the arrow keys to navigate the menu. Select the < Load > menu option.

  6. In the input prompt, enter build-full/.config to load the Linux kernel default configuration:

    ../_images/menuconfig_load.png
  7. Modify the configuration as needed. Use the spacebar key to cycle through configuration options.

    • [*] kernel configuration will be built-in to the kernel

    • [m] kernel configuration will be available as a discrete kernel module

    • [ ] kernel configuration will be excluded

    You can use the search prompt to locate a particular configuration and learn about its dependencies. Press the / key to open the search prompt. This example searches for the PREEMPT_RT configuration:

    ../_images/menuconfig_search.png

    The following is the search result:

    ../_images/menuconfig_search_results.png
  8. After modifying, save the configuration. Select the < Save > menu option, then enter build-full/new.config in the input prompt.

    ../_images/menuconfig_save.png
  9. Select the < Exit > menu option until you return to the devshell command prompt. Exit the devshell using the exit command:

    $ exit
    
  10. Replace the Linux kernel default configuration with the new.config file available in the temporary build directory. This method uses bitbake, so you do not need to exit the bitbake environment:

    $ cp $(bitbake ${RECIPE} -e | grep '^S=' | cut -d'"' -f2)/build-full/new.config $(ls $(bitbake ${RECIPE} -e | grep '^FILE_DIRNAME=' | cut -d'"' -f2)/files/*_intel_defconfig)
    

Step 3: Build Linux Kernel

In this step, you will build the Linux kernel Deb package.

  1. Build the Linux kernel image. The build duration will vary depending on the system capabilities. Typically, the build will complete in about 20 minutes if the system meets the recommended system requirements.

    $ bitbake ${RECIPE}
    
  2. After the build completes, exit the bitbake environment using the exit command.

    $ exit
    
  3. You will find the resulting Linux kernel Deb packages in the target APT repository located at build/eci-packages-<distribution>/tmp/deploy/isar-apt. To find all the Linux kernel Deb packages, run the following command:

    $ sudo find build/eci-packages-*/tmp/deploy/isar-apt  -name linux-image-*.deb
    

    For example, the linux-image-intel-rt Deb package for bullseye:

    build/eci-packages-bullseye/tmp/deploy/isar-apt/eci-bullseye-amd64/apt/eci-bullseye/pool/main/l/linux-intel-rt/linux-image-intel-rt_5.10.140-rt73-bullseye-4_amd64.deb
    
  4. You could install the Linux kernel Deb package onto the target system using the dpkg -i <package.deb> command or you could privately host the ECI APT repository to install the Linux kernel Deb package using the APT package manager.