[Android Software/Hacking General [Developers Only]] newbit:
Yeah as I said, the drivers didn't compile. So I didn't commit them in the source. If you found the right ones, I am happy to commit them in the source

and fix other issues as long they are in my capabilities.

This is pretty much the same I've already posted at last. Unfortunately none of them is mentioning the cfi.so or how to use it in the GCC Toolchain way. So I guess this must be some "old" way to integrate it, and nowadays this happens within CLANG or so. I don't know. I could need someone

explain it to me in detail.

@tohtorin and @Sid127,

I would take a close look into the build.config files. Especially the build.config.common and build.config.aarch64

On my experience, and I am pretty new to this, 95% of the information you need is within the kernel source itself.

I.e.

BRANCH=android-4.19-q
KERNEL_DIR=common
CC=clang
CLANG_PREBUILT_BIN=prebuilts-master/clang/host/linux-x86/clang-r365631c/bin
EXTRA_CMDS=''
STOP_SHIP_TRACEPRINTK=1
LD=ld.lld

ARCH=arm64
CLANG_TRIPLE=aarch64-linux-gnu-
CROSS_COMPILE=aarch64-linux-androidkernel-
LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
FILES="arch/arm64/boot/Image.gz vmlinux System.map"

Lets assume the Kernel is supposed to run on Android 11, I would choose the branch android-11.0.0_r28 for the CLANG Toolchain.

At the end i think it just matters, to get the closest version that matches the one your kernel was build with. More details later.

mkdir workdir && cd workdir
git clone https://github.com/OnePlusOSS/android_kernel_oneplus_sm8250.git kernelsource
CLANGVER=clang-r365631c
ANDROIDBRANCH=android-11.0.0_r28

mkdir $CLANGVER && cd $CLANGVER
wget https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/$ANDROIDBRANCH/$CLANGVER.tar.gz
tar -xzf $CLANGVER.tar.gz && cd ..

git clone \
-b $ANDROIDBRANCH \
--single-branch https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9

cd kernelsource
export ARCH=arm64
export CLANG_TRIPLE=aarch64-linux-gnu-
export CROSS_COMPILE=aarch64-linux-androidkernel-
export LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN=$(pwd)/../aarch64-linux-android-4.9/bin
export CLANG_PREBUILT_BIN=$(pwd)/../$CLANGVER/bin
BUILDPARAMS="CC=clang LD=ld.lld EXTRA_CMDS='' STOP_SHIP_TRACEPRINTK=1"
export PATH=$PATH:$LINUX_GCC_CROSS_COMPILE_PREBUILTS_BIN:$CLANG_PREBUILT_BIN

make $BUILDPARAMS mrproper

I can't say if you have to use these exports or not. Don't know what they mean and couldn't find them in the kernel so far,

but please point me where to look.

export SUBARCH=arm64
export DTC_EXT=dtc

Using the /proc/config.gz would be definitely my absolute first choice to take as a defconfig.

Inside the workdir with a running adb connection you can go with:

adb pull /proc/config.gz
gunzip -k config.gz
## copy it after mrproper ##
cp ../config .config

If you want to create a defconfig file for the future use this:

make savedefconfig
mv defconfig arch/x86/configs/adb_pulled_oneplus_sm8250_defconfig
rm .config
make $BUILDPARAMS adb_pulled_oneplus_sm8250_defconfig

If you have an extracted kernel from your boot.img or extracted firmware image,

unpacked with Android Image Kitchen from @osm0sis,

you can get straight to the defconfig with:

scripts/extract-ikconfig boot.img-zImage > FIRMWARE_oneplus_sm8250_defconfig

I expect that you have to make some minor changes to the defconfig, like changing the certs or so.

Finally let it run with time make $BUILDPARAMS -j$(nproc)

(I like the time command, so I know how long it took to build it)

If they are popping up questions, I am just guessing, with the less possibility to impact anything bad.

Regarding the kernel details from your phone itself. You can try to get the actually Kernel Boot Messages after a reboot of your phone.

adb shell
su
cat /proc/kmsg > /data/data/com.android.shell/logfile.txt
### after 60sec or less cancel the cat command ###
exit
exit
adb pull /data/data/com.android.shell/logfile.txt

All the really important stuff is written right after [ 0.000000] i.e.

[ 0.000000] Linux version 5.4.61-android11-2-00064-g4271ad6e8ade-ab6991359 (build-user@build-host) (Android (6443078 based on r383902) clang version 11.0.1 (https://android.googlesource.com/toolchain/llvm-project b397f81060ce6d701042b782172ed13bee898b79), LLD 11.0.1 (/buildbot/tmp/tmp6_m7QH b397f81060ce6d701042b782172ed13bee898b79)) #1 SMP PREEMPT Mon Nov 23 17:45:44 UTC 2020

Sorry about your Errors, can't tell you anything about to fix it.

Cheers

NewBit