-
Notifications
You must be signed in to change notification settings - Fork 9
Custom Kernels
You need to choose between android-mainline or GKI below.
You may want to build your own kernels manually and copy the output.
We are going to use aospm/linux as example.
git clone https://github.com/aospm/linux.git -b aosp/sdm845-mainline sdm845-mainline
cd sdm845-mainline
Next the kernel needs to be cross-compiled. It is helpful to create an alias like:
mm () {
make CC="$CC" CROSS_COMPILE=aarch64-linux-gnu- O=$KERNEL_OUTDIR/ ARCH=arm64 -j"$(($(nproc --all)-2))" $@
}
Future usages of
mmassume above command.Also make sure to export
CCandKERNEL_OUTDIR.
Next you need to generate a defconfig out of aosp and sdm845 config fragments:
mm defconfig sdm845.config aosp.config
Order matters here!
defconfigcreates the initial base,sdm845.configsets all required options for sdm845 andaosp.configapplies all required options for android.Each config overrides options set by the previous one.
Adjust the defconfig to your liking and build the kernel:
mm
After building your kernel, generate modules:
rm -rf $KERNEL_OUTDIR/modules
mm INSTALL_MOD_PATH=modules modules_install
Your build output is now ready to get copied.
See this gist for an example script to copy kernel build output.
Here is a handy oneliner, which does all of the above steps (assuming you also set up above gist script as copymainlinekernel):
mm defconfig aosp.config sdm845.config && mm && rm -rf $KERNEL_OUTDIR/modules && mm INSTALL_MOD_PATH=modules modules_install && copymainlinekernel generic sdm845
These steps only work for android-mainline kernels with android build files included.
Run following commands to clone the kernel source and prebuilt Android toolchains and build scripts:
mkdir kernel-repo
cd kernel-repo
repo init -u https://android.googlesource.com/kernel/manifest -b common-android-mainline
git clone [email protected]:pundiramit/android-local-manifests.git .repo/local_manifests -b kernel
repo sync -j$nproc
BUILD_CONFIG=beryllium/build.config.beryllium ./build/build.sh
Delete all objects in aosp-repo/device/generic/sdm845/prebuilt-kernel/android-mainline/.
Then copy build artifacts from kernel-repo/out/beryllium-android-mainline/dist/ to
aosp-repo/device/generic/sdm845/prebuilt-kernel/android-mainline/ and build AOSP images again.
cd aosp-repo
source build/envsetup.sh
lunch beryllium-userdebug
make TARGET_KERNEL_USE=mainline -j$nproc
Now reflash the images as above and boot with your custom kernel.
NOTE:
By default the above instructions will sync/download
beryllium-android-mainlinebranch tokernel-repo/berylliumdirectory.
If you want to reproduceandroid12-5.4or GKI build then checkoutcommon-android12-5.4repo manifest andberyllium-android-5.4branch instead.