[GUIDE][TUT]Building a kernel from source[EASY WAY] - Galaxy Grand Duos i9082 General

Hi guys!
I wrote this guide because after a few month of kernel development i found useful tools and tricks than helped me a lot and speeded up my work and i want to share with you this knowledge.
Setup computer and download sources​
Code:
Minumum reqirement:
* C knowledge
* Ubuntu 12.04 or higher, 32 bit or 64 bit (13.10 if you want use Kdevelop + linux kernel plugin)
* Internet connection, possibly fast and unlimited
* the boot.img of the ROM you want to support with your kernel (AOSP, SENSE etc etc...)
* [URL="http://forum.xda-developers.com/showthread.php?t=2519416"]zImage switcher[/URL]
NOTE:
Some toolchains dont work on 32 bit. Using 64 bit is recommended.
Install required package:
Linux 12.04;
Code:
sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2 bin86 libqt3-headers libqt3-mt-dev wget libncurses5 git-core nautilus-open-terminal
linux 13.10(and above):
Code:
sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2 bin86 qt4-dev-tools wget libncurses5 git-core nautilus-open-terminal
and restart your PC.
Download Source:
Go to /home/, create a new folder called "kernel", and enter in that folder.
right click somewhere in "kernel" folder and select "open terminal here" (CooL AH?)
and run
Code:
git clone https://github.com/pawitp/android_kernel_samsung_i9082.git -b cm-11.0
Download the toolchain
There are a lot of toolchain, stock, linaro optimized, based on gcc 4.7, based on gcc 4.8 the choice is yours! in this tutorial we use google gcc 4.8 toolchain.
NOTE:
this toolchain below will not work with 32 bit. Use the arm-eabi-4.4.3, from the ndk toolchains, and if you need any help on its path, or anything, reply in this thread.
Go to /home/, create a new folder called "toolchains", and enter in that folder.
right click -> open terminal here
Code:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
Build the kernel​
Build the kernel:
in this part we will work in "/home//kernel/android_kernel_samsung_i9082" folder, i'll call it
go to "/arch/arm/configs" and copy "cyanogenmod_i9082_defconfig" to
rename cyanogenmod_i9082_defconfig to ".config"
open a terminal window in
type:
Code:
make ARCH=arm CROSS_COMPILE=/home/toolchains/arm-eabi-4.8/bin/arm-eabi- > compileLog
and the compilation will start.
Some explanation:
"ARCH=arm" tells to compiler what arch the kernel is made for
"CROSS_COMPILE=xxxxxx" tells to "make" the compiler to use
"> compileLog" saves all the messages in a file called compileLog, it's easier to read than terminal window
Click to expand...
Click to collapse
Pack the kernel to boot.img:
Unpack zImage switcher somewhere, i'll call that folder .(for 32 bit, download both 64 bit and 32 bit and copy the files "mkbootfs" "mkbootimg" from tools folder of 32 bit one and replace these files with the files in tools folder of 64 bit one)
copy the stock boot.img and your zImage in the folder , you can find it in /arch/arm/boot.
run the script
Code:
./repack.sh
now in there's a new file called newBoot.img, that's your kernel!
to find the modules (*.ko files) open a teminal windows to and type
Code:
find ./ -name "*.ko" -exec cp {} <absolute/path/destination/folder> \;
now you have the boot.img and the modules, download a custom kernel and use the flashable zip to make your flashable zip, just replace the modules and the boot.img!
Add features​Add features to kernel:
"Woah! i'd like to add smartass v2 governor and sio i/o scheduler to my kernel"
First you need to find a git repository that contains smartass v2 governor and sio i/o scheduler, then the commit that added the governor and sio i/o scheduler.
for example https://github.com/akiratoriyama/an...mmit/6a43329a08ec0282e951049ae15a497b121aa8ef
Open a terminal window in
type:
Code:
git remote add akiratoriyama https://github.com/akiratoriyama/android_kernel_samsung_i9082.git -b experimental
git fetch akiratoriyama
git cherry-pick 6a43329a08ec0282e951049ae15a497b121aa8ef
NOTE:
I have used akiratoriyama's github as reference. If you want to add any other features,like f2fs or frandom module, you can ask the dev to help you or you can simply cherry-pick the code. Remember to thank everyone you borrowed the code from and mention them in your thread, whenever you release your kernel.
in termial window type:
Code:
make ARCH=arm xconfig
will open a new window where you can configure your kernel's features
press ctrl+f (find) and serach for "smartass2" and "sio" and tick the checkbox. save clicking the floppy disk in upper left corner.
the modified configuration file will be saved in ".config"
now we can build the kernel again, but first type
Code:
make ARCH=arm clean CROSS_COMPILE=/home/toolchains/prebuilts_gcc_linux-x86_arm_arm-linux-androideabi-4.8/bin/arm-linux-androideabi-
this will remove all the compiled files of previous build.
View git commits history​you can easly view all the commits in your repo:
open a terminal window in and type
Code:
gitk
will open a GUI where you can see all the commits, what files were modified for each commit, the author of the commit.
you can also revert commits.
There are other GUI for git, i also like "gitg"
Hacking the kernel
suggested by @pirlano​for easy work on kernel sources, add features & co. you can use kdevelop + linux kernel plugin, here is a guide
http://www.gnurou.org/code/kdevelop-kernel
and a video guide:
http://video.linux.com/videos/kernel-browsing-and-hacking-using-kdevelop
NOTE: for linux kernel plugin ubuntu 13.10 is required
CREDITS:
@rmbq, this is his guide. I just modified and compiled it especially for our device. Thanks,rmbq.

this guide only applies to kk based kernels. if you want to build a stock kernel,just download sources of 4.2 and start building!!!
If you have any doubts or questions,dont hesitate to reply in this thread.

Thanks for using my github as reference but I'd like to recommend my last 2 commits for adding smartassH3 to be included in this guide as they were clean and more proper IMO. This+k2wl's guide will help newbies to compile a kernel.

akiratoriyama said:
Thanks for using my github as reference but I'd like to recommend my last 2 commits for adding smartassH3 to be included in this guide as they were clean and more proper IMO. This+k2wl's guide will help newbies to compile a kernel.
Click to expand...
Click to collapse
But I just used those commits as reference. If users think that these commits are not proper, they can revert them and use your smartassh3 commit.
Sent from my GT-I9082 using Tapatalk Pro.

Related

[EXPERIMENTAL/TOOLS/GUIDE/ADV.] Toolchain gcc 4.6.3 Cygwin/Linux/OSX; kernel builds

The following contains binaries, and instructions for use of an experimental newer toolchain than those included in the android pre-built package.
This is provided to allow existing linux kernel developers experiment with the updated version of GCC (besides the complicated building instructions the code just has a small patch for a known issue with android and 4.6.* otherwise is directly from GNU (see build information below)
The packages I'm also providing to help developers current on windows (With cygwin but no other virtual environment) to start exploring android Linux kernel development for their devices. (In addition to a OSX toolchain for more advanced mac users)
due to the slight differences between kernels on different devices this How To is intended to be used for advanced users who can adjust for the differences required for the devices specific kernel.
I may add additional guides to this thread if I find a need for them.
[size=+1]Binary Toolchains[/size]
I have two versions of a GCC-4.6.3 toolchain
1) For x86 linux: toolchain-4.6.3.tar.bz2 (Sha1: c8c57aba6ad92e9acddf29ba8620ba880be09a81)
2) For Cygwin (windows): toolchain-4.6.3.cygwin.tar.bz2 (Sha1: 6947e1c1ba95195019f542eb8ba0708667b63eca)
3) For OSX (mac/darwin): toolchain-4.6.3.darwin.tar.bz2 (Sha1: 9a977f0672863fdd9501383a6ad1e30723281f68)
[size=-1]> The linux version was built via this script: http://pastebin.com/b2dZ8YtG (or in the included toolchain_notes.txt)
> The cygwin/darwin version uses the same source however has a slightly modified script (see the included toolchain_notes.txt for the updated script)[/size]
[size=+1]System Requirements[/size]
Note I have a 64bit debian linux box, and a 64bit version of WIndows7 Pro running cygwin, while I believe these binaries ought to be compatible with all x86 linux and cygwin installs these have not been tested by a wide number of people yet.
> Linux users: If you have a working android build environment likely no additional requirements are needed. In addition you must build any kernel/android utilities from a case sensitive filesystem or disk image.
> OSx users: the cygwin packages will give you an idea of what is required, please also see the README in the tar.bz2 about manually installing elf.h
> Cygwin users: as its unlikely you have compiled a kernel with cygwin up to this point you may wish to ensure the following packages are installed (as well as any cygwin recommends to be used with them):
vim
vim-common
make
cmake
lzop
gcc
gcc-core
gcc-g++
wget
git
git-compleation
libncurses-devel
python​
Cygwin users must also set their NTFS file partition to allow case sensitive files:
To do this open regedit and change:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\obcaseinsensitive
to 0
after this reboot and the NTFS kernel will allow cygwin to use case sensitive files (ie 'AbC' and 'aBc' as two different files)​
[size=+1]Advanced Kernel Building Guide[/size]
Since may devices are slightly different this can only be a high level kernel building guide
Please ask for any specific directions from the current kernel maintainer.
To most people who have built kernels before this will look familiar, the most important part is preparing your local environment to use the new toolchain,
1) If you have not already download the tar.bz2 above, (pick the one for the computer you are preparing to build kernels on)
2) extract the file (for the sake of this guide I will assume it is extracted into a ~/android directory)
ie on cygwin you might:
mkdir -p ~/android
cd ~/android
tar -xjvf toolchain-4.6.3.cygwin.tar.bz2
Note: steps one and two are just properly installing the toolchain, you will not need
to repeat them to build a different kernel.
2.b) OSX Only: check elf.h
open ~/android/toolchain-4.6.3/README in a text editor and check if elf.h is installed, otherwise manually install it as per the readme
3) fetch your kernel source into the ~/android directory and change into the
source codes root directory
(this can be via a git repo or tarball)
example if you wanted my ACER a100/a500 source you might run:
git clone git://github.com/ezterry/AcerTabKernel.git
cd AcerTabKernel
change this to match the source you are fetching
4) In the root directory of the kernel source (~/android/AcerTabKernel in the about a100/a500 example) update the environment for the cross compiler
add the toolchain to your path:
export PATH=$HOME/android/toolchain-4.6.3/bin:$PATH​
set the cross compile:
export ARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
export KERNEL_DIR=`pwd`​
(this will need to be done once for each terminal you use to run any of the following make commands)
5) Grab your configuration
From the device:
adb pull /proc/config.gz
gzip -dc config.gz > .config
or from a prepared configuration if it's included in your code base by running
make _defconfig
example for the a100/a500 code base is 'make vangogh_defconfig' for the a100 and 'make picasso_defconfig' for the a500
6) Customize configuration
just run menuconfig and use the UI to update settings
make menuconfig​
7) building the kernel (zImage)
This is normal at this point with 'make -j'
so for a quad core CPU you can run
make -j5​
(note: the wrong number in the -j argument will not harm the build but may slow down the building process by either using too few threads or needing to keep track of too many)
8) If it worked you will now have the kernel in arch/arm/boot/zImage
this can be injected into the boot.img (as the kernel, using an existing ramdisk) as is
If it failed for your kernel your kernel source may need one of the common patches
9) Building modules
the following will prepare the modules in subdirectory mod:
make modules
rm -rf mod
mkdir mod
cp `find ./ | grep .ko$` modules.order mod/​
After these commands [if no errors] you can simply copy the contents of mod/ to /system/lib/modules on your device, note it is recommended usually to remove the existing contents of /system/lib/modules unless there is a closed source module required from the previous build despite the new kernel.
[size=+1]Common Patches Required[/size]
If your kernel has not been built for the new toolchain or on cygwin before you may require some of these common patchs: (I've thus far only tested this on my Acer A100/A500 source)
wireless/bcm4329 for GCC-4.6.3:
https://github.com/ezterry/AcerTabKernel/commit/123f32e27e2c74f1c1789ae5d6d5a1c04e1e264c
linux kernel module patch for cygwin (broken elf.h):
https://github.com/ezterry/AcerTabKernel/commit/220db49593cf6b9f3b556e2f4b75b2f6d3ff556c
Error compiling security/smc/bridge_pub2sec.S (I required the cygwin elf patch and this patch to build the Franco galaxy nexus kernel)
0001-Fix-build-error-with-4.6.3-toolchain-smc-0.patch
(use 'git am 0001-Fix-build-error-with-4.6.3-toolchain-smc-0.patch' to apply)
OSX stat patches (fixes errors between GNU and BSD stat):
https://github.com/ezterry/AcerTabKernel/commit/0c49df3cc1a05a0ccd98201511cdc0534aaeb35a
Errors loading newly built modules (modules appear to build cleanly but wont install):
simply add -fno-pic to CFLAGS_MODULE
https://github.com/ezterry/AcerTabKernel/commit/c5ed0fcb014d36936a86ad253f15af43de2f644a
(I can add others here if highlighted to me, and as I find them)
[size=+1]Other Toolchain uses[/size]
The linux toolchain can be used to build android components, however this requires various manipulation to the android /build git repository as currently various other toolchains have hard coded paths into the prebuilt repo. If you intend to incorporate this into your build it may be best to inject the toolchain into your prebuilt repo rather than expect your users to download the links above, ensure to keep the compile notes as it explains how to get the source code to the toolchains)
On cygwin/osx it may also be possible to build android applications however I've not yet tested this as the scripts to make a proper build are complex when attempted outside the android build tree.
Excellent!!! thanks Man!!! Has been looking for one of these
Added in the OSX version of the toolchain (and some related patches)
Also if you are having problems with your modules built with this toolchain a CFLAG fixes it. (see note in common patches)
FINALLY!!! Great Instructions followed them to the T and BAM got my kernel compiled!!!
wow your toolchain is so small, many thanks, just compiled a kernel for my LG P500 gonna test it, thanks again
Bookmarked for testing when I wake up...
I can almost put: "Building under Windows is not currently supported." (quote from google), unofficially at least, out of my mind...
I have been spoiled by Windows for far too long I fear, my attempt for this last week at getting Linux setup and building CM9 has been nothing but a complete FAILURE, too many single line entrys for different distributions/package combo's, commands I dont know and cant find because of wildcard portions of them and lack of understanding, and not enough scripts like the wonderful Compile CM9 script someone put up (cant run it because all the pre-req's arent setup).
Good god Ill be jumping for joy if this works tomorrow on WinBlows!
EDIT: never mind, problem solved, what I need to know now won't be solved here
I wish i knew how to go about doing this..
Thanks
Thanks For ........... i Really need It .........
Hammerfest said:
Bookmarked for testing when I wake up...
I can almost put: "Building under Windows is not currently supported." (quote from google), unofficially at least, out of my mind...
I have been spoiled by Windows for far too long I fear, my attempt for this last week at getting Linux setup and building CM9 has been nothing but a complete FAILURE, too many single line entrys for different distributions/package combo's, commands I dont know and cant find because of wildcard portions of them and lack of understanding, and not enough scripts like the wonderful Compile CM9 script someone put up (cant run it because all the pre-req's arent setup).
Good god Ill be jumping for joy if this works tomorrow on WinBlows!
Click to expand...
Click to collapse
If you succeed tell me how to do it in a more familiar way
I get errors regading the processor not being supported?
brfield said:
I get errors regading the processor not being supported?
Click to expand...
Click to collapse
Sorry I can't support devs that have not learned cut copy and paste.
You probably forgot to export some of the environment variables or are just trying to run a arm binary on your PC and or a x86 binary on your arm device.
But why am I guessing? Why don't we know what you tried to run and what the actual text of the error was.. what type of kernel you tried to build, what you are running?
These packages are for developers if you feel like using them its time to learn to how to trouble shoot a problem and write a ticket to explain said problem clearly to others with at least some information to give us a chance to understand.
Sent from my Galaxy Nexus using Tapatalk 2
Great guide. Have the bcm4329 wireless module, so followed the tips and everything compiled and works!
Thanks!
one question,how to compiled android kernel with -O3 optimization?
jxxhwy said:
one question,how to compiled android kernel with -O3 optimization?
Click to expand...
Click to collapse
Um, in general its recommended you don't:
-O3 is not recommended for the kernel as many low level parts require the assembly code generated to remain as is and not be optimized as will be by some of the options -O3 enables thus likely reducing the stability of your kernel.
---
That said the menuconfig has an option to optimize for size (-Os) if enabled else -O2
For other optimization (including tuning for your cpu) you can add them to the CFLAGS_KERNEL/CFLAGS_MODULE in the make file.)
For -O3 like functionality you could add the increment to the line:
-finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload, -ftreel-vectorize, -ftree-partial-pre and -fipa-cp-clone
-Ofast is -O3 with -ffast-math as well
If you do build with all the -O3 or-Ofast options ensure you test the kernel for stability and run some benchmarks. (as it may not actually be faster depending on the cache misses)
The first option I'd start pruning was the one mentioned in my reference below -fgcse-after-reload.
If you really insist on -O3 rather than just adding the optimization you want that are not in O2,it can be added also in the Makefile where the configure flag is checked and its added to KBUILD_CFLAGS
Obviously all and any of this is at your own risk, anything that breaks you have to find a way to fix it.
Reference:
Gcc optimize options:
http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Talk of O3 and the kernel (not android specific)
http://unix.stackexchange.com/questions/1597/compiling-gnu-linux-with-o3-optimization
ezterry,thank you very much!
I want to build cm9 kernel using toolchain 4.6.3.
How to replace the default GCC 4.4.3 to 4.6.3 version?
BTW,I use the way -- make bootimage
jxxhwy said:
ezterry,thank you very much!
I want to build cm9 kernel using toolchain 4.6.3.
How to replace the default GCC 4.4.3 to 4.6.3 version?
BTW,I use the way -- make bootimage
Click to expand...
Click to collapse
If you are asking in a cm9 build tree.. its a pain, best is to update the cm kernel makefile to point the build chain temporarily.
If you mean just to compile by hand as described in the op
Once the kernel is compiled find an anykernel update.zip or manually use mkbootimg or fastboot to merge it with the ram disk. Cm9 targets mkbootimg and unpackbootimg (if I'm not mistaken) will build the applications to unpack your current (or the default cm9) boot image and re-create them with your custom kernel built from hand.
Now,I runing script file:
#Let's make sure the environment is clean and ready to compile the kernel
echo "Cleaning house!!"
make mrproper
echo "House cleaned, lets build a kernel!!!"
#
# Lets set the kernel defconfig
echo "defconfig = cyanogenmod_iprj_defconfig"
make ARCH=arm cyanogenmod_iprj_defconfig
#
# Let's build a kernel
echo "Now compiling kernel, go get a soda! "
ARCH=arm CROSS_COMPILE=~/Android/sourcecm9/cm9/toolchain-4.6.3/bin/arm-linux-androideabi- make zImage -j4
#
if [ -f arch/arm/boot/zImage ]; then
echo "Plague has been compiled!!! You can find it in arch/arm/boot/zImage"
else
echo "Kernel did not compile, please check for errors!!"
fi
but,I got some error output:
/home/xxx/cm9/toolchain-4.6.3/bin/arm-linux-androideabi-ld: cannot find usr/initramfs_data.o: No such file or directory
thanks again!!!
I think that means there is an issue with your config..
Most android kernels require initramfs, but don't specify a file, as its provided by the bootloader.. However in your case it is trying to embed it into the kernel.
Sent from my A500 using Tapatalk 2
ezterry said:
I think that means there is an issue with your config..
Most android kernels require initramfs, but don't specify a file, as its provided by the bootloader.. However in your case it is trying to embed it into the kernel.
Sent from my A500 using Tapatalk 2
Click to expand...
Click to collapse
issue has been resolved by myslef.Thanks for your time.

[Step by Step] Build ICS/JB Kernel

I have created a new thread with a script to build the kernel. Full credit for the script goes to the amazing mapkel. Without him there would be no script.
[Script] Build ICS/JB Kernel
This thread will remain as a Step by Step guide. Either method works fine but the script method is much simpler.
This is an informative guide and I decline responsibility for any damage to your device.
Do not attempt to build this kernel if you are going to complain to devs about issues.
That being said, I designed this so that even those with little knowledge can follow the exact commands and will run into no issues. If you have issues building, post here and I will try to assist you.
The following is a complete tutorial to building the kernel.
Credits:
Kernel Devs: krystianp, lehjr, Epinter, and mmontuori for making this kernel; without them there is no kernel.
Big thanks to benouch for the idea and basic outline of this tutorial.
Another big thanks to zen25205 for help with building the kernel and getting the Linaro Toolchain.
A final big thanks to mchinand for suggesting using "${HOME}" (no need to change for username anymore)
Kernel Kitchen
Thanks to:
quetzalcoatl2435
nlabrad
You need to install Ubuntu 12.04 64bit (Google for instructions)
1. Download linaro.zip (toolchain) from here: http://www.mediafire.com/?ok2paef7uhx2ji8
2. Download kitchen.zip from here: https://mega.co.nz/#!Uc4D0YiD!bs-f4FLWQTu7Q8FQziY0o3GWRPJWGBl-6-Hhm6nta-k
3. Download kernel-working.zip from here: http://www.mediafire.com/?wtavk4yb24x3lj1
4. Download misc.zip from here: http://www.mediafire.com/?q693gipql6a6ty8
If there are any issues with this guide, or if you have any issues building the kernel, post here and I will assist you as best I can.
The following is for Arch Linux Only. Ignore if you are using Ubuntu
Code:
pacman -Syu
pacman -S base-devel
pacman -S git
pacman -S bzip2
pacman -S unzip
Ubuntu Users Start Here
If you get an error on apt-get (something about package not found), enable all software sources in Ubuntu Software Center.
Stage 1 (first time only). Go to Stage 2 if you have already built the kernel.
Open a terminal and run the following commands:
Code:
sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2
Code:
sudo apt-get install git
Create a folder named “olympus” in your home directory:
Code:
mkdir ${HOME}/olympus/
Extract the downloaded .zip files to the “olympus” folder (you can use the file manager or the following commands):
Code:
unzip ${HOME}/Downloads/linaro.zip -d ${HOME}/olympus/
unzip ${HOME}/Downloads/kitchen.zip -d ${HOME}/olympus/
unzip ${HOME}/Downloads/kernel-working.zip -d ${HOME}/olympus/
unzip ${HOME}/Downloads/misc.zip -d ${HOME}/olympus/
There should now be 4 folders in ${HOME}/olympus/: “linaro”, “kitchen”, “kernel-working” and “misc”.
In a terminal:
Code:
cd ${HOME}/olympus/
Code:
git clone git://github.com/CyanogenMod-Atrix/android_kernel_motorola_olympus.git
Stage 2 (start here if you are building again).
Code:
cd ${HOME}/olympus/android_kernel_motorola_olympus/
Get the latest updates from git:
Code:
git remote update
Now run the following commands to build the kernel:
Code:
export CROSS_COMPILE=${HOME}/olympus/linaro/bin/arm-unknown-linux-gnueabi-
Code:
make clean && make mrproper
Code:
make -j2 ARCH=arm tegra_olympus_defconfig
Code:
make -j2 ARCH=arm
Now start packing the new kernel and modules:
Code:
cp ${HOME}/olympus/android_kernel_motorola_olympus/arch/arm/boot/zImage ${HOME}/olympus/kitchen/kernel-tools/input/
Code:
cp ${HOME}/olympus/misc/CM9/boot.img ${HOME}/olympus/kitchen/kernel-tools/input/
(Replace CM9 with CM10 for CM10)
Code:
cd ${HOME}/olympus/kitchen/kernel-tools/
Code:
./menu
Press Enter Key
Select Option 1
Press Enter Key (again)
Select Option 1 (again)
Type “olympus” and press Enter Key
Press "Ctrl+C"
Code:
cp ${HOME}/olympus/kitchen/kernel-tools/output/bootimg-contents/initrd.img ${HOME}/olympus/kitchen/kernel-tools/input/
Code:
cd ${HOME}/olympus/kitchen/kernel-tools/
Code:
./menu
Press Enter Key
Select Option 1
Press Enter Key (again)
Select Option 3
Type “olympus” and press Enter Key
Press "Ctrl+C"
Run the following commands:
Code:
cp ${HOME}/olympus/kitchen/kernel-tools/output/boot.img ${HOME}/olympus/kernel-working/
Code:
find ${HOME}/olympus/android_kernel_motorola_olympus/drivers/ -name *.ko -exec cp -f {} ${HOME}/olympus/kernel-working/system/lib/modules/ \;
Code:
cd ${HOME}/olympus/kernel-working/
Code:
zip -r new_kernel.zip *
The “new_kernel.zip” file will be located at ${HOME}/olympus/kernel-working/new_kernel.zip
This is a flashable zip that you can flash on top of MROM CM9 and the ROMs that the devs will be releasing.
You will have the latest kernel changes by building it yourself.
Thanks for the tutorial. Just a quick question, why did you include the kernel modules in the kernel-working.zip; aren't they going to be overwritten with the newly compiled ones?
I can do it in debian?
mchinand said:
Thanks for the tutorial. Just a quick question, why did you include the kernel modules in the kernel-working.zip; aren't they going to be overwritten with the newly compiled ones?
Click to expand...
Click to collapse
They were useless. I have reuploaded. New link in OP.
Ufoex said:
I can do it in debian?
Click to expand...
Click to collapse
I have not tested. You can try and report back. If it works I will update the thread.
Usually devs stick to Ubuntu for Android development.
Seeing as Ubuntu is based off Debian, it should work.
atrix4g18 said:
They were useless. I have reuploaded. New link in OP.
Click to expand...
Click to collapse
I think it is better to only include what is necessary in the zips. Not for space/bandwidth reasons (they were small as you said), but more for understanding the process and knowing what's essential to build a flashable kernel.
mchinand said:
I think it is better to only include what is necessary in the zips. Not for space/bandwidth reasons (they were small as you said), but more for understanding the process and knowing what's essential to build a flashable kernel.
Click to expand...
Click to collapse
100 Percent agree. I appreciate the suggestion. As I said the new kernel-working.zip is updated without those files. Check OP.
Thanks
You forgot "sudo apt-get install git".
Oh, and if you get an error on apt-get (something about package not found), enable all software sources in Ubuntu Software Center.
quetzalcoatl2435 said:
You forgot "sudo apt-get install git".
Oh, and if you get an error on apt-get (something about package not found), enable all software sources in Ubuntu Software Center.
Click to expand...
Click to collapse
Second Post Updated. Thanks. (I don't think anyone will have the apt-get error, but if they do I will let them know).
I got that error on apt-get, which is why I mentioned it.
It was weird, I had to enable local (CD) sources to make apt-get work. It had to read the source list from the CD first before downloading the packages.
It might be a wonky install, though. I just put it here in case anyone faces the same problem.
what?
Does the kernel already includes Linaro?
omg Kristian said he'll look at it, so did he? :crying: Happy:crying:
crazymania56 said:
what?
Does the kernel already includes Linaro?
omg Kristian said he'll look at it, so did he? :crying: Happy:crying:
Click to expand...
Click to collapse
No this is only the Linaro Toolchain used to build the kernel.
Other tutorials would have you download the Android NDK for the toolchains within.. This tutorial uses the Linaro Toolchain instead.
quetzalcoatl2435 said:
I got that error on apt-get, which is why I mentioned it.
Click to expand...
Click to collapse
Added to second post. Thanks. Also made a list of credits in the OP and you are in it.
Hi, i'm trying this in Arch, i looked for the equivalent packages that are needed in ubuntu and seems that Arch has some of them in the arch-devel group of packages and the *-dev packages are included in the non-dev (arch doesn't splits the packages in dev and nondev).
So, i started unziping, and when i'm unzipping the linaro.zip, some files are overwritten, (it asks if i want to overwrite them or not), i chose yes to overwrite.
I'm compiling, so far no problems, i'll update after i finish.
nlabrad said:
Hi, i'm trying this in Arch, i looked for the equivalent packages that are needed in ubuntu and seems that Arch has some of them in the arch-devel group of packages and the *-dev packages are included in the non-dev (arch doesn't splits the packages in dev and nondev).
So, i started unziping, and when i'm unzipping the linaro.zip, some files are overwritten, (it asks if i want to overwrite them or not), i chose yes to overwrite.
I'm compiling, so far no problems, i'll update after i finish.
Click to expand...
Click to collapse
Good to know.
If it works get into the specifics and I can edit the guide or make a second one for Arch. With full credit to you of course.
Im writing this as it compiles
-No errors in make clean && make mproper
-No errors in make mrom_deconfig
The errors must be in the make.
There are a few warnings, unused functions, unused variables, uninitialized variables, i see a few modules being built, but the extension is ".o" not ".ko", for example dhd_something.o
"arch/arm/boot/compressed/head.S: Assembler messages:
arch/arm/boot/compressed/head.S:[num]: Warning: (null) (it appears a like 30 times.
Then i see, for example
"LD [M] drivers/char/hw_random/rng-core.ko" so i guess it was compiled.
Ok nevermind, the find command DOES FIND the files, but i thought that it didn´t because im used to run cp with -v, and i saw no output and i got confused.
ITS OK THEN.
Something else, after running the kitchen, its faster to press CTRL-C instead of closing/opening the terminal.
Plus you have the log of what you've been doing so far.
No current issue, the modules were compiled, i got confused.
I have the kernel zip ready to be tested.
CTRL-C will work in any bash terminal, which is the one that Ubuntu uses.
Instead of closing the terminal, it just ends the current running process (in this case, the kitchen script will end, and you get the prompt ready again).
My english is weak so if you need to change some grammar of this next few lines, feel free to do so:
So far, to compile it in Arch you need to run: (or check if you already have the packages)
pacman -Syu
pacman -S base-devel
pacman -S git
pacman -S bzip2
pacman -S unzip
Then follow the tutorial normally.
Is MROM CM9 = MROM ICS?
nlabrad said:
No current issue, the modules were compiled, i got confused.
I have the kernel zip ready to be tested.
CTRL-C will work in any bash terminal, which is the one that Ubuntu uses.
Instead of closing the terminal, it just ends the current running process (in this case, the kitchen script will end, and you get the prompt ready again).
My english is weak so if you need to change some grammar of this next few lines, feel free to do so:
So far, to compile it in Arch you need to run: (or check if you already have the packages)
pacman -Syu
pacman -S base-devel
pacman -S git
pacman -S bzip2
pacman -S unzip
Then follow the tutorial normally.
Is MROM CM9 = MROM ICS?
Click to expand...
Click to collapse
Updated Second Post. Take a look.

Help compiling Nexus 4 kernel from sources

Hi, I'm trying to compile the Nexus 4 kernel from the sources following the android.developers tutorial:
http://source.android.com/source/building-kernels.html
And also this guides:
[Tutorial] Building Your First Kernel: http://forum.xda-developers.com/showthread.php?t=1748297
Getting Started: Building a Kernel from source: http://xda-university.com/as-a-developer/getting-started-building-a-kernel-from-source
My goal is to learn to compile from AOSP, but I'm failing hard. After doing this step:
Code:
$ git clone https://android.googlesource.com/device/lge/mako-kernel
And after downloading the sources:
Code:
$ git clone https://android.googlesource.com/kernel/msm.git
All I get is a "kernel" file (without extension) and a folder .git folder. Inside that folder there aren't the files I assume I need, because I can't do "make mako_defconfig" as there isn't such file.
I don't know what I'm doing wrong as I'm not getting the files I need, althought download was nearly 1GB (I think they should be like this android tree):
https://android.googlesource.com/kernel/msm.git/+/android-msm-mako-3.4-jb-mr1.1
I'll appreciate your help, and sorry if this is the wrong section. Thanks in advance.
PS: I forgot, I already have the toolchain 4.6 and know how to call it, I tried it after clonning the trinity kernel git, I just wonder why I don't get similar files when clonning mako kernel from google source.
I solved it. I had to add the desired branch to the end of the command:
$ git clone https://android.googlesource.com/kernel/msm.git -b "brand"
Doubt is solved, thread can be closed.

[GUIDE]A Noob Guide On Building Your Own Custom Kernel on WIN10 (ARM & ARM64 & MTK)

[GUIDE]A Noob Guide On Building Your Own Custom Kernel on WIN10 (ARM & ARM64 & MTK)
1. INTRODUCTION:​
This is a guide to build your own custom kernel. Although I'm still a "noob" at this,
I've struggled a lot to build one as all the guides which I followed were not very clear.
So I hope this will be clear enough and as noob friendly as possible!​
You will learn how to:
- Build a kernel for arm and mediatek devices on windows 10
- Add feature
- Basic use of git
Prerequise :
- Updated windows 10 64bits (falls creators update)
- A decent computer with a decent internet speed
- Space on your HDD The minimum space for a kernel source (and its compiled code) is about 2 GB
- Minimal linux knowledge (Terminal, Commands etc)
- Your Brain
- And finally patience
2.Setting UP ENVIRONMENT:​
Installing ubuntu :
1 - Go in Settings -> Update and Security -> For developers and turn on developers mode then
2 - go in Control Panel > Programs > Turn Windows Features On Or Off and enable Windows subsystem for linux
3 - Reboot your computer
4 - launch linux subsystem now and let it download all it need and set up your password (remember it ! you'll need this password later)
5 - Go in microsoft app store and download Ubunutu by canonical group limited
6 - Open ubuntu (a windows with your name and computer name wil appear), congrats you installed ubuntu on windows 10 !
Seting up you environment :
1 - Type "apt-get update" (will update all repo for apps and dependencies)
From here it is nearly the same as my previous guide, but be careful there is some little changes
2 - Type "sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2" (will install all dependencies to build kernel)
3 - Check if dependencies are correctly installed :
- Then type "gcc"
If "gcc" is already installed, you should see "gcc : fatal error : no input file"
- Then type "make"
If "make" is already installed, you should see "make: *** no target specified and no makefile found. stop."
- Then type "git"
If "git" is already installed, you should see bunch of basic git commands
Now you're almost ready to start building your kernel!
Toolchains:
There are several types of toolchains (GCC, Linaro and few custom made ones)
Warning : Not every single device kernel will boot (or even compiles) with older or newer GCC
- For ARM:
We'll be using GCC 4.7 in this tutorial (link : https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/ )
-Open terminal and type: "mkdir kernel"(Type the name you want, I used "kernel")
-Then type "cd kernel" (the name which you used above)
-Then type "git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7"
-Wait till it finishes.
- For ARM 64:
For ARM 64 you need a 64 bit kernel compiler (there's "aarch64" in the name for telling that's a 64 bit compiler)
Exemple : https://releases.linaro.org/archive/13.07/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux.tar.xz
3.DOWNLOADING SOURCE FILES FOR YOUR DEVICE:​
Now you have to find a github that contains your kernel source.
Search on Google or XDA to find a kernel github repo for your device.
A kernel github looks like this: "https://github.com/atxoxx/android_kernel_samsung_msm8974/tree/xenomTW"
On the upper left side you can see branch: completed by a name
These are the different versions of the kernel/project (generally can be for testing, android version etc)
QUICK EXPLANATION OF FILES/FOLDERS:
- /arch/arm/configs : contains the config files for device (where you add option like new governors, features etc)
- /output/arch/arm/boot/ : Where zimage is stored (will explain that later)
- build.sh : Script to make the building much easier (will explain how it works later)
- /arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2 : I put the toolchain in my kernel source making it easier to find (your kernel's toolchain name may be different)
If you don't have your kernel source yet, you need to download it.
Open terminal and make sure that you are in "kernel" folder (the one you previously created)
Then type in terminal : "git clone "URL of the github kernel" -b "name of the branch" "
For Example : "git clone https://github.com/atxoxx/android_kernel_samsung_msm8974 -b xenomTW"
Good! Now you have your kernel source!
4.BUILDING:​
For an easier way you can go to the location using your file explorer to : "/home/"name of your session"/kernel"
You'll see two folders (The Toolchain and The Kernel Source)
Go into your kernel source folder.
- For ARM:
Copy paste this:
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=$(pwd)/arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2/bin/arm-cortex-linux-gnueabi-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For ARM 64:
Copy paste this:
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm64: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE=$(pwd)gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux\bin\aarch64-linux-gnu-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For Mediatek:
Copy paste this:
#!/bin/bash
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
export ARCH=arm ARCH_MTK_PLATFORM=
make "name of defconfig and variant if needed"
make -j4
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- export ARCH=arm ARCH_MTK_PLATFORM=: Defining which kernel architecture type it is (For example arm64 etc) "ARCH_MTK_PLATFORM=" is for specifying which mediatek platform it is
- make _defconfig : Defining which defconfig to use (will explain later)
- make -j4: where the building starts, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
Click to expand...
Click to collapse
Example :
#!/bin/bash
export CROSS_COMPILE=$(pwd)/arm-eabi-4.8/bin/arm-eabi-
export ARCH=arm ARCH_MTK_PLATFORM=mt6580
make pixi4_4_8g1g_defconfig
make -j4
Click to expand...
Click to collapse
When these step are done make sure you are in kernel folder in terminal and type "sudo bash build.sh" then type your password you set up in first launch of linux subsytem
(sudo is important, windows 10 ubuntu seems to handle permission differently than native ubuntu)
The compilation have started
If it compiles without any problems:
Wait till it finishes (it'll say something like "zimage is ready")
If you followed arm and arm64:
Then go to "/Output/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
If you followed mediatek:
Then go to "/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
Caution : Not all kernel build Zimage, it can build image or other compressed image
If in case you have any errors:
Check and see what it says, generally it'll tell you where the error is.
If the text is going too fast reduce the -j number as explained above.
For reference I compile with an AMD Phenom X4 3.4GHz,Samsung HDD and 8GB of RAM and it takes around 10min to build
It is recommanded to type in the terminal "make clean" and "make mrproper" before compiling again​
5.MAKING THE KERNEL BOOT:​
You have 2 solutions here:
1) You can use @osm0sis anykernel method, which is explainded here: "https://forum.xda-developers.com/showthread.php?t=2670512" (A huge shoutout to him!)
OR
2) You can unpack the boot.img (from the same rom (CM, touchwizz,sense etc) and android version) and swap Zimage in it explained here : "https://forum.xda-developers.com/showthread.php?t=2073775" (thanks again to @osm0sis !)
Before flashing the kernel which you've made, backup your "stock" boot.img and Then flash your kernel and see if it boots!
6.HOW TO ADD FEATURE TO KERNEL WORK:​
Here starts the most interesting part! Now let's see how it works:
Basically you can add: Governors, IO Schedulers, Overclock the CPU & Many Tweaks...
Checkout the github section (Section 7) to see how to add them properly.
Here's an exemple for adding a governor (this one is called Intellimm) : https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
The text in the blue box is the commit description (generally tells you about the changelog, general information and who originally made the commit)
The other text boxes tell you about where and which files have been modified/changed.
Everything in green indicates what has been added.
Everything in red indicates what has been deleted.
We can see in the first 2 text boxes that in "arch/arm/configs/" "msm8974_sec_defconfig" and "cm_msm8974_sec_defconfig" have been modified.
Between the lines 140 and 141 of this files this text has been added : "CONFIG_CPU_FREQ_GOV_INTELLIMM=y"
(This line is for enabling Intellimm when you're compiling your kernel)
Same technique applies to the other text boxes (what has been added and deleted and it's location)
Depending on the features you add, more or less files can be modified, added or deleted.
So to sum it up, a Commit let's you see all the changes which have been made and everything else!
7.GUIDE TO GITHUB:​
For this, I'll direct you over to this awsome guide made by @eagleeyetom !
8.GPL (IMPORTANT !!!):​
The Rules as they apply on XDA
As XDA has no legal power to uphold the GPL (and frankly we want to stay as far away from doing so as possible), we can’t force any of our users to abide by the GPL. However it is in XDA’s interests as well as the interests of our developer-base to ensure all GPL-derived materials hosted or linked on XDA comply fully with the GPL.
GPL-derived materials that do not come with the complete sources used to compile the GPL components are considered warez, and will be treated as such under forum rule 6 and 9.
If you use GPL components, but do not make any modifications to them whatsoever, you should provide a link to the original source of your GPL code.
Sources accompanying a release should be complete, and contain all the necessary source code for any modules, scripts or definition files. Complete sources will be defined as those which compile correctly and completely against the platform for which the software is distributed, and which contain any and all modifications made to the released General Public Licenced code. The source code supplied should be the exact version for which the source code is being requested, complete with all modifications.
EXAMPLE: Here’s a bit of code that could be used as a template to post your releases
<Kernel Or Author Name> <Kernel Nr>:
<Source>|<ReadMe>|<Credits>|<Other>
The Very Quick Summary of General Public License (GPL)
The text of the GPL Licence itself will be used to reach any final conclusion regarding any disputes over GPL Licenced materials. The above is a summary of what XDA expects of members using GPL code, and the complete text can be read at the GNU website.
The GPL states that anyone who modifies GPL licenced code is required to make available the sources used to compile it. This is to further improve and encourage collaborative work, as well as to ensure that the best code possible is produced, and to encourage peer-review of all work. This benefits both developers and end users in numerous ways, including:
Allowing anyone to verify the code they are trusting with their data, and its authenticity
Encouraging community collaboration to produce faster fixes and updates, and better code
Helping bring new developments from other devices and fields to your own, letting you benefit from new code that wouldn’t have been available without this sharing.
The GPL imparts great freedom for GPL end users. It ensures innovation is never stifled and no project is dependent upon any single developer.
It is in everyone’s interest for the GPL to be adhered to, as it gives us all better ROMs, better transparency, and a better atmosphere for developers to work together to make great code.
Click to expand...
Click to collapse
THANKS :​
- @ravish_919 : For testing and correcting this guide
- @karkasss : As my friend and support
- @gugu0das : For helping me a lot when I tried to build my kernel
- @eagleeyetom : For his awsome github guide
- @osm0sis For his aswsome anykernel solution
- @kirito9 : Huge thanks to him for providing mediatek guide !
- @F4uzan : Huge thanks to him for giving me a lot of useful information to fill this guide !
- @sunilpaulmathew : For providing an advanced method to rename your kernel ! (again)
- @nathanchance : For a proper kernel naming method
- @RendyAK and @DroidThug : For correcting me about "#!/bin/bash"
- @ahmed.ismael : For helping me, giving feedback and his huge support !
- Microsoft and canonical for the windows linux subsystem documentation
- All the developers for their hard work !
- XDA and The Community!
TIPS AND TRICKS​
1. You can use a copy of a defconfig file with different setup :
Usage : Use a "stock" one and use another one with esperimental feature for testing without altering original defconfig
Exemple : copy "stock" defconfig and in copied one add a governor see if it compile and work
How to do : Create a second build.sh with modified defconfig name !
2. Change kernel name and version :
Simple method :​Edit this line "CONFIG_LOCALVERSION="-" after - in your defconfig
Exemple : CONFIG_LOCALVERSION="-XenomTW-3.2.6"
Advanced methods :​
Method 1 :
1. Go in Makefile in the root folder of your kernel source
2. Add
CONFIG_LOCALVERSION="nameofyourkernel"
LOCALVERSION="versionofyourkernel"
Click to expand...
Click to collapse
Exemple :
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
Click to expand...
Click to collapse
Caution ! Never touch or edit VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION !
Click to expand...
Click to collapse
Method 2 :
1. Go in "scripts/mkcompile_h"
2. Add
LINUX_COMPILE_BY="nameofyourchoice"
LINUX_COMPILE_HOST="nameofyourchoice"
Exemple
Click to expand...
Click to collapse
3. Solve problem with PATH :
If you encounter "IS YOUR PATH CORRECT" problem try in terminal :
"export PATH="pathtotoolchainlocation"/bin:$PATH"
Exemple : export PATH=/home/3lambda/kernel/M8_Kernel/arm-eabi-4.7/bin:$PATH
4. Access ubuntu folders :
Path location to ubuntu folder is : C:\Users"NAME"\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home
Caution ! Editing files here directly from windows may break permission, you'll have to fix them if so (look on google on how to)
More to come...
Edit and update are coming, I may have forgot things let me know
Feed back also appreciated
highly appreciated
thank you
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
Code:
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(CONFIG_LOCALVERSION)$(LOCALVERSION)
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
Code:
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
would result in the following output:
Code:
4.4.127-FlashKernel-v1.00
nathanchance said:
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
would result in the following output:
Click to expand...
Click to collapse
Thanks for pointing this out
I'll take a look when I'll have time
Nice! Been looking for something like this. XDA feed brought me here.
is it necessary do in win10? or you can simply do it in linux pc without WIN10?
thanks for the post!
tobarreh said:
is it necessary do in win10? or you can simply do it in linux pc without WIN10?
thanks for the post!
Click to expand...
Click to collapse
it should be done on linux
but windows can handle linux as a subsystem now so the guide for people like me who is dumb enough to use windows
seriously skip the ubuntu installation steps on sindows and start building your kernel by following the other steps :good:
Sent from my OnePlus 5 using XDA Labs
nathanchance said:
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
Code:
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(CONFIG_LOCALVERSION)$(LOCALVERSION)
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
Code:
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
would result in the following output:
Code:
4.4.127-FlashKernel-v1.00
Click to expand...
Click to collapse
I personally like to define "LINUX_COMPILE_BY" and "LINUX_COMPILE_HOST" in "scripts/mkcompile_h" just like in this commit by @franciscofranco. By adding this
Code:
LINUX_COMPILE_BY="francisco"
LINUX_COMPILE_HOST="franco"
would display "[email protected]"
3lambda said:
Thanks for pointing this out
I'll take a look when I'll have time
Click to expand...
Click to collapse
Added new kernel naming method by @nathanchance and @sunilpaulmathew, huge thanks to them !
I'll need feedback see if some of these steps aren't clear or if I forgot things
I may also add a video soon and maybe screenshots
Stay tuned
sunilpaulmathew said:
I personally like to define "LINUX_COMPILE_BY" and "LINUX_COMPILE_HOST" in "scripts/mkcompile_h" just like in this commit by @franciscofranco. By adding this
Code:
LINUX_COMPILE_BY="francisco"
LINUX_COMPILE_HOST="franco"
would display "[email protected]"
Click to expand...
Click to collapse
He stopped doing that after I pointed out the same thing can be achieved without any source code edits (since it would change it for everyone building your source)
Code:
export KBUILD_BUILD_USER=francisco
export KBUILD_BUILD_HOST=franco
From: https://github.com/torvalds/linux/blob/master/scripts/mkcompile_h
If I downloaded a zip file of my source code, how do I extract it, since this is no longer just cloning from Git?
https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
link is dead . please update this part of the guide as it is the most important part for me . Thanks for this awesome guide. more updates to come
I'm really looking forward to any and all updates on this thread. I'm old and loosing my mind and all my "Re-Memories" too, so I need all the help I can get.... LOL
permission denied
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
kwshl said:
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
Click to expand...
Click to collapse
execute with 'sudo' make
otonieru said:
execute with 'sudo' make
Click to expand...
Click to collapse
that doesn't help, i did
kwshl said:
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
Click to expand...
Click to collapse
did you place it by doing a git clone or do a cp command ?
this will lessen the nuisance i hope
otonieru said:
did you place it by doing a git clone or do a cp command ?
Click to expand...
Click to collapse
[email protected]:/mnt/g/linux/oreo# bash k.sh
make: execvp: /home/kwshl/aarch64-linux-android-4.9/bin/aarch64-linux-android-gcc: Permission denied
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/bin2c

[Guide]How To Compile Kernel (Especially for Redmi Note 5A)

Hi guys , it is a common fact that kernel runs linux. Without kernel, linux won't be usable. One of linux family is Android. Okay, so after that preamble, i just want to share to you "How To Compile Kernel (Especially for Redmi Note 5A)"​
So, Let's start !​Prerequisites :
1. Laptop/PC with Linux installed (i prefer Ubuntu based distro, for other distributions i'll update if i have tested​2. Already installed needed package (you'll see list below)​3. Internet connection (Optional if you have prepared all)​
Stages :
1. Install all needed packages by typing this command in terminal (if you encounter any error just delete the package that causes error)
Code:
sudo apt-get install git –core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib adb
2. Get the compiler(gcc) by typing this command in terminal
Code:
git clone <url> gcc
3. Get the kernel source from github or gitlab or whatever the service is by typing this command in terminal
Code:
git clone –b <branch name> https://github.com/xxx/xxx
Compile :
After all required components are ready, now let's start compiling our kernel. Run terminal in your kernel folder and type commands below :
1. First, we have to export(to tell the computer) the path of our compiler(gcc) by typing this command :
Code:
export CROSS_COMPILE=/home/<your host>/<gcc folder>/bin/<toolchain prefix>
Example :
Code:
export CROSS_COMPILE=/home/nayef/gcc/bin/aarch64-linux-android-
2. Second, we have to export(to tell the computer) the architecture for our devices. Fortunately Redmi Note 5A has ARM 64 bit architecture, so it should be "arm64".
Code:
export ARCH=arm64 && export SUBARCH=arm64
3. Third, before compiling, let's configure our devices configuration by using available defconfig, usually our devs name it "ugglite_defconfig", but from official Xiaomi source it is "ugglite_msm8937_defconfig" . There are many sources of Redmi Note 5A Kernel. PM me if you want the list.
Code:
make O=out <defconfig name>
Example:
Code:
make O=out ugglite_defconfig
4. Now, let's compile it by typing this commands below
Code:
make O=out -j4
Reference :
nathanchance thread
Android Google Source
Hey man, does the wifi work after compiling the kernel?
I am trying to compile redmi 5a kernel from source.
Even though device boots with new kernel , the wifi doesn't work.
The guid at https://github.com/MiCode/Xiaomi_Kernel_OpenSource/wiki/How-to-compile-kernel-standalone
talks about non-dtbo and include-dtbo. What are those? Can you give me some idea.
Partha Dip said:
Hey man, does the wifi work after compiling the kernel?
I am trying to compile redmi 5a kernel from source.
Even though device boots with new kernel , the wifi doesn't work.
The guid at https://github.com/MiCode/Xiaomi_Kernel_OpenSource/wiki/How-to-compile-kernel-standalone
talks about non-dtbo and include-dtbo. What are those? Can you give me some idea.
Click to expand...
Click to collapse
you have to add prima wlan drivers to get wifi working correctly
Bro plz help me .tell me the source and toolchain you use plz bro reply plz I request
Bro plz tell me toolchain and source you use
Mind sending me the guide that you use to root your Redmi 5A? I'm not so interested into building my own kernel from source, as I don't really see any benefits of doing so unless I'm changing compilation flags which, at least right now, is not my intention.
I have experience with Linux, but I'm having a few questions that I cannot come up with the answer and some technical issues which I'm still trying to overcome, and I've seen several guides from several people each doing different stuff to achieve the same goal and I'm lost on which one to follow and why, as most of them are oversimplified and are merely a set of instructions without further explanation, and I would hate to brick my phone because of it (although it's a old phone so that's not that bad).
Also the github page you mentioned has an outdated version of the Linux kernel.
Also since the Redmi 5A runs armv8 (aarch64) you could run any Linux distribution you like, right? Obviously it has to have support out of the box in the iso for touch screen otherwise you can't do anything, but I should be fine installing a generic distribution that ships with aarch64 and touch input, right? Worst case scenario it doesn't ship with the drivers required for some components to works, as you mentioned with wi-fi, but that's a matter of installing it on the system.

Categories

Resources