[Samsung Galaxy S23 Ultra] mslezak:
Do you want to build custom kernels, and have an hour of your time to spare? With WSL2 (Windows Subsystem for LInux v2), you can run Linux inside of Windows seamlessy. But just because it is possible, doesn't mean it is easy to setup. Things as basic as internet connectivity don't work out of the box. Add to it all the packages required to build a GKI (Generic Kernel Image) or a custom kernel, and it gets complicated fast. It took me a week to build a super small image with everything setup perfectly, but the result - you can build kernels with just a few commands!

First off, why Kali Linux? Because they have an awesome way to run Linux inside of Windows with a library called win-kex. Literally type: kex and you have a connection to your Linux box with a full GUI (graphical user interface, in this case XFCE4), which will appear in its own window. It all feels very familiar for people coming from Windows. Just use your mouse to open the apps you want, I included Firefox (with sound enabled), Geany code editor, and Diffuse merge / file comparison tool. You will be using the Terminal Emulator quite a bit which is very similar to Windows Powershell.

I have added a complete step-by-step installation and build demonstrations!

Part 1

Note: On Windows 11, you need to type: wsl --install --no-distribution and reboot before Part 2 begins

Part 2

So lets get started. First download the image here: WSL Image

Now we have to make sure you have WSL2 enabled. I will give the old commands since it works on all Windows 10 and 11 builds. 1) type: powershell in the search bar, click on Run as adminstrator 2) type: dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 3) type: dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart 4) restart your computer. [note Win11 - type: wsl --install --no-distribution and reboot]

5) type cmd in the search bar and open Command Prompt 6) type: wsl --set-default-version 2 7) type: wsl --import kali-linux {install location} WSL2_GKI_Kernel_Builder_Kali_Linux.tar.gz (I usually use {install location} as c:\Users\[my_user_name]\WSL2) Note: if you get an error that WSL needs to be updated, type: wsl --update.

Give it a few minutes to import and after it says successful 1) type: wsl 2) type: login 3) type: user 4) type: user 5) type: kex 6) type: user. You just entered the login which is username: user and password: user. The sudo password is: user. Simple. If it asks you to set a password just use whatever you want, that is for accessing VNC server, just use 6 characters.

Okay you are in! You should be greated by a new window like this:

View attachment 6004107

If you want to make it a normal window you can resize, hit F8, unclick Full screen.

Now we need to download the GKI which comes with the Clang / GCC toolchain and scripts we need for building. 1) open a terminal emulator (click View attachment 6004109at the top) 2) type: cd ~ 3) type: ./install_GKI_kernel.sh

Wait for the download to finish, it will pull Android 13 5.15.78 kernel. If you want a different version you can edit the init_repo.sh file in the ~/GKI/ folder.

Almost there! Now let's build the GKI kernel! 1) type: cd ~/GKI 2) type: ./bazel_build.sh 3) when it finishes, type: find . -name boot.img 4) you can copy the boot.img back to your C: type: cp {file_location} /mnt/c/Users/[my_user_name]/Downloads/

Now you can flash the boot.img to your phone and use your first kernel! Note I also included another script to install the S23 Ultra source code from my Github repo. You can run it by 1) type: cd ~ 2) type: ./install_S23_kernel.sh 3) after it downloads, type: cd ~/S23_kernel 4) type: ./build_kernel_GKI.sh 5) type: find . -name boot.img 6) you can copy the boot.img back to your C: type: cp {file_location} /mnt/c/Users/[my_user_name]/Downloads/

You did it! Go celebrate!