This repository uses various scripts to create a building environment for the OnePlus SM8350 kernel tree.
- A linux distro
- Git
- A Lineage OS ROM flashable zip, needed to build a working vendor_dlkm.img
- A oneplus-sm8350 kernel tree
- Download the kernel source in the root of this repository
- The default name for the kernel source tree is
android_kernel_oneplus_sm8350
git clone [your-kernel-repo] android_kernel_oneplus_sm8350 - The default name for the kernel source tree is
- Download a lineage os build and place it in the root of this repository
- This will be used to extract the
vendor_dlkm.imgwhich will be used as a base for thevendor_dlkm.imgof the kernel being built
- This will be used to extract the
- Run build.sh
./build.sh- This will automatically build and package the kernel in an ak3 zip
Final build files will be written in build folder.
The environment produces the following
Image- Kernel image
vendord_dlkm.img- vendord_dlkm partition
modules- Folder containing vendor_ramdisk modules
kernel-oneplus-sm8350.zip- AnyKernel3 flashable zip of the kernel
Main script. Contains all possibile commands.
toolchain_setup- Checks and sets up the toolchain
- Implemented in toolchain_setup.sh
kernel- Builds the kernel
- Implemented in build_kernel.sh
kernel_clean- Runs
make cleanandmake mrproperon the kernel source tree - Implemented in build_kernel.sh
- Runs
vendor- Builds vendro_dlkm.img and ramdisk modules
- Implemented in vendor.sh
ak3- Packages the kernel with anykernel3
- See ak3.sh for details.
lemonade- Downloads the latest Lineage OS ROM for OnePlus 9
- See lineage.sh for details.
lemonadep- Downloads the latest Lineage OS ROM for OnePlus 9 Pro
- See lineage.sh for details.
clean- Cleans all build artifacts
- Implemented in build.sh
These scripts are used by the main scripts for various utility functions
- colors.sh
- Has
cechofunction for colored output
- Has
- extract_vendor_dlkm.sh
- Extracts the
vendor_dlkm.imgfrom the provided Lineage OS zip file
- Extracts the
- set_env.sh
- Exports to
PATHthe locations of toolchain utilities
- Exports to
- lineage.sh
- Downloads the latest Lineage OS rom for the specified device
The toolchain is installed in ~/android/toolchain_oneplus_sm8350 and has the following tools
- build-tools
- Repository: https://android.googlesource.com/kernel/prebuilts/build-tools
- Branch: main-kernel-build-2024
- Contains various tools for building android images
- Mainly used for mkfs.erofs implementation
- clang-r547379
- Repository: https://gitlab.com/kei-space/clang/r547379.git
- Version: 20.0.0
- Main compiler
- Compiled from this revision
- This repository is a mirror of the prebuilt from google
- This is used instead of google's repository because the google one contains various other clang versions not needed that make the download size unnecessarily big
- payload-dumper-go
- Repository: https://github.com/ssut/payload-dumper-go
- Version: latest
- This tool is used to extract the payload.bin file from the Lineage OS zip
- anykernel3-oneplus-sm8350
- Repository: https://github.com/Gamesmes90/anykernel3-oneplus-sm8350
- Branch: lemonade
- AnyKernel3 Zip Template customized for lemonade/lemonadep devices
To get a kernel up and running on lemonade/lemonadep, all the modules built with the kernel need to be added in vendor_dlkm.img and a specific set of modules have to be put in vendor_ramdisk and then these have to be flashed with the kernel.
This repository uses a custom AnyKernel3 repo to achieve this.
In addition, the AnyKernel3 repo has a small kernelsu module that runs some kernel tweaks at boot, it is configurable.
- msm_drm.ko
- apr_dlkm.ko
- q6_pdr_dlkm.ko
- q6_notifier_dlkm.ko
- adsp_loader_dlkm.ko
- snd_event_dlkm.ko
An alternative to this would be to build the kernel with all the modules as built-in.
Using a base image is necessary to build a vendor_dlkm.img, as the image contains other files that are not generated by just building the kernel (e.g. /etc/build.prop generated by the lineage build system). This approach is also easier as it allows to drop-in replacement/new modules in the extracted base image and swiftly generate the erofs image.