> For the complete documentation index, see [llms.txt](https://open-rt.gitbook.io/open-surfacert/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://open-rt.gitbook.io/open-surfacert/surface-rt/linux/kernel/source/mainline.md).

# Mainline

## Download mainline Linux

You should be able to use the latest versions without problems.\
You can get it on Github:\
`git clone https://github.com/torvalds/linux.git --depth=1`\
or use .tar files from kernel.org\
<https://www.kernel.org/>

## Applying patches

{% hint style="info" %}
grate-driver/linux has these patches already included.
{% endhint %}

### 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](/open-surfacert/surface-rt/linux/devicetree/devicetree-efi.md).

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](https://2395005476-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MJQb34R_xPz0ll0scbM%2F-MSchLVeclD3RLHlHpi_%2F-MScpR0elxcSjIGxpbtR%2Fgrafik.png?alt=media\&token=13ad349b-2b3b-4385-a8c6-bc9559e16bd9)

### 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.

{% file src="/files/-MU9k0ULYJcSAE43amav" %}

### Apply patch for tCover

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

{% file src="/files/-MeASyyhUZrrt-ttqly8" %}

### 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.

{% file src="/files/-MeAqFMcHlLNmrNJ7YYA" %}
