Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Compiling the Linux kernel

Apacelus edited this page Sep 21, 2023 · 22 revisions

Kernel types

As of the moment of writing (28 July 2023), there are two kernel types that can be used:

  1. Mainline kernel: Latest stock Linux kernel directly from kernel.org.
  2. ChromeOS kernel: Google-customized Linux kernel, currently located here

There is no definitive way to predict which kernel will work best for each device in the future. Therefore, it is recommended to test both kernels to determine which one performs better on your specific device.

Follow these steps with the desired kernel

  1. Download the kernel source code

  2. Install all tools and dependencies needed to compile the kernel.

  3. Generate the default config with make defconfig

  4. Edit the default config with make menuconfig:

    NOTE: Any modules that are not included as Y will not be available until the storage is mounted (which happens pretty late in the boot process)

    4.1. Set any Chromebook/box or Google related options to Y.
    4.2. Determine your Chromebook/box's soundcard and enable those options (these can be set to M).
    4.3. Set all modules to Y that are needed for the storage format which you used when formatting the boot medium in preparing the boot medium.
    4.4. Set any modules related to your chromebooks gpu (amd/intel/nvidia) to Y.

  5. Compile the kernel with make -j"$(nproc)". This step might take a very long time, especially on slower devices.

  6. Compile the kernel modules with mkdir kernel-modules && make -j"$(nproc)" modules_install INSTALL_MOD_PATH=kernel-modules INSTALL_MOD_STRIP=1

  7. Optional: Compile the kernel headers

  8. Optional: Create an initramfs and compile it into the kernel. External initramfs' are not supported by depthcharge.

  9. Create the kernel cmdline:
    9.1. Run blkid -o value -s PARTUUID /dev/insert_rootfs_partition_here. Replace insert_rootfs_partition_here with your rootfs partition. It will be either /dev/insert_devicep2 or /dev/insert_device2 (notice the missing 'p' in the second example).
    9.2. Create a new file called cmdline.txt.
    9.3. Paste the following into that file: loglevel=15 root=PARTUUID=insert_partuuid i915.modeset=1 rootwait rw. Replace insert_partuuid with the output you got in step 9.1.
    9.4. Add security=apparmor or security=selinux at the end IF your distro requires that. If you do not, your distro might not behave correctly and might even refuse to let you log in.
    9.5. Add iommu=pt if you have an amd gpu.

  10. Sign the kernel with: futility vbutil_kernel --arch x86_64 --version 1 --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --bootloader cmdline.txt --config cmdline.txt --vmlinuz ./arch/x86/boot/bzImage --pack ./bzImage.signed

Once you've finished compiling the kernel, install it to the boot medium:

  1. You will need to determine the partition name to flash the kernel. It will be either /dev/insert_devicep1 or /dev/insert_device1 (notice the missing 'p' in the second example). Once you have it, flash the kernel with: dd if=/path-to-kernel-source-code/bzImage.signed of=/dev/insert_device1. Replace path-to-kernel-source-code with the appropriate path to the kernel source code directory.
  2. Mount the second partition of the storage medium (if you haven't already) and copy the kernel modules into /lib/modules (or /usr/lib/modules) on the second partition.
  3. Optional: Copy the headers to the appropriate location and create symbolic links for all the required paths.

Clone this wiki locally