yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] spezi77:
Hey there,

I am compiling my rom for marlin. Clang kernel is compiled inline. After I have reinstalled my build machine with Debian I get a segmentation fault and the build fails.. On my old distro (Deepin) the segmentation fault was also occurring but the build never failed, and the rom worked like a charm.

Here's my log: https://del.dog/irebegutaf.coffeescript

Edit: please do not pay attention to my issue. I have solved it. After upgrading gnu make on my machine the issue was gone.
[Android Software/Hacking General [Developers Only]] Alejandro_424:
Hi

After searching and information I have managed to compile a kernel for the Galaxy A50

But but I can't find the lines to disable dm verify, knox, tima this is very rare can I add the line to my defconfig to disable it?

Thanks you
[Android Software/Hacking General [Developers Only]] darklight2k2:
Hello i do compile kernel since 2.2 came out on linux, but it's my first time doing it on android. I read your guide and several (outdated and not) others.

i'm trying to update the kernel of my device. It's an Elephone P9000, Mediatek cpu (MT6755 + MaliT860).

Kernel version i tryed are the official linux stable 5.2.11 (it's probably a long shot, i know :( ) and to official google's git branch "common-android-4.19" .

I can compile both of them, their modules... (since there is no defconfig for my device, i selected the single options, maybe here is the issue. did i miss something? (attached the defconfig i created)

I had troubles at beginning with verified boot, and if i understood correctly there are 2 version. VB 1.0 and AVB 2.0. My device when i unpack falls under the 1st version.

I tried AIK, superr to upack and repack the official bootloader but i was stuck on bootloop on the first logo. (First logo is Elephone symbol, second is the android loading animation)

I then found that Android_boot_image_editor works for me (https://github.com/cfig/Android_boot_image_editor) and the official stock rom will recompile without any problem.

I substituted the kernel in the unpacked bootloader, added the modules in the ramdisk. I repacked (a signed image is created) and flashed.

It just looks like the previous rom, same kernel boot parameters, same file format (Android , not ext4)

It gets stuck on the first boot animation. I don't have any error, not one i can read atleast.

I would like to provide more informations, but i'm actually asking you if you can give me an advice about how to have some sort of log or you have an idea what i possibly mess up.

is there a serial port i can read boot informations? can i remove the bootlogo in some way and have (my loved) linux boot text?

Thank you for your attention

P.S.

Twrp is already installed and works with any of the boot image i flash (as it should beeing in another partition)

I did enable Android options in the kernel config, and i did enable ext2/4 + mtd to be able to mount the real root.

I did format cache and dalvik partitions

bootloader is unlocked

flashboot doesn't work on mtk, i'm using sp_flash_tool (latest version on linux) with his scatter file

P.P.S.

toolchain versions shouldn't matter since compilation do not fail... but anyway...

i used the one in the guide (https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/) for 5.2.11

and the one that is automatically selected with git source from google's git with "clang-r353983c"

My aim is to have an updated bootloader i can use with GSI or learn how android boot works in detail, and next to this kernel i'll update the one on my tablet (another MTK).

Unfortunally MTK configs are not upstreamed, and there is a lack of ORGANIZED source code.
[Android Software/Hacking General [Developers Only]] attack11:
Linux kernel in android isn't like pcs,you can't upgrade your kernel just like that just modifying your defconfig, what you want to do is imposible,your best bet it's just upstream your kernel to the latest 3.18 release
[Android Software/Hacking General [Developers Only]] darklight2k2:
i'm not expecting all to be working (gps, and everything else is actually needing a vendor driver) but since 3.18 some drivers have been released from MTK. and i'm curious to see which point is possible to reach.

Either way i will need to upgrade the bootimage to give the correct interfaces to a GSI

edit.

even if 5.2.11 will not work it should still be possible to boot to a shell like linux, with just generic drivers

right now i'm trying to see if i'm able to pass the bootloader stage with a compiled 3.18 kernel.
[Android Software/Hacking General [Developers Only]] mxj_xda:
How to compile kernel for X86 (Samsung GT-P5210)

Hi, can I follow the exact same steps for compiling kernel of Samsung Galaxy Tab 3 10.1" inch (GT-P5210)?

According to GSMArena, this tablet's processor is X86 (Intel Atom).

I would like to rebuild its kernel because i want to change the battery fuel gauge method to voltage monitoring, and not using columbo counting.
[Android Software/Hacking General [Developers Only]] RogerF81:
Hello guys,

I'm just trying to compile Caesium kernel for my Pixel 2 XL on my own, using clang tc, but I always get this error message:

/..//bin/ld: unrecognised emulation mode: aarch64linux
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu elf_l1om elf_k1om i386pep i386pe
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../arch/arm64/kernel/vdso/Makefile:48: arch/arm64/kernel/vdso/vdso.so.dbg] Error 1
make[1]: *** [arch/arm64/Makefile:209: vdso_prepare] Error 2
make[1]: Leaving directory '/home/rogerf81/kernel/caesium/out'
make: *** [Makefile:154: sub-make] Error 2

I'm doing this to compile the kernel:

export ARCH=arm64
export SUBARCH=arm64
export PATH="${HOME}/tc/clang-r353983c/bin:~/tc/aarch64-elf-gcc/bin/:${PATH}"
export CLANG_TRIPLE="aarch64-linux-gnu-"
export CLANG_PREBUILT_BIN="${HOME}/tc/clang-r353983c/bin"
export CC=${CLANG_PREBUILT_BIN}/clang
export CROSS_COMPILE=${HOME}/tc/aarch64-elf-gcc/bin/aarch64-elf-
export CROSS_COMPILE_ARM32="ccache ${HOME}/tc/arm-eabi-gcc/bin/arm-eabi-"

make -j$(nproc) clean
make -j$(nproc) O=out wahoo_defconfig
make -j$(nproc) O=out \
CC=clang \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-elf- \
CROSS_COMPILE_ARM32=arm-eabi-

ans some variations of this, but I always get exactly the same error. What am I missing or doing wrong? Many thanks in advance! :)
[Android Software/Hacking General [Developers Only]] FSadino:
Natan helped me for kernel 3.18 here -> https://xdaforums.com/showpost.php?p=80037438&postcount=600&nocache=1&z=9268079975691624

Don't if works for you but you can give it a shoot
[Android Software/Hacking General [Developers Only]] RogerF81:
This fix is already included it seems. But I now think that the toolchain I use is not compatible. I'm trying AOSP's GCC tc now. Perhaps this will work, hopefully :D
[Android Software/Hacking General [Developers Only]] chompie1337:
Has anyone had success building a kernel with KASAN and KCOV and running it on a device? I was able to compile it using directions I found here:

https://source.android.com/devices/tech/debug/kasan-kcov

But when I flash the Pixel the goes into a bootloop. I changed the board parameters and followed everything in the guide, but something's off. If i remove KASAN and KCOV I can flash the kernel just fine. Super frustrating.
[Android Software/Hacking General [Developers Only]] oneprimedroid:
vmlinux error

hello everyone,

i have been trying to build kernel for pixel 3a xl from aosp. i am getting this error..

/home/prime/Android-kernel/private/msm-google/scripts/link-vmlinux.sh: line 93: 29684 Killed ${LD} ${LDFLAGS} -r -o ${1} $(modversions) ${objects}

/home/prime/Android-kernel/private/msm-google/Makefile:1101: recipe for target 'vmlinux' failed

make[2]: *** [vmlinux] Error 137

Makefile:152: recipe for target 'sub-make' failed

make[1]: *** [sub-make] Error 2

Makefile:24: recipe for target '__sub-make' failed

make: *** [__sub-make] Error 2

i am building on mac but ubuntu is installed on it own ssd. ..not vm...
[Android Software/Hacking General [Developers Only]] palmbeach05:
What is on line 1101 of /home/prime/Android-kernel/private/msm-google/Makefile ?
[Android Software/Hacking General [Developers Only]] oneprimedroid:
vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE

+$(call if_changed,link-vmlinux)

i just did another build but disabled LTO as by android instructions and it built thru but the kernel is 5-6 mb smaller than stock kernel. have not tried to boot it yet...
[Android Software/Hacking General [Developers Only]] kkbs4u:
I was to try build kernel on ubuntu 16 lts

I have already source code for my samsung A705gm

And also configured toolchain

But got some error when compiling

Please help where I am wrongView attachment error.txt
[Android Software/Hacking General [Developers Only]] oneprimedroid:
LOL

Update...

I made a beginner mistake..LOL..

When I installed ubuntu 18.04LTS i did not make a swap partition for linux on the ssd. for 2 weeks i have been trying everything just to build a stock kernel and it would hang and error out at LTO or LD with different errors. I would almost always have to reboot the mac to get things working again..

I was doing a reinstall yesterday and it hit me that i needed a swap part for linux so i made a 100GB part.

Now I have built the stock kernel no less than 6 times without a problem. :D
[Android Software/Hacking General [Developers Only]] TheMarc0:
I get this error when I use the lavender kernel

manufacturing. Where is the mistake?

mkdir out
$ export ARCH=arm64
$ export SUBARCH=arm64
$ export DTC_EXT=dtc
$ export CROSS_COMPILE=${PWD}/toolchain/bin/aarch64-linux-android-
make O=out clean
make O=out mrproper
make O=out lavender-perf_defconfig
make O=out -j$(nproc --all)

Kernel Bulid Error:
LD drivers/staging/qcacld-3.0/wlan.o
LD drivers/staging/qcacld-3.0/built-in.o
LD drivers/staging/built-in.o
LD drivers/built-in.o
make[1]: Verzeichnis „/root/kernel/out“ wird verlassen
make: *** [Makefile:152: sub-make] error 2

Makefile: Makefile:152
sub-make:
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
[Android Software/Hacking General [Developers Only]] SwayWasTaken:
nice work!!
[Android Software/Hacking General [Developers Only]] palmbeach05:
As in android 4.0? Yeah, it hasn't changed. Just the kernel revision and the android version everyone else is on
[Android Software/Hacking General [Developers Only]] Jack_Rickwood:
Hello! Im trying to compile the kernel here (which is based off, and very similar to this).

When I try to compile the kernel I get a number of errors which I have fixed by setting the ANDROID_VERSION and ANDROID_MAJOR_VERSION environment variables to p, but now about 5 secs after executing make -j8 I get a new error:

/mnt/d/AndroidKernel/NethunterKernel/Makefile:587: recipe for target 'scripts' failed
make[1]: *** [scripts] Error 2
make[1]: *** Waiting for unfinished jobs....
Do you know what this could be?

In Makefile line 587 is:

585: scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
586:	asm-generic
587:	$(Q)$(MAKE) $(build)=$(@)
[Android Software/Hacking General [Developers Only]] FakeSmile:
Hello. I'm trying to compiler a kernel for G950F with drivers for nethunter external wifi adapter. I got this error:

/home/zerocount/kernel/kernel/Makefile:1058: recipe for target 'drivers' failed

make[1]: *** [drivers] Error 2

make[1]: Leaving directory '/home/zerocount/kernel/out'

Makefile:152: recipe for target 'sub-make' failed

make: *** [sub-make] Error 2

What does "recipe for target" mean?
[Android Software/Hacking General [Developers Only]] onliner:
Error 2 means that something failed before, look for the previous error in the full output.
[Android Software/Hacking General [Developers Only]] FakeSmile:
Okay. This is the error 1 and error 2:

In file included from include/linux/linkage.h:6:0,

from include/linux/kernel.h:6,

from include/linux/delay.h:10,

from drivers/bluetooth/bcm43xx.c:23:

drivers/bluetooth/bcm43xx.c:80:15: error: 'check_bt_op' undeclared here (not in a function)

EXPORT_SYMBOL(check_bt_op);

^

include/linux/export.h:57:16: note: in definition of macro '__EXPORT_SYMBOL'

extern typeof(sym) sym; \

^

drivers/bluetooth/bcm43xx.c:80:1: note: in expansion of macro 'EXPORT_SYMBOL'

EXPORT_SYMBOL(check_bt_op);

^

scripts/Makefile.build:277: recipe for target 'drivers/bluetooth/bcm43xx.o' failed

make[2]: *** [drivers/bluetooth/bcm43xx.o] Error 1

scripts/Makefile.build:484: recipe for target 'drivers/bluetooth' failed

make[1]: *** [drivers/bluetooth] Error 2

Makefile:1058: recipe for target 'drivers' failed

make: *** [drivers] Error 2

I guess it's all about the first error (undeclared). Fixing it and it will continue to compile. I'm really sick of these errors all the time. I watched every video and read every topic in google about kernel compiling and still errors....

So how do I declare the function in the first error? I compared sources of 2 different kernels and in the other one this part:" EXPORT_SYMBOL(check_bt_op); " in drivers/bluetooth/bcm43xx.c: was missing. So can I just delete it?
[Android Software/Hacking General [Developers Only]] Harshiv989:
[MENTION=6842057]nathanchance[/MENTION]

you said :

why is that? Please explain?

Given that you have the source and compiler and necessary libs, it seems possible to build the kernel on the device that your targeting the build for
[Android Software/Hacking General [Developers Only]] Lieta:
Is it possible to compile a kernel module for kernel running on stock ROM?

I have Xiaomi POCO F1 with stock ROM and want to add kernel modules for NFS support. I compiled kernel from Xiaomi_Kernel_OpenSource repo with gcc toolchain, but on insmod of kernel module I'm getting:

Edit: looks like I selected wrong branch.
[Android Software/Hacking General [Developers Only]] nathanchance:
I mean, I feel like that statement is fairly well worded. If you are compiling on your phone, you would be doing a native rather than cross build so the host tools would work. This guide is written from an x86_64 host perspective, hence that comment.
[Android Software/Hacking General [Developers Only]] Harshiv989:
[MENTION=6842057]nathanchance[/MENTION]

IRL, I think there are GCC 4.x available on internet that are ported to Android, source files can be copied easily. Make, cpio and some of the "build-essentials" could be found in Termux repo.

The compilation time is perhaps the only issue I suppose ? On desktop/laptos, it's about 10-20 minutes, for Android it should be less than an hour for a particularly newly launched device.
[Android Software/Hacking General [Developers Only]] Lieta:
Follow up on "disagrees about version of symbol module_layout". I compiled the correct branch, but got the same error. How to set the right vermagic when compiling?

beryllium:/ # uname -r
4.9.112-perf-g4aff1b2

It means I should compile the commit "4aff1b2" of Xiaomi git kernel repo, but there is no such commit.
[Android Software/Hacking General [Developers Only]] gokart2:
Disregard my OP, my brain has a lot of gas......
[Android Software/Hacking General [Developers Only]] rulim34:
Help please... I was managed to compile the kernel from source code. But it won't boot when i try to flash it. Already try to set SELinux to permissive
[Android Software/Hacking General [Developers Only]] KaMyKaSii:
Check this out

https://xdaforums.com/android/softw...-compile-android-kernel-t3627297/post78999546
[Android Software/Hacking General [Developers Only]] RedGreenBlue123:
Help me this error:

CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK scripts/mod/devicetable-offsets.h
CHK include/generated/timeconst.h
CHK include/generated/bounds.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
make[1]: 'include/generated/vdso-offsets.h' is up to date.
VDSOC32 arch/arm64/kernel/vdso32/vgettimeofday.o
VDSOA32 arch/arm64/kernel/vdso32/sigreturn.o
Assembler messages:
Error: unrecognized option -mfloat-abi=soft
clang-8: error: assembler command failed with exit code 1 (use -v to see invocation)
make[1]: *** [arch/arm64/kernel/vdso32/Makefile:150: arch/arm64/kernel/vdso32/sigreturn.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Assembler messages:
Error: unrecognized option -mfloat-abi=soft
clang-8: error: assembler command failed with exit code 1 (use -v to see invocation)
make[1]: *** [arch/arm64/kernel/vdso32/Makefile:148: arch/arm64/kernel/vdso32/vgettimeofday.o] Error 1
make: *** [arch/arm64/Makefile:182: vdso_prepare] Error 2

Kernel 4.4.19x

First, the error is:

/usr/bin/as: unrecognized option '-EL'

But the error changed to:

Error: unrecognized option -mfloat-abi=soft

like above after i replaced /usr/bin/as with <TOOLCHAIN>/bin/aarch64-linux-android-as.

SOLVED: Change "export CROSS_COMPILE_ARM32=/root/sdmllvm32/bin/arm-linux-android-" to "export CROSS_COMPILE_ARM32=/root/sdmllvm32/bin/arm-linux-androideabi-"

Reason: Wrong 32 Bit toolchain location causes Makefile use old assembler (/usr/bin/as)
[Android Software/Hacking General [Developers Only]] kimocoder:
"enchilada" - OnePlus6 kernel question

[MENTION=6842057]nathanchance[/MENTION]

Hi there! I've got issues with OnePlus kernels, several of them too.. this time it's the "enchilda" OnePlus 6 that gives me a hazzle.. but I think I've only wonder about 2 things..

Does the "vendor" libs has to be fitted into kernel source? E.g this one here: https://github.com/OnePlusOSS/andro...source_kernel/tree/oneplus/SDM845_Q_10.0_Beta with the kernel sources over at https://github.com/OnePlusOSS/android_kernel_oneplus_sdm845/tree/oneplus/SDM845_Q_10.0_Beta ?

If that's the case, how can I do it any way simplier than manually editing/fitting? :D :eek:

Thanks a lot for making these tutorials for us! Cheers!
[Android Software/Hacking General [Developers Only]] onliner:
Yes, those drivers are deeply integrated into the kernel (You may not include them, but you would have to make a "clean" import, I mean, remove a lot of code that depends on those drivers).

You have to add that repo as remote and merge it into drivers.
[Android Software/Hacking General [Developers Only]] kimocoder:
Aaaah, thanks! Found out howto import linux-stable (CAF) in a couple of different ways. But how may I get the vendor files without doing it manually, line-by-line, is there any shortcut to importation of it?

And thanks a lot, git fetch, git remote and git merge is understood :) :) cheers
[Android Software/Hacking General [Developers Only]] onliner:
git remote add <alias> https://github.com/OnePlusOSS/android_vendor_oneplus_opensource_kernel/

git fetch <alias> <branch_name>

git merge -s ours --no-commit FETCH_HEAD --allow-unrelated-histories

git read-tree --prefix=drivers/oneplus -u FETCH_HEAD

git commit
[Android Software/Hacking General [Developers Only]] rulim34:
Still cannot booted up
[Android Software/Hacking General [Developers Only]] Not_Sure:
On some devices you can access last kernel boot log (even if it panicked) via /sys/fs/pstore/console-ramoops

It is very helpful for troubleshooting boot issues provided that your kernel is loaded by boot-loader at all.

If there are stack traces you can convert function addresses to sourcefile and line by addr2line
[Android Software/Hacking General [Developers Only]] gokart2:
I don't remember how to edit the kernel version info, and for the life of me can't find the process on how to? I thought it was done via a build script "export" command of some sort? But was also thinking it could be via an addition to the makefile...or another source file?
[Android Software/Hacking General [Developers Only]] onliner:
export KBUILD_BUILD_USER

export KBUILD_BUILD_HOST
[Android Software/Hacking General [Developers Only]] gokart2:
Thanks. I thought I remembered it being simple. But Google wasn't wanting to work with me. Much appreciated!
[Android Software/Hacking General [Developers Only]] SXUsr:
I feel as giddy as I did the first time I modified my first apk years ago. :D

Had a bit of trial and error using the commands in the OP but then decided to use the instructions in the XPERIA.readme that came with the archive, and voila. Next up is trying to upstream.

I do have a couple of questions though.

1. Where can I change the Kernel version name?

Kind of answered above. I assume you just add "=mykernelname"?

2. I'm also going to build the kernel for my tablet because I want to be able to use the Fota Partition for TWRP instead of it being built into the boot.img, but unsure as to how I go about including this - extract_elf_ramdisk

Any help appreciated.

Thanks.
[Android Software/Hacking General [Developers Only]] nathanchance:
For number 1, you can either use the LOCALVERSION environment variable (export LOCALVERSION=-mykernelname) or CONFIG_LOCALVERSION in your defconfig.

For number 2, I have no idea.
[Android Software/Hacking General [Developers Only]] ezzony:
Hi, total noob to this. First thing I want to do is just compile from source without making any changes. 64 bit architecture device.

$ export CROSS_COMPILE=/home/ezzony/mykernel/aarch64-linux-android-4.9/bin/aarch64-linux-android-

error:

line 25: /home/ezzony/mykernel/aarch64-linux-android-4.9/bin/aarch64-linux-android-gcc: No such file or directory

I had no problems creating the .config file. I tried NDK and googlesource.
[Android Software/Hacking General [Developers Only]] onliner:
The toolchain path (your export CROSS_COMPILE) is wrong, I'm 99.9% sure it's in the "/home/ezzony/" part.

Pro-tip: use ${HOME} instead of /home or ~.
[Android Software/Hacking General [Developers Only]] ezzony:
Makes no difference if I use your suggestions and even $(pwd). In any case the error message produces the correct path in all cases i.e /home/ezzony/mykernel/aarch64-linux-android-4.9/bin/aarch64-linux-android-gcc

This is the code my kernel source code readme file says to use but it did not say where to place the files and the path doesn't make sense to me after the pwd part:

===========================================

a) cd kernel/msm-3.18

b) mkdir -p out

c) make ARCH=arm64 O=./out elsa_nao_us-perf_defconfig

d) make ARCH=arm64 O=./out CROSS_COMPILE=$(pwd)/../../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- KERNEL_COMPRESSION_SUFFIX=gz -j4

==============================================

Is there a chance I've done something else wrong that has noting to do with CC path?
[Android Software/Hacking General [Developers Only]] AndDiSa:
[MENTION=4721914]ezzony[/MENTION] I doubt that you have the compiler binaries installed in /home/ezzony/mykernel/aarch64-linux-android-4.9

generally you have the following structure:

- (android-src)

-- prebuilts/gcc/...

-- ...

-- kernel/<vendor>/msm-3.18

-- ...

-- out/...

...

If you do not follow that structrure, you should define the CROSS_COMPILE environment variable as an absolute path to the compiler binaries, e.g.

export CROSS_COMPILE=/home/ezzony/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

but this depends on the location where you put the compiler binaries.