Kernels - Common stuff

Kernels - Common stuff

silent_listener

Directories

I generally use a separate directory for kernel building.

-$HOME
 - kernel
  - toolchain
   - clang-aosp
   - clang-proton
   - clang-playground
  - anykernel3
  - kernel-sweet-lineage
  - kernel-sweet-KewL
  - kernel-sweet-Vantom
  - kernel-sweet-Vantom-aryan


This way, it is easy to manage things.

Prerequisites

Of course we need a Linux system to build an Android kernel. But if you are on other operating system, you can use a Linux virtual machine as well (or WSL in Windows).

Install kernel build dependencies

This is for Ubuntu or Ubuntu based Linux distros.

sudo apt update -y && sudo apt install -y make cmake automake autoconf llvm lld lldb clang gcc binutils bison perl gperf gawk flex bc python3 python2 zstd openssl unzip cpio bc bison build-essential ccache liblz4-tool libsdl1.2-dev libstdc++6 libxml2 libxml2-utils lzop pngcrush schedtool squashfs-tools xsltproc zlib1g-dev libncurses5-dev bzip2 gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi libssl-dev 

Select a cross compiler

We need a cross-compiler to compile android kernel. Read more here: https://en.wikipedia.org/wiki/Cross_compiler

We have several cross-compilers for compiling android kernel. I usually use playground clang for standalone kernel building.

git clone --depth=1 https://gitlab.com/PixelOS-Devices/playgroundtc -b 17 ~/kernel/toolchain/clang-playground

We can use AOSP clang provided by Google as well.

git clone --depth=1 https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 ~/kernel/toolchain/clang-aosp

Other clangs:

Proton clang

git clone --depth=1 https://github.com/kdrag0n/proton-clang.git ~/kernel/compiler/clang-proton

Flashing the kernel

I use AnyKernel3 to make a flashable zip after the kernel build.

https://github.com/osm0sis/AnyKernel3.git


Thanks for reading.


Resources:

Report Page