FORUMS
Remove All Ads from XDA

[REFERENCE] How to compile an Android kernel

13,717 posts
Thanks Meter: 50,713
 
By nathanchance, Recognized Developer / Recognized Contributor on 26th June 2017, 04:38 AM
Post Reply Email Thread
16th July 2017, 05:15 PM |#21  
nathanchance's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mesa, AZ
Thanks Meter: 50,713
 
More
Quote:
Originally Posted by ZawZaw

Hi..Sir Flash,

I want to ask a question for ARM Device. ( Nexus 6 )

This is right method for ARM?

example:

- - - - -
export CROSS_COMPILE=${HOME}/Kernel/Toolchain/bin/arm-eabi-

export ARCH=arm && export SUBARCH=arm

make clean && make mrproper

make shamu_defconfig

make -j$(nproc --all)
- - - - -

I want to know this about.
If this method is wronged, Please teach me Sir.

Thanks.

•••

That's correct.
The Following User Says Thank You to nathanchance For This Useful Post: [ View ]
 
 
16th July 2017, 07:20 PM |#22  
Senior Member
Thanks Meter: 2,241
 
Donate to Me
More
Quote:
Originally Posted by The Flash

You should just be able to copy the whole file (cp .config arch/arm64/configs/marlin_defconfig).

You could run a git bisect on your kernel source and see if there is a commit causing those mismatch errors. Very rarely is that a result of a toolchain or environment configuration.

I got the mismatch errors fixed. It turned out to be this guy:

https://github.com/chevycam94/marlin...eea24c88ea6f61

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.
16th July 2017, 08:43 PM |#23  
D1stRU3T0R's Avatar
Senior Member
Flag Beclean
Thanks Meter: 1,005
 
More
How can i test my own kernel, how can I make a flashable zip, or how should i make it in boot?
16th July 2017, 10:15 PM |#24  
nathanchance's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mesa, AZ
Thanks Meter: 50,713
 
More
Quote:
Originally Posted by D1stRU3T0R

How can i test my own kernel, how can I make a flashable zip, or how should i make it in boot?

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.
The Following User Says Thank You to nathanchance For This Useful Post: [ View ]
16th July 2017, 11:09 PM |#25  
ZawZaw's Avatar
Recognized Developer
Flag Pyay, Myanmar.
Thanks Meter: 3,060
 
More
Quote:
Originally Posted by The Flash

That's correct.

Thanks The Flash.

•••

Sent from my Google Nexus 5X using XDA Labs
17th July 2017, 04:07 PM |#26  
D1stRU3T0R's Avatar
Senior Member
Flag Beclean
Thanks Meter: 1,005
 
More
Delete
18th July 2017, 10:00 AM |#27  
Junior Member
Thanks Meter: 1
 
More
Quote:
Originally Posted by The Flash

Introduction

Hello everyone, I will be going over how to compile a kernel from beginning to end!

Prerequisites:
A Linux environment (preferably 64-bit)
Knowledge of how to navigate the command line
Common sense
A learning spirit, there will be no spoonfeeding here


What this guide will cover:
Downloading the source
Building the kernel
Setting up a build environment (plenty of existing Linux installation guides)
Pull your device's boot image from the latest image available for your device (whether it be a ROM or stock)
Run the following with the boot image:

Run the following to repack:

Download the latest AnyKernel2 zip: https://github.com/osm0sis/AnyKernel...ive/master.zip
Place your kernel image in the root of the file.
kernel.string: your kernel name
block: Your boot image's path in your fstab. The fstab can be opened from the root of your device and it will look something like this:
https://android.googlesource.com/dev...r/fstab.angler
The first column is the value you want to set block to.
[*]After that, zip up the kernel and flash it!
[/LIST][/HIDE][/HIDE]


Tips and tricks


1. Remove GCC wrapper

A lot of kernels from CAF include a Python script that will essentially turn on -Werror, causing your build to error at the most benign stuff. This is necessary with higher GCC versions as there are a lot more warnings.

Here is the diff of what you need to change in the Makefile:


2. Using a higher level GCC toolchain

Using a higher GCC toolchain (5.x, 6.x, 7.x or even 8.x) will require you to nuke the GCC wrapper script as above and use a unified GCC header file (pick the following if you have an include/linux/compiler-gcc#.h file):

3.4/3.10: https://git.kernel.org/pub/scm/linux...9bb8868d562a8a
3.18: https://git.kernel.org/pub/scm/linux...9f67d656b1ec2f

You may get a lot of warnings but they are not entirely necessary to fix.


3. Adding upstream Linux to kernel source

Once you have gotten familiar with git and the compilation process, you should consider upstreaming your kernel. This will allow you to stay on top of CVE and bug fixes by staying up to date with the latest work of the Linux kernel developers.



Receiving help

I am happy to answer anything that I touched on in this guide. I may point you to another thread if it's better suited but I don't mind off topic (within reason) within the thread. I also want this to be a collaborative effort; other developers, if you have something to add, correct, or improve upon, please let me know!

I am particular in how people ask for help. I do NOT respond to posts asking for a hand out ("How do I fix this?", "Please fix this!", etc.). I only respond to posts with clear logs and steps that you have tried. Basically, show me that you have read this guide and have a specific issue. I am not here to hold your hand through this, this is a developers' forum.

This is interesting
18th July 2017, 11:27 AM |#28  
kosmitchak's Avatar
Senior Member
Thanks Meter: 391
 
More
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/androi...droid6?files=1

Thanks!
18th July 2017, 11:32 AM |#29  
DSA's Avatar
Senior Member
Thanks Meter: 5,819
 
More
Quote:
Originally Posted by 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/androi...droid6?files=1

Thanks!

i would guess this is the part:

Code:
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....
18th July 2017, 12:14 PM |#30  
kosmitchak's Avatar
Senior Member
Thanks Meter: 391
 
More
Quote:
Originally Posted by DSA

i would guess this is the part:

Yes i know but i don't know what is wrong with it.
18th July 2017, 06:56 PM |#31  
D1stRU3T0R's Avatar
Senior Member
Flag Beclean
Thanks Meter: 1,005
 
More
Quote:
Originally Posted by 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/androi...droid6?files=1

Thanks!

Hi, no reason why to compile emui 4.1bif you're not Vodafone user..
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes