Kernel

Linux Kernel for Surface RT. Build your own working Linux kernel for Surface RT.

Building a Kernel is an advanced process for most beginners. We suggest people to read this article first to understand kernel bootup on ARM devices. https://people.kernel.org/linusw/how-the-arm32-kernel-starts I'd also recommend reading Jay Carlson's excellent notes on Embedded Linux here - https://jaycarlson.net/embedded-linux/ as an overview.

Get the kernel source

You may want to build grate-driver/linux instead of mainline. It includes the latest device tree and experimental patches for Tegra in general. Take reference from the EFI compiling page and just use the different config settings from here. Recommended for users who know what they are doing.

Grate

Using Grate is recommended. It has also Surface RT specific patches and features.

git clone https://github.com/grate-driver/linux.git

Mainline

Download and unpack the kernel and open the directory in terminal wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.10.tar.xz tar -xf linux-5.10.10.tar.xz cd linux-5.10.10/

Modify the source (Mainline)

Devicetree

This is very important a wrong devicetree can damage your device!

Go to ./arch/arm/boot/dts, this is the devicetree directory Place tegra30-microsoft-surface-rt.dts there. Add the new devicetree to the build system by a adding: tegra30-microsoft-surface-rt.dtb to ./arch/arm/boots/dts/Makefile below dtb-$(CONFIG_ARCH_TEGRA_3x_SOC) +=(see image)

Configure the Kernel

SoC config

Start with a basic configuration for Tegra SoC's by using the default tegra_defconfig. Type: make ARCH=arm tegra_defconfig This will place a .config file in the kernel root directory with the default config for Tegra CPUs.

Surface RT config

Now its time to add Surface RT specific settings.

This can be done with [g|x|menu]config or by simply modifying the lines below in the .config file

BATTERY_CHARGER_SURFACE_RT=y
I2C_HID_OF=y
MWIFIEX=y
MWIFIEX_SDIO=y

Battery and Charger should be obvius. But I2C_HID is needed for touchscreen and tCover mwifiex is wifi

Debug config

CONFIG_DEBUG_DRIVER=y
CONFIG_DEBUG_GPIO=y
CONFIG_DEBUG_UNCOMPRESS=y

Optional: add#define DEBUG in the top of arch/arm/boot/compressed/head.S to enable decompressor output to see uart ouput as soon as possible

Build the kernel using command line

Type: make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j $(nproc) - $(nproc) sets the number of threads to your CPU core count

If compiling was successful you should see some output similar to this: (This doesn't need to be a the end of the log. Scroll up a bit ;) ) CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh CHK include/generated/compile.h Kernel: arch/arm/boot/Image is ready Kernel: arch/arm/boot/zImage is ready

Build the kernel using shell script

You can create a .sh script in kernel root to speed up your workflow

plsMake.sh
#!/bin/bash
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j $(nproc)

The kernel is located at arch/arm/boot/zImage and the devicetree can be found at arch/arm/boot/dts/tegra30-microsoft-surface-rt.dtb