yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] ezzony:
I downloaded this via git in terminal.

https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/

Which gives me this path to the files: /home/ezzony/mykernel/aarch64-linux-android-4.9/bin/

I had previously downloaded nkd which gave this path:

/home/ezzony/mykernel/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/

I got the same error but I noticed this file was missing in the ndk download: aarch64-linux-android-gcc as per the error. That is why i tried gogglesource instead.

I don't understand the difference between using ndk and googlesource.

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

Does the structure matter, where you store the files, as long as you give the right path, generally?

I have been using absolute path from the beginning as for a beginner it makes it easier for me to learn getting started. My first post here shows an absolute path. I get the same error no matter what way I define the path.
[Android Software/Hacking General [Developers Only]] AndDiSa:
[MENTION=4721914]ezzony[/MENTION]

if your installation directory is /home/ezzony/mykernel/aarch64-linux-android-4.9 you should set CROSS_COMPILE=/home/ezzony/mykernel/aarch64-linux-android-4.9/bin/aarch64-linux-android-

... but one moment: I just saw "gcc-4.9: remove GCC from Android" on the master branch, you didn't checkout master, did you? Probably it's sufficient to checkout "ndk-release-r21" instead of "master" to fix your issues.
[Android Software/Hacking General [Developers Only]] ezzony:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9

expanded

git clone h**ps;//android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9

That is what I input. I don't know what checkout master is. The download was about 300meg. Are there files missing, is that what your saying?

So I have downloaded 2 things, my phones kernel source code directly from LG and the above.
[Android Software/Hacking General [Developers Only]] AndDiSa:
you could try to do a

git checkout ndk-release-r21

in the directory where you have cloned the compiler (aarch64-linux-android-4.9)
[Android Software/Hacking General [Developers Only]] AndDiSa:
well ... doesn't look too bad ;)

probably you'll need to switch to a still older version ... or you do not have all the required tools installed on your PC. It's a bit difficult to tell. I do not know what version you will need, but e.g. "android-8.1.0_r72" might be a good candidate, too.
[Android Software/Hacking General [Developers Only]] ezzony:
I'm currently downloading an older version of NKD, the one I think was used around the time my kernel was built, from June 2018. Can't hurt. https://developer.android.com/ndk/downloads/older_releases.html

As for tools installed on my PC, I just set up Kbuntu 19.04 on a 8yo laptop I hardly use and it's working really well, wifi didn't drop once in 2 days so far! No issues whatsoever actually which is a surprise. Anyway I installed this to begin with:

sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2

When I installed Kbuntu I installed everything on offer and updated. A decade since I've used Linux so I need to update myself as well :D

edit: it's compiling with this! headed in the right direction at least! Thanks!
[Android Software/Hacking General [Developers Only]] ezzony:
Okay so I wasn't expecting that to compile without errors and it didn't.

Just to remind I'm building an amr64 from source - no changes made at all, just looking to make sure my enviroment is set up right before making any changes.

So 2 errors

(the aarch64-linux-android-ar does exist)

and before it stopped, i guess this one is the more serious:

So again could this be down to not using the right toolchain?
[Android Software/Hacking General [Developers Only]] AndDiSa:
As suggested: you can build with

make CONFIG_NO_ERROR_ON_MISMATCH=y

and it should go through. There are some section mismatches which should be solved later, but you can ignore for now.
[Android Software/Hacking General [Developers Only]] gokart2:
Looking for feedback on whether or not compressing a kernel with lz4 instead of the normal compression is a bad idea? Seen it as an option in the config and thought maybe?
[Android Software/Hacking General [Developers Only]] onliner:
Your bootloader must support lz4 (As far as I know, only Pixels support that format), otherwise the phone will not boot.
[Android Software/Hacking General [Developers Only]] ezzony:
Yes it worked! Flashed it on my device - the lcd touch screen didn't work but I connected a keyboard and mouse to control it what way and everything else seems to be okay! I'm hoping to add KCAL color controls after I fix the touchscreen issue. Thanks for your input - I wouldn't have got this far without your help!
[Android Software/Hacking General [Developers Only]] CupangTerbang:
can i update asus zenfone x86 version kernel to higher than 3.10 ??

cause it was bug on wifi if it always connect & disconnect.

if yes where i can find that kernel source ??

---------- Post added at 10:30 PM ---------- Previous post was at 10:28 PM ----------

can i update asus zenfone x86 version kernel to higher than 3.10 ??

cause it was bug on wifi if it always connect & disconnect phpne got hang due kernel bug.

if yes where i can find that kernel source ??
[Android Software/Hacking General [Developers Only]] onliner:
Theoretically yes, but it depends on some factors, it's necessary that CAF has published a new kernel version for that soc (For example, sd 625 received 4.9 last year), and then you must rewrite the device-specific kernel drivers to be compatible with the new kernel version.
[Android Software/Hacking General [Developers Only]] ezzony:
I have a problem which I though had nothing to do with the build process but after hours of going though the code and not being able to sort a problem I'm having I'm beginning to thing I've done something wrong i.e not done something that was required therefore the question may be relevant in this thread.

So, I built successfully from source for my LG fone (Qualcomm Snapdragon 820 MSM8996). I didn't make any changes at all, just built it, and the touchscreen does not work.

I put the Image.gz-dtb in a flashable zip and I unpacked the boot.img and repacked it as an alternative method. Still no go.

I see I have 15 modules. I didn't do anything with them. Should I have. One of them is a lcd.ko file. Those files would already exist on the device anyway.

There are other files created in /arch/arm64/boot where the image.gz-dtb file is created. What are they for?

I see in the compilation output process something happens with generating keys. Could this in any way be relevant to my issue?

That'll do for now.
[Android Software/Hacking General [Developers Only]] Matrid:
Hi thanks for this great resource and advice in this thread so far.

I'm hoping someone can help.

I'm definitely a noob when it comes to compiling any kind of kernel.

I'm working on an experiment to take a dump of volatile memory from a device using LiME and to do this, I need to compile an identical kernel to the one in my test device, using the same compiler used for the running kernel in the device.For my project, I'm working with an original gen Google Pixel, arm64 architecture, running NDE63H android-7.1.0_r1.

In adb, "cat /proc/version" returns;

So I've downloaded android-msm-marlin-3.18-nougat-dr1 source and the compiler aarch64-linux-android-gcc (GCC) 4.9 20150123 (prerelease).

I'm getting to the stage I'm getting to the point of 3.4. "Build the kernel" and receive the following error for the "make clean" command;

Similarly, if I skip this and jump straight to "make marlin_defconfig", I receive this;

Sorry if there is an obvious error staring me in the face or if I haven't provided enough information but I feel like I'm going in circles trying to troubleshoot and would be extremely grateful for some advice!

Thanks! :)
[Android Software/Hacking General [Developers Only]] kevintm78:
If it's your first build attempt then I would skip the <make clean> and <make mrproper> commands since there's nothing to clean (I assume). I would also suggest building to an <out> folder if you're not already, just remember the <make> commands change to this <make 0=out (option)>
[Android Software/Hacking General [Developers Only]] SXUsr:
So frustrated.

Hi all.

I'm trying to upstream my kernel from 4.4.78 but have once again run in to an issue. I am able to compile that version and cherry pick a DRM mod to it successfully. I compiled and flashed 4.4.79 successfully so thought I would carry on for as long as time permitted, merging, resolving conflicts, adding and commiting and got to 4.4.87. I've tried to flash that but it gets stuck on the Sony logo. I also get two warnings about the BL being unlocked which I don't ordinarily.

I've attached the log but have no clue what I'm supposed to be looking for that would tell me what the issue is. Also, if anyone reading this knows how to do an "OEM import" I'd appreciate the info.

Thanks.
[Android Software/Hacking General [Developers Only]] kevintm78:
I'm wanting to try an OEM import myself and unfortunately don't know much about it yet but I thought I would bring up git bisect in case you were unaware of it. If you are unfamiliar with it its a very handy git command for narrowing down the commit(s) thats causing the boot issue.

This will explain it much better than I can. It helped me numerous times when going through this process. In a nutshell what it does it take the last commit that you know is good and the commit you're at now and will go to the halfway commit between the two so you can build and test. Depending on your results it will split again between the new good/bad commit and work towards the middle to further narrow it down.
[Android Software/Hacking General [Developers Only]] :
It can often be a wrong merge resolution in some driver. If you have, look at another kernel and how it's resolved. Also trying to boot more often is a good idea
[Android Software/Hacking General [Developers Only]] kevintm78:
If you're running lineage it's most likely posted in the first post of the rom you're using. If not, I think it's supposed to be. That's my understanding of it anyhow. LineageOS is open sourced so I assume....
[Android Software/Hacking General [Developers Only]] kevintm78:
OK, your second link, https://github.com/LineageOS/android_kernel_sony_msm8994 is your kernel source and the ReadMe file has building instructions and tells which defconfig to use. It seems to be pretty straightforward from the little bit that I read.
[Android Software/Hacking General [Developers Only]] Emerald_N8:
hello

i did compile the kernel , now i have a Image file in arch/arm64/boot and i want to flash it

actually i dont no what exactly boot.img is

its my device rom image or something in my rom?

and how can i get that

im using rooted htc desire 826 with stock rom marshmallow and TWRP installed

thank you

(sorry if i had a bad english)
[Android Software/Hacking General [Developers Only]] Emerald_N8:
kernel

thanks for your quick reply

i made my flashable boot img but its size is a bit bigger than my phones boot img

i did not care and flashed with terminal when phone was in bootloader

i got some errors and it did not flashed then i tried to flash with TWRP

so it did flashed but my phone did not boot and stocked in HTC logo

i flashed my phones boot img again and now its booting up normally

do you have any idea why it did not booted when i flashed that ?

should i try another kernel source code ?
[Android Software/Hacking General [Developers Only]] All-In-One:
I think it's probably because your boot.img is larger than the boot partition on your device, so it can not be flashed properly because it does not fit in.
[Android Software/Hacking General [Developers Only]] wojtoo:
[MENTION=6842057]nathanchance[/MENTION] thx for great work

But how to build kernel with gcc 9.2.0

could you please add manual for that
[Android Software/Hacking General [Developers Only]] kl16:
Hi everyone! I'm trying to compile a kernel module for an Android 10 emulator (x86) in Android Studio. I've been following lots of advice in this thread as well as guides from online, but I can't figure out how to compile it without errors. I'm developing on a Windows x86-64 machine, and I'd like to compile to Android x86. My Makefile is shown below. The error I keep getting is:

clang: error: no such file or directory: 'path/to/file/hellokernel.c'

clang: error: no input files

I was hoping someone else had previously experienced this and would be able to assist me. Thanks!

Makefile:

obj-m += hellokernel.o

NDK=$(PWD)/android-ndk-r21

TOOLCHAIN=$(NDK)/toolchains/llvm/prebuilt/windows-x86_64

TARGET=i686-linux-android

API=29

CLANG=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang #-target i686-linux-android

KERNEL_DIR=$(PWD)/crosshatch-4.9-android10-qpr1/

all:

make -C $(KERNEL_DIR) M=$(PWD) ARCH=x86 CC=$(CLANG) HOSTCC=$(CLANG) CFLAGS_MODULE=-fno-pic modules
[Android Software/Hacking General [Developers Only]] nathanchance:
Unfortunately, my time nowadays is limited between my job, school, and more important open source projects.

However, compiling with GCC 9.2.0 is the same as compiling with GCC 4.9.4, you point the CROSS_COMPILE variable at the GCC 9.2.0 toolchain (or use PATH and update the CROSS_COMPILE prefix to match) and go from there. There are probably going to be new warnings that you will need to solve and there are potentially some other commits that you will need to pick to get a boot off.

If anyone else wants to pitch in and write something up, I'd be happy to add it to the OP.
[Android Software/Hacking General [Developers Only]] Keskebeu:
Cannot Compile

I am using make 4.1 and tried multiple tool chains. Which toolchain do you recommend for Ubuntu 16.04. I am trying to compile the kernel and I am coming to issues like: include/trace/events/sched.h:783:2: error: #error "Unsupported NR_CPUS for lb tracepoint." I am not using -j option.

Can you help to figure it out. I am trying to build the kernel with realtek and ralink modules but I am not able to build it.
[Android Software/Hacking General [Developers Only]] gudenau:
Trying to do this with the PIxel 4 XL is generating a really bizarre error.

In file included from ../scripts/selinux/genheaders/genheaders.c:19:
../security/selinux/include/classmap.h:247:2: error: #error New address family defined, please update secclass_map.
247 | #error New address family defined, please update secclass_map.
| ^~~~~

Commands:

make mrproper
make O=out clean
make O=out mrproper
make O=out ARCH=arm64 floral_defconfig
make O=out ARCH=arm64 menuconfig
PATH=/.../clang-r353983c/bin/:$PATH make -j8 O=out ARCH=arm64 CC=clang CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=/.../aarch64-linux-android-4.9/bin/aarch64-linux-android- CROSS_COMPILE_ARM32=/.../arm-linux-androideabi-4.9/bin/arm-linux-androideabi-

I am using commit e58a32340f442ce44af7123d502ba4eec69cefc5 from https://android.googlesource.com/kernel/msm/
[Android Software/Hacking General [Developers Only]] Keskebeu:
Kernel Compile

You are specifying two paths for cross_compiling.

For arm64 only a 64 bit toolchain will compile.

If I was you I would do.: export CROSS_COMPILE=/path/to/your/chain/aarch64-linux-android-

export ARCH=arm64

It looks like you are building for 64 bit and 32 bit architecture in your PATH but only 64 bit in your make command.

It has been reported on of glibc 2.29 and newer to have the same build error. Perhaps try an older version of glibc than 2.29.

Let me know if it helps. Good Luck.
[Android Software/Hacking General [Developers Only]] gudenau:
If I don't specify CROSS_COMPILE_ARM32 the build fails, I am using the toolchains from Google.

Clang: https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86

AARCH64: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9

ARM: https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9

Don't know why the official toolchain would not be able to build the kernel.
[Android Software/Hacking General [Developers Only]] Keskebeu:
Kernel Build

________________________________________

https://android.googlesource.com/pl...-linux-android-4.9/+/refs/heads/android10-dev

Try this toolchain instead. The one you pointed me does not have gcc. I would suggest you use ndk prebuilt toolchain version 16b. Which are best and easy to find.

In your main kernel dir you want to build do with root privileges:

User@host#export ARCH=arm64

User@host#export CROSS_COMPILE=/path/to/your/toolchain/

aarch64-linux-android-

make clean && make mrproper

make yourdevice_defconfig (this can be found in arch/arm64/configs directory of your building kernel)

make menuconfig

make

You do not need clang to build a kernel. I just ended up building a custom kernel without clang.
[Android Software/Hacking General [Developers Only]] Wladek01:
So, I've downloaded the kernel for my ocean device and made it some changes. In step two you mention that I have to download a cross compiler. Can't I run the commands in linux ubuntu console directly? If not so, I'm confused about wich cross compiler to download. Could you give me a little light in this matter? Thank you very much.

PS: It's my first time in everything [MENTION=6842057]nathanchance[/MENTION]
[Android Software/Hacking General [Developers Only]] gudenau:
But Google builds the kernel with clang and the gcc toolchains have sleeps built in to make them slow.
[Android Software/Hacking General [Developers Only]] nathanchance:
Either build android-10.0.0_r0.49, where this was fixed because of a linux-stable merge or cherry-pick the actual fix: https://android.googlesource.com/kernel/msm/+/760f8522ce08a24abac3208290f93fe3fffc0d6c
[Android Software/Hacking General [Developers Only]] gudenau:
I applied that patch and now I am having a different issue. I tried a few things, including adding the AARCH64 and ARM toolchain bins to the path and specifying AS.

arch/arm64/Makefile:49: LSE atomics not supported by binutils
arch/arm64/Makefile:57: Detected assembler with broken .inst; disassembly will be unreliable
CHK include/config/kernel.release
GEN ./Makefile
CHK include/generated/uapi/linux/version.h
Using .. as source for kernel
CHK include/generated/utsrelease.h
HOSTCC scripts/kallsyms
HOSTCC scripts/sortextable
CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
CC scripts/mod/devicetable-offsets.s
/usr/bin/as: unrecognized option '-EL'
clang-9: error: assembler command failed with exit code 1 (use -v to see invocation)

Sorry for being such an idiot.

Edit:

I did rerun all the mrpropper, cleans and config commands before this. The out dir and kernel dir where clean.
[Android Software/Hacking General [Developers Only]] nathanchance:
Your CROSS_COMPILE variable is just not set properly. It needs to either be the full patch to your aarch64-linux-gnu- or aarch64-linux-android- toolchain or just aarch64-linux-gnu- or aarch64-linux-android-, depending on what you are doing.
[Android Software/Hacking General [Developers Only]] Uzephi:
Unless your computer's Arch is also ARM/ARM64 (depending on device), you need a cross compiler. If you build without one, your target Arch will be what is running your computer (usually x86/x64).
[Android Software/Hacking General [Developers Only]] Wladek01:
Yes, but how do I know which one to download? Three are lots of them
[Android Software/Hacking General [Developers Only]] achilles_85:
Hi!

I want build PIE https://github.com/SyberiaProject-Devices/platform_kernel_xiaomi_msm8996/tree/9.0kernel for Xiaomi mi5 with Clang, kernel version 3.18. But building stops with mistake

error: the clang compiler does not support '-mcpu=cortex-a57.cortex-a53'
error: optimization flag '-fno-modulo-sched' is not supported [-Werror,-Wignored-optimization-argument]

Build kernel with those commands

make O=out ARCH=arm64 gemini_defconfig
make -j$(nproc --all) O=out ARCH=arm64 SUBARCH=arm64 CC="$HOME/MI5/clang/bin/clang" CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE="$HOME/MI5/aarch64-linux-android-4.9/bin/aarch64-linux-android-"

Where do i wrong?

And second. I build kernel for PIE 4.4 and LOS 16 3.18 without Clang and did not have any trouble. But with https://github.com/SyberiaProject-Devices/platform_kernel_xiaomi_msm8996/tree/9.0 i have issue, while doing

make O=out clean

i get error

/home/user/MI5/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-: Command not found

But all steps from this post https://xdaforums.com/showpost.php?p=77273046&postcount=346 i doing right, because other 2 kernels i can build without any error. Please, help me find my mistake.
[Android Software/Hacking General [Developers Only]] GadgetCrusader:
where do I start learning the code languange?
[Android Software/Hacking General [Developers Only]] gudenau:
That is weird, I am using exact paths but it is still trying to use the system's ar. I really don't get it.

Edit:

Now that I retyped all the paths and started using the PATH variable it is now saying it can't find the aarch64 gcc.
[Android Software/Hacking General [Developers Only]] nathanchance:
git clone -b android-9.0.0_r1 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
[Android Software/Hacking General [Developers Only]] Hari Nguyen:
So I try to build kernel for my sony device (Xperia XA1 Plus) device name is teak and currently running android 8.0, I download kernel source from Sony open source website and using GCC 4.8 cross compiler (branch ndk-release-18) every thing work just fine till I try to run make and it turn back a bunch of error, or warning (I'm not familiar with make)

full log here: https://paste.ee/p/CoRT9
[Android Software/Hacking General [Developers Only]] ezzony:
Something I'm unclear on.

I have noticed looking at other devs anykernel zips that some of them have added .ko files in the ramdisk folder /system/modules.. For example lcd.ko. The files seem to be created at the same time as compiling the kernel. Is it correct to say that in the case they are already on the device there is not need to put them in?. I often see some anykernel zips have them and some don't. The thing I'm wondering is do those exact files need to be used with that kernel image that was created with them for some reason?
[Android Software/Hacking General [Developers Only]] nathanchance:
"#error NO corresponding project of mtk_udi.h header file can be found!!!"

Seems your source might be incomplete but I don't know. Are you using "O=out" with all of your make commands?

It all depends on the device and kernel. .ko are kernel modules and generally/usually need to be recompiled/flashed when working with a different kernel. In other words, the stock kernel modules will not load on a source built kernel. You can avoid building them separately by just building them into the kernel image itself (change '=m' to '=y' in your config file). That won't always work without any issues but it usually does.

Hopefully that clears things up!
[Android Software/Hacking General [Developers Only]] Soul Spark:
Hey [MENTION=6842057]nathanchance[/MENTION], thanks to your guide I was able to compile my first kernel.

I used the following source https://github.com/iamsaalim/kernel_asus_X01A to build it.

used the zql1830-perf_defconfig to build for Asus Zenfone Max M2.

There were some warnings with the build https://pastebin.com/SKttwX3y

But there are some problems with the result. It won't boot at all. It just redirect to bootloader everytime.

I even tried:

But the final boot.img is too large to flash.

Please help me.