yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] Phil_Smith:
Hi,

first of all thank you for this nice guide! : )

Sadly, following this tutorial I get the following error message trying to compile stock jdc nougat 7.1.2 kernel for gemini:

https://hastebin.com/cagimajara.coffeescript

kernel source:

https://github.com/AOSP-JF-MM/platform_kernel_xiaomi_msm8996

Strangely enough, when building the whole ROM as in here:

https://github.com/AOSP-JF-MM/platform_manifest

I don't get any errors and the ROM including the kernel builds up just fine.

Does anyone know what this might be about?

Thanks in advance!
[Android Software/Hacking General [Developers Only]] HemanthJabalpuri:
[MENTION=6842057]nathanchance[/MENTION]

Sir my device has a custom kernel...

That has 1.22.2 Dorimanx busybox....

I think it is outdated and i want to replace this with latest stericson....

Should I just replace busybox file in sbin of ramdisk and recompile or anything else are required to change to work?
[Android Software/Hacking General [Developers Only]] turbo81:
Hi,

I have successfully compile my kernel for my Marlin and also tested newly generated Image.lz4-dtb by:

fastboot boot Image.lz4-dtb

My phone booted up with the new kernel without any issue.

Then I downloaded the factory image from

https://dl.google.com/dl/android/aosp/marlin-ppr1.180610.009-factory-90a4fa8b.zip

Unzip the factory image.

Got the latest Android Kitchen 3.3 and run:

unpackimg boot.img
cd split_img

Renamed Image.lz4-dtb to boot.img-zImage, replaced the boot.img-zImage in split_img with the new boot.img-zImage

and then repack the image:

repackimg.sh

One repacked I rename image-new.img to boot.img

Subsequently flash the new boot.img

fastboot flash boot boot.img

Then boot loop.

Anyone able to point me to the right direction. I thought I got it right since I am able to fastboot boot Image.lz4-dtb

Or at the point after compiling successfully, I have an Image, Image-dtb, Image.gz, or Image.gz-dtb file.

can I just fastboot flash kernel Image?

Many thanks.

Wayne
[Android Software/Hacking General [Developers Only]] iissmart:
Wifi isn't working on my Pixel 2 after flashing a 9.0 kernel I compiled myself. Is there a driver that needs to be enabled in the .config?
[Android Software/Hacking General [Developers Only]] nathanchance:
Change CONFIG_QCA_CLD from m to y.
[Android Software/Hacking General [Developers Only]] rhutik:
How to compile a kernel for android pie?
[Android Software/Hacking General [Developers Only]] DSA:
Basically, as detailed in the op but with pie sources (There will be fixes to do etc, but the basics are very similar)
[Android Software/Hacking General [Developers Only]] zongojim:
Hello,

I tried to build a kernel for android pie on Pixel 2 -XL, but I have an issue: the touchscreen does not work anymore...

Does anybody would be able to help ?

Here is what I did:

- retrieve repository android-msm-wahoo-4.4-pie from android.googlesource.com/kernel/msm.git

- make wahoo_defconfig

- export PATH=$PATH_TO_AOSP/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:$PATH

- export PATH=$PATH_TO_AOSP/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:$PATH

- export PATH=$PATH_TO_AOSP/prebuilts/clang/host/linux-x86/clang-4393122/bin:$PATH

- export ARCH=amr64

- export CROSS_COMPILE=aarch64-linux-android-

- export CROSS_COMPILE_ARM32=arm-linux-androideabi-

make CC=clang -j24

then I copied arch/arm64/boot/dtbo.img and arch/arm64/boot/Image.lz4-dtb to $PATH_TO_AOSP/device/google/wahoo-kernel

The flash is ok, the phone starts, but the touchscreen is unresponsive.
[Android Software/Hacking General [Developers Only]] nathanchance:
You need to change all of the '=m' entries in the defconfig to '=y'.
[Android Software/Hacking General [Developers Only]] zongojim:
replace all =m to =y works, many thanks !!!

What does =m mean ?
[Android Software/Hacking General [Developers Only]] nathanchance:
Module so it's built as a .ko object which is loaded externally during boot
[Android Software/Hacking General [Developers Only]] tony_686:
Nice and useful info!!

---------- Post added at 09:04 AM ---------- Previous post was at 08:58 AM ----------

Thank you! gonna try it
[Android Software/Hacking General [Developers Only]] korom42:
[HELP] Compiling : Makefile errors

[MENTION=6842057]nathanchance[/MENTION] Thank you so much for this guide

I am getting errors trying to compile U11 kernel forked from ElementalX by [MENTION=4684315]flar2[/MENTION]

https://imgur.com/a/tE5Elfw

make clean
lib/Makefile:17: *** recipe commences before first target. Stop.
Makefile:1213: recipe for target '_clean_lib' failed
make: *** [_clean_lib] Error 2
[Android Software/Hacking General [Developers Only]] rhutik:
everything worked fine but after 5min got this error please help

kernel/built-in.o: In function `sched_slice.isra.75':
jump_label.c:(.text+0x3d8e0): undefined reference to `__multi3'
jump_label.c:(.text+0x3d8e0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
kernel/built-in.o: In function `update_curr':
jump_label.c:(.text+0x3de48): undefined reference to `__multi3'
jump_label.c:(.text+0x3de48): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
kernel/built-in.o: In function `task_dead_fair':
jump_label.c:(.text+0x3e490): undefined reference to `__multi3'
jump_label.c:(.text+0x3e490): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
jump_label.c:(.text+0x3e4ac): undefined reference to `__multi3'
jump_label.c:(.text+0x3e4ac): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
jump_label.c:(.text+0x3e56c): undefined reference to `__multi3'
jump_label.c:(.text+0x3e56c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
kernel/built-in.o:jump_label.c:(.text+0x3e590): more undefined references to `__multi3' follow
kernel/built-in.o: In function `task_dead_fair':
jump_label.c:(.text+0x3e590): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
kernel/built-in.o: In function `migrate_task_rq_fair':
jump_label.c:(.text+0x3e6cc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
jump_label.c:(.text+0x3e6e8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
jump_label.c:(.text+0x3e7a8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
jump_label.c:(.text+0x3e7cc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__multi3'
kernel/built-in.o: In function `check_preempt_wakeup':
jump_label.c:(.text+0x3ea44): additional relocation overflows omitted from the output
Makefile:986: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

please help
[Android Software/Hacking General [Developers Only]] nathanchance:
Just skip the make clean for now and go straight to make.

Normally I just ignore posts like this since you clearly didn't follow the "Receiving help" section but I want to make this an educational opportunity. How in the world am I supposed to help you when you give me quite literally zero information?

Nothing about device, toolchain, kernel source link.

Please realize I'm not a wizard or magician. I cannot read your mind. My initial guess is your kernel source is broken or your toolchain is. Please come back with more info if you want my help.
[Android Software/Hacking General [Developers Only]] rhutik:
Sir i gave full info see above
[Android Software/Hacking General [Developers Only]] DSA:
No, you didnt. Re-read nathans post, especially this bit:
[Android Software/Hacking General [Developers Only]] kevintm78:
In the future, you might want to either include a link to your previous post or just add that info again to your second post. Once you pointed it out I saw the first post, but unless they're subsequent posts it's probably not going to get noticed.
[Android Software/Hacking General [Developers Only]] korom42:
http://prntscr.com/kl1gyi

lib/Makefile:17: *** recipe commences before first target. Stop.

Makefile:1213: recipe for target '_clean_lib' failed

make: *** [_clean_lib] Error 2

Update: I changed my building environment to Fedora 28 and that problem is fixed now. But, I am getting another error I guess it is related to the source code , I found a similar issue here

My working setup:

Information about my OS:

Virtualization: oracle

OS: Ubuntu 16.04 Fedora 28 (Workstation Edition)

Kernel: Linux 4.17.17-200.fc28.x86_64

CPU: Intel Core i5-7200u @ 2x 2.7GHz [50.0°C]

GPU: intel

RAM: 2048MiB

Prepare :

export CROSS_COMPILE=/home/korom42/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export ARCH=arm64
export SUBARCH=arm64
export USE_CCACHE=1
make elementalx_defconfig
make /or make O=out

Compile issue:

[...]
CC drivers/base/module.o
CC drivers/base/soc.o
CC drivers/base/pinctrl.o
CC drivers/base/platform-msi.o
LD drivers/base/built-in.o
CC drivers/block/brd.o
CC drivers/block/loop.o
CC drivers/block/zram/zcomp_lzo.o
CC drivers/block/zram/zcomp.o
CC drivers/block/zram/zram_drv.o
CC drivers/block/zram/zcomp_lz4.o
LD drivers/block/zram/zram.o
LD drivers/block/zram/built-in.o
LD drivers/block/built-in.o
CC drivers/bluetooth/bluetooth-power.o
CC drivers/bluetooth/btfm_slim.o
drivers/bluetooth/btfm_slim.c:26:23: fatal error: btfm_slim.h: No such file or directory
#include <btfm_slim.h>
^
compilation terminated.
make[2]: *** [scripts/Makefile.build:264: drivers/bluetooth/btfm_slim.o] Error 1
make[1]: *** [scripts/Makefile.build:408: drivers/bluetooth] Error 2
make: *** [Makefile:966: drivers] Error 2

I also tried

make O=out clean

And got the same error

Kernel source: https://github.com/korom42/ocean

Main Tree: https://github.com/flar2/ocean
[Android Software/Hacking General [Developers Only]] nathanchance:
Use "make O=out" for all make commands.
[Android Software/Hacking General [Developers Only]] ThePiGuy:
[MENTION=6842057]nathanchance[/MENTION] I don't think this is really the right place for it, but I was wondering if you could explain how you make a kernel made for an old version of Android compatible with a newer version. Is there a well known method or do you build with the old kernel, fix errors and repeat?

Edit: I forgot to mention this would be for a device without support for the new android version
[Android Software/Hacking General [Developers Only]] nathanchance:
I've never personally done this because I don't use custom ROMs anymore but the general idea is to comb through Google's kernels and look for critical things. With Oreo to Pie, I don't believe there are any kernel specific changes needed for compatibility.
[Android Software/Hacking General [Developers Only]] nathanchance:
Maybe, maybe not, I don't know because I use AnyKernel2 for all of my kernels, I have never messed with a full ramdisk or Busybox.

You really don't need to quote, mention, AND message me....
[Android Software/Hacking General [Developers Only]] KiD3991:
cc1: warning: unrecognized command line option '-Wno-switch-unreachable'

cc1: warning: unrecognized command line option '-Wno-int-in-bool-context'

cc1: warning: unrecognized command line option '-Wno-format-overflow'

cc1: warning: unrecognized command line option '-Wno-memset-elt-size'

cc1: warning: unrecognized command line option '-Wno-duplicate-decl-specifier'

cc1: warning: unrecognized command line option '-Wno-bool-operation'

cc1: warning: unrecognized command line option '-Wno-format-truncation'

cc1: warning: unrecognized command line option '-Wno-misleading-indentation'

scripts/Makefile.build:307: recipe for target 'drivers/input/input.o' failed

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

scripts/Makefile.build:443: recipe for target 'drivers/input' failed

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

Makefile:997: recipe for target 'drivers' failed

make: *** [drivers] Error 2

Dear sir. Any idea for this error?
[Android Software/Hacking General [Developers Only]] nathanchance:
You or your kernel developer should be disabling new GCC flags like this:

KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)

instead of like this:

KBUILD_CFLAGS += -Wno-int-in-bool-context
[Android Software/Hacking General [Developers Only]] :
[MENTION=6842057]nathanchance[/MENTION] Thank you so much for this guide. Followed it to build my first kernel for Galaxy S7 and Edge. Very clear and helpful and the guide to use AnyKernel2 was excellent. I also used your guide to upstream my kernel as well. Thanks bro!!
[Android Software/Hacking General [Developers Only]] nathanchance:
That's correct.
[Android Software/Hacking General [Developers Only]] chevycam94:
I got the mismatch errors fixed. It turned out to be this guy:

https://github.com/chevycam94/marlin_kernel/commit/b82627ead81eaca16c547e5517eea24c88ea6f61

Now all I have to do is diagnose my random system crash/ramdumps. Locking up quite a bit. This should be interesting. Not sure how to debug kernel issues. Remember, this is my first time working on a kernel. :P

Done plenty of ROMs, just never the kernel itself.
[Android Software/Hacking General [Developers Only]] D1stRU3T0R:
How can i test my own kernel, how can I make a flashable zip, or how should i make it in boot?
[Android Software/Hacking General [Developers Only]] nathanchance:
I cover that in step 4 lol; if you are having issues understanding any of it, you need to ask more specific questions so I can clear those up.
[Android Software/Hacking General [Developers Only]] ZawZaw:
Thanks The Flash.

•••
[Android Software/Hacking General [Developers Only]] D1stRU3T0R:
Delete
[Android Software/Hacking General [Developers Only]] kanjanja:
This is interesting
[Android Software/Hacking General [Developers Only]] kosmitchak:
Hi i'm trying to compile Kernel for P8 lite (emui 4.1 ALE-L21) but i'm getting errors and compiling stops.

https://pastebin.com/pRT4AgMA

I don't know what is wrong :( can somebody help me?

Source code: https://github.com/kosmitchak/android_kernel_huawei_hi6210sft/tree/android6?files=1

Thanks!
[Android Software/Hacking General [Developers Only]] DSA:
i would guess this is the part:

aarch64-linux-android-ld: no input files
scripts/Makefile.build:454: polecenia dla obiektu 'init/mounts.o' nie powiodły się
make[1]: *** [init/mounts.o] Błąd 1
CC arch/arm64/mm/copypage.o
Makefile:883: polecenia dla obiektu 'init' nie powiodły się
make: *** [init] Błąd 2
make: *** Oczekiwanie na niezakończone zadania....
[Android Software/Hacking General [Developers Only]] kosmitchak:
Yes i know but i don't know what is wrong with it.
[Android Software/Hacking General [Developers Only]] D1stRU3T0R:
Hi, no reason why to compile emui 4.1bif you're not Vodafone user..
[Android Software/Hacking General [Developers Only]] kosmitchak:
Emui 4.0 Kernel source is outdated :(
[Android Software/Hacking General [Developers Only]] D1stRU3T0R:
I know, but emui 4.1 Kernel won't boot on emui 4.0.3 :/ i think latest and best is Esal...but at first upstream i got 4 commits to resolve.
[Android Software/Hacking General [Developers Only]] kosmitchak:
Now i started working on emui 4.0 Kernel source, maybe we can cooperate xD
[Android Software/Hacking General [Developers Only]] Mandy $ingh:
https://pastebin.com/dDc3aiqs got error while compiling plz help and source link is https://github.com/jcadduono/android_kernel_samsung_exynos7870
[Android Software/Hacking General [Developers Only]] Gingernut78:
Thank you for the detailed tutorial on kernel building.

I've followed this guide and successfully built the lineageos Mi5s kernel without errors using Google's 4.9 prebuilt cross compiler.

The only modifications to the source code I made were to resolve building errors, nothing else, but unfortunately it doesn't boot.

I kindly asked the developers for some enlightening as to why but was told that they don't build the standalone kernel so can't help.

Would it have anything to do with no dt.img and not using dtbTool?

My zImage.gz-dtb image was repacked with the latest lineageos boot.img and also tried with Anykernel2.

Any help is kindly appreciated and sorry if this is way off topic :angel: .
[Android Software/Hacking General [Developers Only]] Jleeblanch:
Thanks for this, glad to see someone made an updated kernel compilation guide. A while back, I had done some extensive searching trying to learn how to build and compile a kernel. As there was no updated info, it was quite a learning experience to say the least! I had to use bits a pieces of guides here on xda, info from GitHub, info from within the kernel source documentation and various other Google searches to finally be able to successfully build a kernel.

Point is, thank you for an updated reference guide, you the man [emoji6]
[Android Software/Hacking General [Developers Only]] D1stRU3T0R:
Delete lol
[Android Software/Hacking General [Developers Only]] D1stRU3T0R:
What I should do?
[Android Software/Hacking General [Developers Only]] zhaozihanzzh:
It seems that there are errors, so you can check the information and find errors which cause sub-make failed. Sorry, I am a noob.
[Android Software/Hacking General [Developers Only]] tripLr:
So as a noob

I have built for many laptops and servers doing

The kernelewbies.org/KernelBuild method

I am just starting to learn how to include non-free proprietary drivers

I assume like many ROMs , manufactures like Samsung

Have closed source drivers which have to be included in a custom kernel and ROM.

Is this the general method?

And is there a step by step to extract OEM drivers to add them to the new kernel?

The 4.x.x kernel makemenuconfig script allows for including driver modules not in the git download tree.

And how do I select arm instead of x86 to compile ?

How do I find the .config in my existing ROM?

I need to git (download) my kernel source.

Copy my blobs ( oem drivers ) into a kernel source folder?

Mention the blobs in a config file somewhere ?

Then compile into a out directory?

Thanks
[Android Software/Hacking General [Developers Only]] MrMeeseeks:
I have a suggestion. Maybe under the Tips and Tricks section, you could add some Pixel 2/2 XL specific packages that don't seem to be documented very well. Like DTC, mkbtimg and liblz4-dev.

Edit: Well they might not be Pixel specific but for noobs like myself, it sure would be nice if someone put these in their guide.
[Android Software/Hacking General [Developers Only]] FAT32 SHAMER:
Voice Assistant inclusion

I'm not sure if you would know or if this is the right place to ask, but if I have the Alexa SDK and wanted to try building that into a customized kernel that I've been working on for a board that I built. Would I need to customize anything in the kernel, or would the SDK handle all of that for me?

I know the source code on google's repo master branch doesnt have any sort of voice assistant built into it, so it should be relatively easy, just a matter of determining what classes to modify

e; it has come to my attention that the OEM will bundle whatever voice assistant they want as an app and set it as the default in their builds of android and that they are not built into the OS itself, so that solves that mystery. thanks!
[Android Software/Hacking General [Developers Only]] pixeluser:
I've getting stuck on the zipping the kernel image. I have successfully compiled the kernel and i have:

Image

Image.lz4

Image.lz4.dtb

Using the AIK method, i renamed the "Image" to "boot.img-zImage" and restored it and the file is too large to flash(34mb),using the compressed image,"Image.lz4" results in a bootloop after flashing.Same things goes for the .dtb file. What is the exact method here to get a proper flashable kernel?
[Android Software/Hacking General [Developers Only]] Wishpering:
make -j4 error

Hi all, I am getting error Makefile:801: *** multiple target patterns. Stop. on make -j4

My steps:

cd ~/hdd/Kernel/aarch64-linux-android-8.x

export CROSS_COMPILE=$(pwd)/bin/aarch64-linux-android

export ARCH=arm64 && export SUBARCH=arm64

cd ~/hdd/Kernel/kenzo

sudo make clean

sudo make mrproper

CLEAN scripts/basic

CLEAN scripts/kconfig

CLEAN include/config

CLEAN .config

make kenzo_defconfig

make[1]: 'kenzo_defconfig' is up to date.

make -j4

Makefile:801: *** multiple target patterns. Stop.
[Android Software/Hacking General [Developers Only]] nathanchance:
Recompile your Clang 8 toolchain from latest master, this has been fixed upstream without any need for code changes in Linux. The gettimeofday errors are due to an incompatible GCC toolchain.
[Android Software/Hacking General [Developers Only]] janjan:
I tried with latest GCC 8.2 and still this issue.

In file included from ../arch/arm64/kernel/asm-offsets.c:21:
In file included from ../include/linux/sched.h:19:
In file included from ../include/linux/timex.h:56:
In file included from ../include/uapi/linux/timex.h:56:
In file included from ../include/linux/time.h:5:
In file included from ../include/linux/seqlock.h:35:
In file included from ../include/linux/spinlock.h:57:
../include/linux/bottom_half.h:18:24: error: returning address of label, which is local [-Werror,-Wreturn-stack-address]
__local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
^~~~~~~~~
../include/linux/kernel.h:134:64: note: expanded from macro '_THIS_IP_'
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
^~~~~~~~
In file included from ../arch/arm64/kernel/asm-offsets.c:21:
In file included from ../include/linux/sched.h:19:
In file included from ../include/linux/timex.h:56:
In file included from ../include/uapi/linux/timex.h:56:
In file included from ../include/linux/time.h:5:
In file included from ../include/linux/seqlock.h:35:
In file included from ../include/linux/spinlock.h:57:
../include/linux/bottom_half.h:31:23: error: returning address of label, which is local [-Werror,-Wreturn-stack-address]
__local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);
^~~~~~~~~
../include/linux/kernel.h:134:64: note: expanded from macro '_THIS_IP_'
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
^~~~~~~~
HOSTCC scripts/dtc/livetree.o
HOSTCC scripts/mod/modpost.o
HOSTCC scripts/asn1_compiler
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/dtc/treesource.o
2 errors generated.
.././Kbuild:55: recipe for target 'arch/arm64/kernel/asm-offsets.s' failed
make[2]: *** [arch/arm64/kernel/asm-offsets.s] Error 1
/home/ajo/123android/msm/wahoo-pie-4.4157/Makefile:1090: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: *** Waiting for unfinished jobs....
HOSTCC scripts/dtc/srcpos.o
HOSTCC scripts/extract-cert
HOSTCC scripts/dtc/checks.o
HOSTCC scripts/dtc/util.o
SHIPPED scripts/dtc/dtc-lexer.lex.c
SHIPPED scripts/dtc/dtc-parser.tab.h
SHIPPED scripts/dtc/dtc-parser.tab.c
HOSTCC scripts/dtc/dtc-lexer.lex.o
HOSTLD scripts/genksyms/genksyms
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTLD scripts/mod/modpost
HOSTLD scripts/dtc/dtc
make[1]: Leaving directory '/home/ajo/123android/msm/wahoo-pie-4.4157/out'
Makefile:152: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
-------------------
Build is Completed:
-------------------

It is strange that it works fine when I use clang-r328903. But fails with clang-r339409. Maybe I should just use clang-r328903. Thank u
[Android Software/Hacking General [Developers Only]] nathanchance:
As I said, it's been fixed upstream, you'll just have to wait for it to trickle down into Google's builds.

In the meantime, you can apply this change: https://github.com/nathanchance/wahoo/commit/0ae9cccde4c75bcc55e83bf66afeb1424b3d0a8b

Just realize that it should be reverted once the Clang fix is available like so: https://github.com/nathanchance/wahoo/commit/429232ee6959f101febda801420e0359dc1344f9