Compiling kernel

Clone kernel

Since the beginning of July 2021 our changes to the linux kernel are upstreamed to grate-driver/linux. To be specific, we created a fork for pull-requests, but this repository may have not fully tested features.

This means you can either use grate-driver/linux, without the need of modifying the kernel source, or you can use mainline linux, with the need of applying patches.

Download grate-driver/linux

Simply rungit clone --depth=1 && cd linux to download the repository with a git history depth of 1 (to reduce the amount of data downloaded, full history is over 1 GB).

Download mainline linux

You should be able to use the latest versions without problems, the download link may need to be updated. (visit

wget tar -xf linux-5.12.3.tar.xz cd linux-5.12.3/

The commands above download the kernel source into the linux-5.12.3 directory, relative from your current path.

Applying patches for mainline

This only needs to be done when you use mainline versions of the kernel. grate-driver/linux has these patches included.

Adding a devicetree

Go to ./arch/arm/boot/dts, create a file with the name tegra30-microsoft-surface-rt-efi.dts and paste the contents of the code block in the devicetree sub-section.

Search for dtb-$(CONFIG_ARCH_TEGRA_3x_SOC) += in the Makefile (same directory), there you can see a few lines which begin with tegra30, add a line with the devicetree file name you created above, but instead of the extension .dts use .dtb. Be aware that you will need to add a backslash (\) at the end of the previous line. Here is a picture how it should look like:

Picture shows the wrong file name

Apply patch for ACPI Parking Protocol

Open up a terminal and cd into your linux-5.12.3 directory. Then download the patch from bellow and run git apply 0001-Add-ACPI-Parking-Protocol-for-arm32-devices.patch This should add ACPI Parking Protocol to your kernel and allows you to use SMP.

The patch doesn't follow kernel coding conventions. This will eventually be fixed.

Apply patch for tCover

This patch was created from commit c0a5652f from grate-driver/linux. The changes in the devicetree were removed. (Create with git format-patch -1 c0a5652f) Rungit apply 0001-WIP-ARM-tegra-Add-Type-Touch-Power-Cover-support-for.patch to apply the patch.

Apply patch for I2C GPIO hotplug for tCover

This patch was created from commit e2a2772b from grate-driver/linux. (Create with git format-patch -1 e2a2772b) Run git apply 0001-i2c-GPIO-based-hotplug-gate.patch to apply the patch.

Editing kernel build configuration

First run the command make ARCH=arm tegra_defconfig This will create a standard kernel config for tegra soc's.

Open the file .config in the kernel source directory with your favorite text editor and paste the following at the end of the file


Build the kernel

To build the kernel use the command make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j $(nproc) It will use all of your available cores. This command can take a while depending on your computer's speed. (5+ minutes)

Note: If you get asked what configuration you want to choose, just press enter, this will take the standard value.

The output image is arch/arm/boot/zImage The output device tree is arch/arm/boot/dts/tegra30-microsoft-surface-rt-efi.dtb.