Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Configure and build Linux kernel for Surface RT
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
CONFIG_EFI_STUB=y
CONFIG_EFI=y
CONFIG_I2C_HID_OF=y
CONFIG_I2C_HOTPLUG_GPIO=y
CONFIG_BATTERY_CHARGER_SURFACE_RT=y
CONFIG_MWIFIEX=m
CONFIG_MWIFIEX_SDIO=m
CONFIG_SND_SOC_TEGRA_WM8962=y
CONFIG_HID_MICROSOFT=y
Note that some drivers (Wi-Fi) are built as modules. See exporting modules below to use them.
To build the kernel use the command make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j $(nproc)
- $(nproc)
sets the number of threads to your CPU core count
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.
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
The output kernel image is located at arch/arm/boot/zImage
The output device tree is located at
EFI:arch/arm/boot/dts/tegra30-microsoft-surface-rt-efi.dtb
.
APX:arch/arm/boot/dts/tegra30-microsoft-surface-rt.dtb
.
You can create a .sh script in kernel root to speed up your workflow
Some drivers will be built as modules. This reduces the kernel image size.
The module folder needs to be placed on the rootfilesystem in /lib/modules
.
Some drivers need to be built as module. For example the Wi-Fi driver. Wi-Fi needs a firmware which will be send to the Wi-Fi SoC at the time the hardware is probed. This can happen before the root filesystem is mounted. Therefore the driver can't load the firmware. If wifi is built as module it won't be loaded before the root filesystem was mounted.
This command will place the modules folder next to your Linux kernel folder.
You need to copy the modules after: - Modifying the kernel source for the first time - Every git commit - Editing a driver which is built as module (obvious?)
Since the beginning of July 2021 our changes to the Linux kernel are upstreamed to grate-driver/linux. For pull requests we created our own fork:
This fork contains the latest changes. Eventually they will be merged to grate at some point.
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.
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/
grate-driver/linux has these patches already included.
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:
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.
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
) Rungit apply 0001-WIP-ARM-tegra-Add-Type-Touch-Power-Cover-support-for.patch
to apply the patch.
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.
APX can boot normal and UEFI kernels. UEFI can only boot UEFI kernels. Therefore we use UEFI kernel for both methods of booting. This simplyfies development, testing and distributing kernel Images for both boot methods.
Visit the main Linux page for a short comparison between EFI vs. APX Linux
Building a Kernel is an advanced process for most beginners. If you just want to use Linux on your Surface RT you should go with the prebuilt binaries. If you want to help developing you need to compile the kernel on your own.
If you don't want to compile a kernel yourself, just use the prebuilt binaries. They are built everytime new hardware support is added. These images additionally include a lot of USB drivers and are digitally signed.
Get information on how to compile a working Linux kernel. You can either use mainline linux
, or grate-driver/linux
(based on Linux-next with experimental changes for tegra devices).
There are branches for all devices.
Use the master tree to only get tested and stable features for all devices:
https://github.com/Open-Surface-RT/grate-linux/
Use the device speccific branches for your device:
https://github.com/Open-Surface-RT/grate-linux/tree/surface-rt
https://github.com/Open-Surface-RT/grate-linux/tree/surface-2
https://github.com/Open-Surface-RT/grate-linux/tree/lenovo-ideapad-yoga-11
For information on how to boot your kernel, visit the Booting page.
Prebuilt binaries for APX/EFI linux
All zImage files that have (signed)
at the end, are digitally signed by @Leander. Here is the certificate file:
All files built include a lot of USB device drivers, so features like USB RNDIS will work.
For booting take the zip bellow, extract to USB and place your desired zImage and devicetree file onto the USB (don't rename). For more information visit the Booting.
You may want to change the line that begins with zImage
! Kernel files are distributed in a long name for archival sake so double check if you renamed it to just zImage
. root=/dev/mmcblk1p2
is the second partition of the SD card, change this if you want to use a different device/partition. RPI OS is a recommended distro, as it runs smooth
root=/dev/mmcblk0p2
is a location set to internal storage (eMMC) second partition, set it to this after cloning the installation over to internal storage.
root=/dev/sda2
is a second partition for USB only boot, set it to this if you want to USB boot only
mmc
stands for the storage type, more specifically a MMC memory module like eMMC storage or a SD card.
mmcblk[]0[]
would be used to specify the exact partition in a boot configuration file, for example root filesystem partition, in this case it can be mmcblk[]p2
for typical Linux distros.
0p[]
is used for internal storage definition as it's the primary MMC module
1p[]
is used for external MMC storage like a SD card
Typical Linux distro consists of two partitions; small FAT32 formatted boot partition with kernel stuff and a main root partition which contains the entire filesystem. Root file system is formatted as EXT4 in most cases!
In this case mmcblk[]p1
is a FAT32 boot partition and mmcblk[]p2
is a root file system.
sda[]
is used to define a USB drive's partition as it's considered an external media.
In our case sda1
would be FAT32 boot partition and sda2
a root file system.
Modules are required for features like WiFi. Make sure to extract them to the root of your root filesystem. The lib folders of the ZIP and of the root filesystem should merge. The modules are not required for booting, you can extract them while the system is running on your Surface RT. (E.g. When you are not able to extract the modules to a EXT4 filesystem on your main PC)
The latest binaries and modules of kernel, devicetree, modules can be found below.
Write to USB disk with e.g. rufus/etcher and boot.
No support for older builds. Use at your own risk.