-
Notifications
You must be signed in to change notification settings - Fork 0
Compiling the Linux kernel
As of the moment of writing (28 July 2023), there are two kernel types that can be used:
- Mainline kernel: Latest stock Linux kernel directly from kernel.org.
- 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.
-
Download the kernel source code
-
Install all tools and dependencies needed to compile the kernel.
-
Generate the default config with
make defconfig -
Edit the default config with
make menuconfig:NOTE: Any modules that are not included as
Ywill 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 toM).
4.3. Set all modules toYthat 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) toY. -
Compile the kernel with
make -j"$(nproc)". This step might take a very long time, especially on slower devices. -
Compile the kernel modules with
mkdir kernel-modules && make -j"$(nproc)" modules_install INSTALL_MOD_PATH=kernel-modules INSTALL_MOD_STRIP=1 -
Optional: Compile the kernel headers
-
Optional: Create an initramfs and compile it into the kernel. External initramfs' are not supported by depthcharge.
-
Create the kernel cmdline:
9.1. Runblkid -o value -s PARTUUID /dev/insert_rootfs_partition_here. Replaceinsert_rootfs_partition_herewith your rootfs partition. It will be either/dev/insert_devicep2or/dev/insert_device2(notice the missing 'p' in the second example).
9.2. Create a new file calledcmdline.txt.
9.3. Paste the following into that file:loglevel=15 root=PARTUUID=insert_partuuid i915.modeset=1 rootwait rw. Replaceinsert_partuuidwith the output you got in step 9.1.
9.4. Addsecurity=apparmororsecurity=selinuxat 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. Addiommu=ptif you have an amd gpu. -
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
- You will need to determine the partition name to flash the kernel. It will be either
/dev/insert_devicep1or/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. Replacepath-to-kernel-source-codewith the appropriate path to the kernel source code directory. - 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. - Optional: Copy the headers to the appropriate location and create symbolic links for all the required paths.