[GUIDE] How to build a Samsung Kernel July 30, 2016

Search This thread

The Sickness

Retired Recognized Developer
Oct 27, 2012
9,780
22,733
Somewhere in Texas
MAINMAIN_zpsdhabisgt.png


How to compile a Samsung Kernel from source

Ok folks, I am going to show you how to build a Sammy kernel from source. This will be a very long guide, so I might miss one or two things. But we will solve that if it happens.
Below is a list of requirements that you must have in order to be successful.

REQUIREMENTS

1. For the best outcome, you need to be on Linux. I dont support VM Box
2. All the android dependencies. (Which I will provide)
3. Toolchain
4. A github account or the like. Its free.
5. Be familiar with terminal commands
6. And have alot of patients

SETTING UP YOUR BUILD ENVIRONMENT

First thing we need to do is set up your build environment. So in order to do this we need to install some packages to make sure your kernel
compiles correctly.... So open a terminal on your desktop, and copy and paste the code into your terminal from below:
Code:
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
Screenshot_2016-07-30_14-59-17_zps6binvhuc.png



HOW TO GET YOUR KERNEL SOURCE

Samsung keeps all of their source code on Samsung Open Source here. So open this in your browser...once you have you want to click on "Mobile"
Screenshot_2016-07-30_15-26-23_zpsaonjdhli.png


The next screen will have a search box. Inside that box you need to type in YOUR model number...

d3dac0bb-e561-4891-8f86-795245bf30f3_zpsdqvg9te6.png


The next screen will show all of the available source code for your device. Select the one that you need, the most current one...

b66e22e6-4fd6-43aa-9b14-5f76680ad381_zpsgxnm4dp8.png



Now you have downloaded the kernel source.......now we need to extract it. This where you need to pay attention...
You will have a "home" folder. Open it and create a "new" folder and name it anything you want. This is where you will extract the kernel source to. Once you have
your folder created you need to navigate to your download folder, thats where the kernel zip will be located. Right click on the zip and select "extract here"...it will
then extract the kernel.tar to your download folder. Once its done you will see the new folder it has made and this is what it should look like when you open it

eac6c9ba-e916-4274-b7b9-ad8d0afbd685_zpsjn2dd4cl.png


Now, right click on kernel.tar. Then select "extract to"......a window will pop up, select the new folder you just created. It will then extract all the kernel files to that folder.
That will be your kernel source. It should look similiar to mine...

Screenshot_2016-07-30_16-50-35_zpspzlinhtb.png


Now you have your source. But, Sammy left out some files (imagine that)......so your going to need to get them. The easiest way is for you to clone my source
from Github. So go here. See the green tab that says Clone or download? Click it, it will bring up another
small widow.....click on the clipboard icon....open a terminal in your HOME FOLDER.....inside the terminal type git clone and then paste the url after

Screenshot_2016-07-30_17-04-26_zpsmydlqhei.png


This will now download MY source to your home folder. Now lets pay close attention here.....You need to open YOUR source in a window, and open MINE in
another window. We will be copying several files from my source to yours.

In my source navigate to drivers/video/exynos. Copy and paste "decon_dual_dsi" and "decon_dual_display" folders to YOUR source. If you already have these files
in your source, you can skip this.

Now we need to get a couple more files. (Non T-Mobile users see post #3) Download these files here. Open the zip and copy them to
your source. In another words just drop them in. Please note that the "output" folder contains empty folder for the G920T and G925T. IF you are building the G920F you need
to change the folder name. Thats very important. We will get more into the build_kernel.sh and env_setup.sh later.

Now we need to get our toolchain. I have decided to get yall to use a custom toolchain instead of stock. There are several that you can use, but for this will use UberTC. So go
here. Now open your HOME folder and then open a terminal. On the webpage click "clone", copy
and paste it into the terminal. It will now download the toolchain to your home folder.

Seeing that we have our toolchain now, we need to set the path from it to our source so the compiler will know what to use at build time. The path needs to be set in 2 places in your source.
One in the env_setup.sh, and in the Makefile......This is how you do this ANYTIME you change your toolchain:


Now navigate to your home folder, you will see the UberTC toolchain you cloned earlier. Now you want to open it like this aarch64-linux-android-5.3-kernel/bin/. Now you will
need to copy the entire address line...mine is like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/ Yours should be the same except for "sick", it should be your username.
Now, you need to open env_setup.sh with your text editor (mousepad, gedit, etc).....scroll to the bottom to where you see # system compiler
export CROSS_COMPILE=/home/sick/aarch64-linux-gnu-5.3/bin/aarch64-........REPLACE /home/sick/aarch64-linux-gnu-5.3/bin/aarch64- with the address from your toolchain folder.
It should look like this when you are done /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-..................YES, you need to type aarch64-linux-android- after bin/
The screen shot below shows a different toolchain than what we are using. So pay that no mind.

Screenshot_2016-07-30_20-32-54_zpsxmwnfeo2.png


Now open your Makefile.......I want you to replace the ENTIRE file from the one I provided below.
Open the Makefile with your text editor.....see line #7 #TOOLCHAIN_DIR = $(CURDIR)/toolchain/aarch64-linux-gnu-5.3/bin/aarch64-
Change it to this : #TOOLCHAIN_DIR=$(CURDIR)/toolchain/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-

Line #8 need to be just like the one you set in env_setup.sh......
Mine looks like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-

Now the toolchain is set, and the compiler will use it to build the kernel.

OK, I'm going to skip a step on editing the defconfig for now. Reason being is that once we upload your source to Github you will need some basic Github
commands when you change things within your source and need to commit them.

UPLOADING SOURCE TO GITHUB

I assume by now that you have made a Github account. So now we need to create a repository so we can upload your source. This is'nt too difficult to do....
Go to Github....There will be a green tab that says New Repository, click on it.

Screenshot_2016-07-31_08-55-24_zpsc335lsty.png


Now you need name the repository......name it whatever you wish

Screenshot_2016-07-31_08-57-03_zpsixnpusfp.png


On the next 2 screen shots select the ones I have highlighted, then select Create repository
Screenshot_2016-07-31_08-59-13_zpsrabrqham.png

Screenshot_2016-07-31_08-59-32_zpsizjnywnt.png


Once the new repository is created it will look like this......

Screenshot_2016-07-31_09-00-07_zpszg36wn2q.png


Ok, minimize your Github page, (dont close it).......open your kernel source folder. Inside the folder open a terminal and type: git init

Screenshot_2016-07-31_09-20-35_zps3odoilli.png


Next I want you to type EXACTLY like this: git add .

Screenshot_2016-07-31_09-26-37_zpsseahjqsm.png


Press enter.....in a minute or two it will start to load all your files......once its complete you need to maximize your Github page. Click on the green tab, then on the
small clipboard icon, in the terminal i want you to type: git remote add origin (paste the url from the clipboard). It should look like this...

Screenshot_2016-07-31_09-37-09_zpsdv962ndy.png


Press enter. If you dont get any errors it will look like this.

Screenshot_2016-07-31_09-46-37_zpsfo57pv6n.png


Now type this: git commit -m Stock source Where I have Stock source you can change to whatever you want

Screenshot_2016-07-31_10-08-12_zpsdl4axty1.png


It will start uploading your source

Screenshot_2016-07-31_10-37-18_zpsl5ydlyv8.png


Once that is complete you need to type: git push origin master
It will ask for your Github username and then password

Screenshot_2016-07-31_10-38-05_zpsvofedapj.png


Now sometimes Github can be a pain and you will get this error when you try to push your source

Screenshot_2016-07-31_10-38-21_zpsdciuukmu.png


To get around this, you need to type: git push -f origin master........then your username and password

Screenshot_2016-07-31_10-38-56_zps70fxx0x9.png


Once it completes the upload process go ahead and refresh your Github page and it should look like this...

9e5aae10-7989-40e1-a541-900d1fe6098e_zpstuiu5dzo.png


You have now uploaded your source to Github.


SETTING UP env_setup.sh FOR BUILDING YOUR VARIANT

When you look at env_setup.sh you will see that on line #68 says G920T. IF you are going to build for example the G920F, you need to change it
from G920T to G920F and so on.....

Screenshot_2016-07-30_20-32-54_zpsxmwnfeo2.png


Now take a look at line #70....that is the defconfig file. So in your kernel source folder go to arch/arm64/configs. You will see the original name
for one or both config files. I changed the name on mine which correspond with my env_setup.sh. If you are NOT going to change the name on the
defconfig then you must change it back to original in env_setup.sh.

Earlier I had you use the Makefile I provided instead of the one that came with your source......That is MY Makefile from Twisted. So, we are going to have
to make a couple of edits in your defconfig file so you can take advantage of a few things that are included in my Makefile......

Open the Makefile in your kernel source......look at lines 10-19. Those 2 need to be enabled in your defconfig. So now go to arch/arm64/configs. Open
the config file that you will be using with a text editor.......add I want you to add these 2 lines just as I have them....

Screenshot_2016-07-31_12-16-10_zps0r2j9ptn.png


Now we just made a change to your source. The changes are what is called local. We need to commit them to Github. In order to do that you need
to open a terminal in your kernel source and type: git status
You should see this

Screenshot_2016-07-31_12-23-24_zpszw82hdfn.png


You need to copy like this

Screenshot_2016-07-31_12-26-52_zpsasfxqfm2.png


Then type: git add (paste it here) then enter

Screenshot_2016-07-31_12-29-27_zpskgvufknu.png


Now type: git commit and you will get this.....

Screenshot_2016-07-31_12-32-17_zpsw3iim2sk.png


You will need to type a commit line. If you leave it blank it WILL NOT commit your changes. See how mine is......

Screenshot_2016-07-31_13-25-10_zpsgn6f2x8z.png


Now to commit those changes from above you need to type the following: Ctrl+o enter Ctrl+x.......if you did it correctly it will look like this....

Screenshot_2016-07-31_13-30-28_zpszby8ip2c.png


Then type: git push origin master then enter. Type your username and password......And this is what it should look like
if you did it all correctly...

Screenshot_2016-07-31_13-33-46_zpsnvsbytgi.png


Now at this point you can look at your Github page and see that it has been committed.......

Screenshot_2016-07-31_13-37-55_zpshlspnccv.png



TIME TO COMPILE

This part is rather simple. I'm going to give 2 examples on how to build for the G920T and the G920F. Now remember, our env_setup.sh says
G920T on lines 68 and 69. So thats what we will build....

In your kernel source open a terminal and type this: sudo build_kernel.sh G920T press enter. It should look like this...

Screenshot_2016-07-31_13-51-14_zpswpbtizy8.png


Once you type your password and hit enter it should look like these.....

Screenshot_2016-07-31_13-55-21_zpsjqg0cp2g.png

Screenshot_2016-07-31_13-55-34_zps4fk7qt4l.png

Screenshot_2016-07-31_13-55-48_zpsykmd1g5s.png

Screenshot_2016-07-31_13-56-05_zpselc2fgog.png


Now for the G920F build.......all you need to do is change the names in your env_setup.sh. Where it says G920T you change to G920F.
Same goes for any S6 device. Just change the name in the file.
Also make sure the name of your config file matches in both the env_setup.sh and in arch/arm64/configs.......

AT THE END OF THE BUILD YOU WILL BE ASKED TO USE s=stock or c=custom DT.IMG........SELECT S!!!!

NOW YOU HAVE BUILT IT......NOW WHAT.....

If you have followed along you will have made sure the output folder in your source has the device name you were compiling. Look in that folder,
and there will be a flashable zip as well as a tar file for Odin.

Well folks, that about covers it. In post #2 I will show you how to cherry-pick commits and fix simple HEAD errors. If anyone has issues or is
lost please post the problem and I will help you the best I can.......


I dont think I missed anything. If I did we will address it when the time comes. Remember, this is a guide to get you started. I suggest you try to use
Google to find other kernel threads that has building information and so on.......

A special thanks to the following folks:
Especially to my bro @ShinySide for getting me starting in the kernel bizz
@halaszk for his awesome build script
@UpInTheAir for various code source and BUILD SCRIPTS
And of course.....ME

Telegram Invite
https://telegram.me/joinchat/DnmUJwsL2XJPvYYSezOnfA

XDA:DevDB Information
How to build a Samsung Kernel, Kernel for the Samsung Galaxy S6

Contributors
The Sickness
Kernel Special Features:

Version Information
Status: Stable

Created 2016-08-02
Last Updated 2016-08-01
 

Attachments

  • Makefile.zip
    15.6 KB · Views: 1,138
Last edited:

The Sickness

Retired Recognized Developer
Oct 27, 2012
9,780
22,733
Somewhere in Texas
HOW TO CHERRY PICK COMMITS

This part of the guide isnt really that hard to understand. You just need to make sure what you pick will work on your kernel......I advise for you
to pick from the same device. If your building for the G920T, you need to pick from the S6.....Please note that it doesnt matter if the commit is
2 weeks old or 2 years. In another words, firmware isnt a factor. Your stock source is what is from the latest firmware. The kernel code is many
years old....its just improved over time. So lets get started......

First question.....where would you cherry pick from? Well Github is the answer. So to make this easy will will use my Twisted Kernel source.
Go to here. Now in your kernel source open a terminal.....
What we need to do is "fetch" my source......its a remote hook up you might say. So on the web page click the green tab that says
Clone or download, then click on the clipboard icon.......go to your terminal and type: git fetch (paste url you just copied), hit enter. It will set
up a remote hook. Once its done you can pick any or all of my commits.

A point to remember, you ALWAYS pick from the oldest to newest, unless you commit each pick you make. So, let me show you how. On the Github page
on the left side it says 388 commits, select it. It will now bring up all the commits. Scroll to the bottom of the page and select older.....keep doing that until
you reach the end.....so you should be here......

Screenshot_2016-07-31_20-31-12_zpser2mw0dq.png


Now, what you really need to do is read the commit BEFORE you pick it. Most have a description, and some dont. But, everyone wants a "permissive" kernel.
So, the commit that says Set kernel to "permissive" is our first one. To the far right of the commit is a clipboard icon, click it......now in your terminal
type: git cherry-pick (paste from the clipboard) then hit enter. It will look like this when its done

Screenshot_2016-07-31_20-41-55_zpsyuw4bjlz.png


Now we need to commit the cherry-pick we just made. So in your terminal type: git push origin master......then your username, then your password.
When its done it will look like this

Screenshot_2016-07-31_20-45-58_zpszlmxvtpl.png


Now, lets say you made a cherry-pick and you get this error.......

Screenshot_2016-07-31_20-55-46_zps9ulmj0xd.png


When you get this error there is a problem with the commit. So in your terminal type: git status.......and it will look like this after

Screenshot_2016-07-31_20-59-03_zpspfwousnv.png


So what we need to do is find out what the issue is. 99.9% of the time its a "HEAD" issue......which is the case here. So, go to block/Kconfig.iosched...thats the first issue.
Open it with your text editor. Look at line 35, 36, and 119. Those NEED to be deleted

Screenshot_2016-08-01_19-01-58_zpssxorjmwy.png


Now go to block/Makefile... you can see here that you need to delete lines 18, 19, and 28.
Screenshot_2016-08-01_19-07-29_zpsrmslotxg.png


Now once you have fixed those errors you need to commit it. To do that you need to copy the folder location like this.....

Screenshot_2016-08-01_19-31-46_zpsmla7foc9.png


Then once you have it copied you will need to type: git add (paste it here)...then it will look like this

Screenshot_2016-08-01_19-35-57_zps6thsgb5b.png


Now do the same to the other...it will look like this

Screenshot_2016-08-01_19-39-31_zpsfbbcedrr.png


Now we need to commit those changes. Type: git commit.........it will look like this

Screenshot_2016-08-02_03-33-29_zpskkff5vre.png


Now you will notice that the commit message is already there....so there is no need to change it. So now we need to commit. To do that
you need to select Ctlr+o.........then enter.........Ctlr+x...............and it will look like this

Screenshot_2016-08-02_04-24-53.png


Then in your terminal type: git push origin master........then your username..then your password. Then take a look at your Github
page and you will see the commit appear.

That covers basic cherry-pick..........
 
Last edited:

The Sickness

Retired Recognized Developer
Oct 27, 2012
9,780
22,733
Somewhere in Texas
How to use Mkboot to edit your ramdisk

Here will will learn how to use mkboot to do many things...... The first thing we need to do is clone mkboot.img from Github. So you need to go
here. Now open a terminal in your home folder and "clone" the source.....it should look like this

Screenshot_2016-08-04_17-51-21_zpsrkcvzct9.png


Then when you open the folder it should look like this

Screenshot_2016-08-04_17-51-54_zpstkz9whui.png


Now, you need to place your stock boot.img into the folder. Its up to you to get your boot.img from your device firmware. I cant do
everything for you...lol. Drop the boot.img in like this

Screenshot_2016-08-04_18-15-54_zpsymrdlief.png


Now, in the mkbootimg_tools folder you need to open a terminal and type: ./mkboot boot.img unpacked......hit enter. Looks like this

Screenshot_2016-08-04_18-29-47_zpskrok2exn.png


When its done unpacking the boot.img it will look like this

Screenshot_2016-08-04_18-30-03_zpsd1sklsak.png

Screenshot_2016-08-04_18-30-15_zpsp8cxkcq3.png


Now, for all non T-Mobile users.........

In your kernel source you need to go to your build_kernel folder. Now "make" a folder of your device IE: G920F......G920I...etc
Once you have this folder made you need to take the ramdisk, dt.img, and img_info from the unpacked folder in mkboot_tools and
place them in the new folder you just created in build_kernel...like this

url]


Now your ready to build....
 
Last edited:

inteks

Senior Member
Oct 14, 2006
1,323
933
MAINMAIN_zpsdhabisgt.png


How to compile a Samsung Kernel from source

Ok folks, I am going to show you how to build a Sammy kernel from source. This will be a very long guide, so I might miss one or two things. But we will solve that if it happens.
Below is a list of requirements that you must have in order to be successful.

REQUIREMENTS

1. For the best outcome, you need to be on Linux. I dont support VM Box
2. All the android dependencies. (Which I will provide)
3. Toolchain
4. A github account or the like. Its free.
5. Be familiar with terminal commands
6. And have alot of patients

SETTING UP YOUR BUILD ENVIRONMENT

First thing we need to do is set up your build environment. So in order to do this we need to install some packages to make sure your kernel
compiles correctly.... So open a terminal on your desktop, and copy and paste the code into your terminal from below:
Code:
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
Screenshot_2016-07-30_14-59-17_zps6binvhuc.png



HOW TO GET YOUR KERNEL SOURCE

Samsung keeps all of their source code on Samsung Open Source here. So open this in your browser...once you have you want to click on "Mobile"
Screenshot_2016-07-30_15-26-23_zpsaonjdhli.png


The next screen will have a search box. Inside that box you need to type in YOUR model number...

d3dac0bb-e561-4891-8f86-795245bf30f3_zpsdqvg9te6.png


The next screen will show all of the available source code for your device. Select the one that you need, the most current one...

b66e22e6-4fd6-43aa-9b14-5f76680ad381_zpsgxnm4dp8.png



Now you have downloaded the kernel source.......now we need to extract it. This where you need to pay attention...
You will have a "home" folder. Open it and create a "new" folder and name it anything you want. This is where you will extract the kernel source to. Once you have
your folder created you need to navigate to your download folder, thats where the kernel zip will be located. Right click on the zip and select "extract here"...it will
then extract the kernel.tar to your download folder. Once its done you will see the new folder it has made and this is what it should look like when you open it

eac6c9ba-e916-4274-b7b9-ad8d0afbd685_zpsjn2dd4cl.png


Now, right click on kernel.tar. Then select "extract to"......a window will pop up, select the new folder you just created. It will then extract all the kernel files to that folder.
That will be your kernel source. It should look similiar to mine...

Screenshot_2016-07-30_16-50-35_zpspzlinhtb.png


Now you have your source. But, Sammy left out some files (imagine that)......so your going to need to get them. The easiest way is for you to clone my source
from Github. So go here. See the green tab that says Clone or download? Click it, it will bring up another
small widow.....click on the clipboard icon....open a terminal in your HOME FOLDER.....inside the terminal type git clone and then paste the url after

Screenshot_2016-07-30_17-04-26_zpsmydlqhei.png


This will now download MY source to your home folder. Now lets pay close attention here.....You need to open YOUR source in a window, and open MINE in
another window. We will be copying several files from my source to yours.

In my source navigate to drivers/video/exynos. Copy and paste "decon_dual_dsi" and "decon_dual_display" folders to YOUR source. If you already have these files
in your source, you can skip this.

Now we need to get a couple more files. Download these files here. Open the zip and copy them to
your source. In another words just drop them in. Please note that the "output" folder contains empty folder for the G920T and G925T. IF you are building the G920F you need
to change the folder name. Thats very important. We will get more into the build_kernel.sh and env_setup.sh later.

Now we need to get our toolchain. I have decided to get yall to use a custom toolchain instead of stock. There are several that you can use, but for this will use UberTC. So go
here. Now open your HOME folder and then open a terminal. On the webpage click "clone", copy
and paste it into the terminal. It will now download the toolchain to your home folder.

Seeing that we have our toolchain now, we need to set the path from it to our source so the compiler will know what to use at build time. The path needs to be set in 2 places in your source.
One in the env_setup.sh, and in the Makefile......This is how you do this ANYTIME you change your toolchain:


Now navigate to your home folder, you will see the UberTC toolchain you cloned earlier. Now you want to open it like this aarch64-linux-android-5.3-kernel/bin/. Now you will
need to copy the entire address line...mine is like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/ Yours should be the same except for "sick", it should be your username.
Now, you need to open env_setup.sh with your text editor (mousepad, gedit, etc).....scroll to the bottom to where you see # system compiler
export CROSS_COMPILE=/home/sick/aarch64-linux-gnu-5.3/bin/aarch64-........REPLACE /home/sick/aarch64-linux-gnu-5.3/bin/aarch64- with the address from your toolchain folder.
It should look like this when you are done /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-..................YES, you need to type aarch64-linux-android- after bin/
The screen shot below shows a different toolchain than what we are using. So pay that no mind.

Screenshot_2016-07-30_20-32-54_zpsxmwnfeo2.png


Now open your Makefile.......I want you to replace the ENTIRE file from the one I provided below.
Open the Makefile with your text editor.....see line #7 #TOOLCHAIN_DIR = $(CURDIR)/toolchain/aarch64-linux-gnu-5.3/bin/aarch64-
Change it to this : #TOOLCHAIN_DIR=$(CURDIR)/toolchain/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-

Line #8 need to be just like the one you set in env_setup.sh......
Mine looks like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-

Now the toolchain is set, and the compiler will use it to build the kernel.

OK, I'm going to skip a step on editing the defconfig for now. Reason being is that once we upload your source to Github you will need some basic Github
commands when you change things within your source and need to commit them.

UPLOADING SOURCE TO GITHUB

I assume by now that you have made a Github account. So now we need to create a repository so we can upload your source. This is'nt too difficult to do....
Go to Github....

TO BE CONTINUED...........
thx. but why no vm box?

Gesendet von meinem SM-G920F mit Tapatalk
 

Maqical

Senior Member
Jun 5, 2012
1,198
1,177
thx. but why no vm box?

Gesendet von meinem SM-G920F mit Tapatalk

Alot of Vm applications limit how much ram you can set and then it would take quite awhile with lower resources on build time probably up to 3 hours in some cases where it could be 1 hour and less

1 extremely good vm application I use for everything is VMwareworkstation It's quite expensive but worth it and fully able to change any settings needed at any time

Theres a free 30 trial if you plan on going the vm way for workstation
 

inteks

Senior Member
Oct 14, 2006
1,323
933
Alot of Vm applications limit how much ram you can set and then it would take quite awhile with lower resources on build time probably up to 3 hours in some cases where it could be 1 hour and less

1 extremely good vm application I use for everything is VMwareworkstation It's quite expensive but worth it and fully able to change any settings needed at any time

Theres a free 30 trial if you plan on going the vm way for workstation
i use virtualbox normaly and without performance issues! the last time i build a kernel is some time ago. for my xperia neo [emoji6] but this was although virtualbox with debian and i had no problems with it!

i thought about kernel building for s6 because all kernel projects are EOL and i have no money for a new device for now. btw i quite happy with my 128gb version [emoji12] only batterytime is a bit low. maybe i swap the battery for a s7egde battery sometime...

Gesendet von meinem SM-G920F mit Tapatalk
 

pawo99

Senior Member
Dec 20, 2007
635
203
Is possible to show us how to build your Twisted kernel for 920F, please? :fingers-crossed: :angel: Call audio not working :( Or how to update older kernel to new sources? :eek:Thanks
BTW, your Twisted kernel is the best :good::good::good:
 

The Sickness

Retired Recognized Developer
Oct 27, 2012
9,780
22,733
Somewhere in Texas
Is possible to show us how to build your Twisted kernel for 920F, please? :fingers-crossed: :angel: Call audio not working :( Or how to update older kernel to new sources? :eek:Thanks
BTW, your Twisted kernel is the best :good::good::good:

This guide will show you how to build a kernel. I will also explain how to cherry pick commits and such...so yes, you can build one just like my Twisted kernel
 
  • Like
Reactions: pawo99

royorbs3

Senior Member
Feb 9, 2013
286
68
Cool @TheSickness this will be easier than referring to our hangouts conversations ;) Thanks buddy. I told u I eventually got some errors using git cherry pick. Looking out for that part of the tut
 

UpInTheAir

Account currently disabled
Jan 17, 2011
7,965
15,907
Phuket, Thailand
Actually . . . the build script(s) were initially sourced from here : https://github.com/halaszk/Perseus-halaszk-universal5433 and if you diff them, will be HUGE changes. The 'modern' build script(s) version you are currently using was packaged within my SkyHigh v3.4 source (which isn't a requirement for GPL). I have since moved on and of course kept improving them since . . . .

I always leave original credit in all my scripts, even if the code has been modified (sometimes) beyond recognition . . .
 
  • Like
Reactions: Umair Ahmad

Top Liked Posts

  • There are no posts matching your filters.
  • 65
    MAINMAIN_zpsdhabisgt.png


    How to compile a Samsung Kernel from source

    Ok folks, I am going to show you how to build a Sammy kernel from source. This will be a very long guide, so I might miss one or two things. But we will solve that if it happens.
    Below is a list of requirements that you must have in order to be successful.

    REQUIREMENTS

    1. For the best outcome, you need to be on Linux. I dont support VM Box
    2. All the android dependencies. (Which I will provide)
    3. Toolchain
    4. A github account or the like. Its free.
    5. Be familiar with terminal commands
    6. And have alot of patients

    SETTING UP YOUR BUILD ENVIRONMENT

    First thing we need to do is set up your build environment. So in order to do this we need to install some packages to make sure your kernel
    compiles correctly.... So open a terminal on your desktop, and copy and paste the code into your terminal from below:
    Code:
    sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng
    Screenshot_2016-07-30_14-59-17_zps6binvhuc.png



    HOW TO GET YOUR KERNEL SOURCE

    Samsung keeps all of their source code on Samsung Open Source here. So open this in your browser...once you have you want to click on "Mobile"
    Screenshot_2016-07-30_15-26-23_zpsaonjdhli.png


    The next screen will have a search box. Inside that box you need to type in YOUR model number...

    d3dac0bb-e561-4891-8f86-795245bf30f3_zpsdqvg9te6.png


    The next screen will show all of the available source code for your device. Select the one that you need, the most current one...

    b66e22e6-4fd6-43aa-9b14-5f76680ad381_zpsgxnm4dp8.png



    Now you have downloaded the kernel source.......now we need to extract it. This where you need to pay attention...
    You will have a "home" folder. Open it and create a "new" folder and name it anything you want. This is where you will extract the kernel source to. Once you have
    your folder created you need to navigate to your download folder, thats where the kernel zip will be located. Right click on the zip and select "extract here"...it will
    then extract the kernel.tar to your download folder. Once its done you will see the new folder it has made and this is what it should look like when you open it

    eac6c9ba-e916-4274-b7b9-ad8d0afbd685_zpsjn2dd4cl.png


    Now, right click on kernel.tar. Then select "extract to"......a window will pop up, select the new folder you just created. It will then extract all the kernel files to that folder.
    That will be your kernel source. It should look similiar to mine...

    Screenshot_2016-07-30_16-50-35_zpspzlinhtb.png


    Now you have your source. But, Sammy left out some files (imagine that)......so your going to need to get them. The easiest way is for you to clone my source
    from Github. So go here. See the green tab that says Clone or download? Click it, it will bring up another
    small widow.....click on the clipboard icon....open a terminal in your HOME FOLDER.....inside the terminal type git clone and then paste the url after

    Screenshot_2016-07-30_17-04-26_zpsmydlqhei.png


    This will now download MY source to your home folder. Now lets pay close attention here.....You need to open YOUR source in a window, and open MINE in
    another window. We will be copying several files from my source to yours.

    In my source navigate to drivers/video/exynos. Copy and paste "decon_dual_dsi" and "decon_dual_display" folders to YOUR source. If you already have these files
    in your source, you can skip this.

    Now we need to get a couple more files. (Non T-Mobile users see post #3) Download these files here. Open the zip and copy them to
    your source. In another words just drop them in. Please note that the "output" folder contains empty folder for the G920T and G925T. IF you are building the G920F you need
    to change the folder name. Thats very important. We will get more into the build_kernel.sh and env_setup.sh later.

    Now we need to get our toolchain. I have decided to get yall to use a custom toolchain instead of stock. There are several that you can use, but for this will use UberTC. So go
    here. Now open your HOME folder and then open a terminal. On the webpage click "clone", copy
    and paste it into the terminal. It will now download the toolchain to your home folder.

    Seeing that we have our toolchain now, we need to set the path from it to our source so the compiler will know what to use at build time. The path needs to be set in 2 places in your source.
    One in the env_setup.sh, and in the Makefile......This is how you do this ANYTIME you change your toolchain:


    Now navigate to your home folder, you will see the UberTC toolchain you cloned earlier. Now you want to open it like this aarch64-linux-android-5.3-kernel/bin/. Now you will
    need to copy the entire address line...mine is like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/ Yours should be the same except for "sick", it should be your username.
    Now, you need to open env_setup.sh with your text editor (mousepad, gedit, etc).....scroll to the bottom to where you see # system compiler
    export CROSS_COMPILE=/home/sick/aarch64-linux-gnu-5.3/bin/aarch64-........REPLACE /home/sick/aarch64-linux-gnu-5.3/bin/aarch64- with the address from your toolchain folder.
    It should look like this when you are done /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-..................YES, you need to type aarch64-linux-android- after bin/
    The screen shot below shows a different toolchain than what we are using. So pay that no mind.

    Screenshot_2016-07-30_20-32-54_zpsxmwnfeo2.png


    Now open your Makefile.......I want you to replace the ENTIRE file from the one I provided below.
    Open the Makefile with your text editor.....see line #7 #TOOLCHAIN_DIR = $(CURDIR)/toolchain/aarch64-linux-gnu-5.3/bin/aarch64-
    Change it to this : #TOOLCHAIN_DIR=$(CURDIR)/toolchain/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-

    Line #8 need to be just like the one you set in env_setup.sh......
    Mine looks like this: /home/sick/aarch64-linux-android-5.3-kernel/bin/aarch64-linux-android-

    Now the toolchain is set, and the compiler will use it to build the kernel.

    OK, I'm going to skip a step on editing the defconfig for now. Reason being is that once we upload your source to Github you will need some basic Github
    commands when you change things within your source and need to commit them.

    UPLOADING SOURCE TO GITHUB

    I assume by now that you have made a Github account. So now we need to create a repository so we can upload your source. This is'nt too difficult to do....
    Go to Github....There will be a green tab that says New Repository, click on it.

    Screenshot_2016-07-31_08-55-24_zpsc335lsty.png


    Now you need name the repository......name it whatever you wish

    Screenshot_2016-07-31_08-57-03_zpsixnpusfp.png


    On the next 2 screen shots select the ones I have highlighted, then select Create repository
    Screenshot_2016-07-31_08-59-13_zpsrabrqham.png

    Screenshot_2016-07-31_08-59-32_zpsizjnywnt.png


    Once the new repository is created it will look like this......

    Screenshot_2016-07-31_09-00-07_zpszg36wn2q.png


    Ok, minimize your Github page, (dont close it).......open your kernel source folder. Inside the folder open a terminal and type: git init

    Screenshot_2016-07-31_09-20-35_zps3odoilli.png


    Next I want you to type EXACTLY like this: git add .

    Screenshot_2016-07-31_09-26-37_zpsseahjqsm.png


    Press enter.....in a minute or two it will start to load all your files......once its complete you need to maximize your Github page. Click on the green tab, then on the
    small clipboard icon, in the terminal i want you to type: git remote add origin (paste the url from the clipboard). It should look like this...

    Screenshot_2016-07-31_09-37-09_zpsdv962ndy.png


    Press enter. If you dont get any errors it will look like this.

    Screenshot_2016-07-31_09-46-37_zpsfo57pv6n.png


    Now type this: git commit -m Stock source Where I have Stock source you can change to whatever you want

    Screenshot_2016-07-31_10-08-12_zpsdl4axty1.png


    It will start uploading your source

    Screenshot_2016-07-31_10-37-18_zpsl5ydlyv8.png


    Once that is complete you need to type: git push origin master
    It will ask for your Github username and then password

    Screenshot_2016-07-31_10-38-05_zpsvofedapj.png


    Now sometimes Github can be a pain and you will get this error when you try to push your source

    Screenshot_2016-07-31_10-38-21_zpsdciuukmu.png


    To get around this, you need to type: git push -f origin master........then your username and password

    Screenshot_2016-07-31_10-38-56_zps70fxx0x9.png


    Once it completes the upload process go ahead and refresh your Github page and it should look like this...

    9e5aae10-7989-40e1-a541-900d1fe6098e_zpstuiu5dzo.png


    You have now uploaded your source to Github.


    SETTING UP env_setup.sh FOR BUILDING YOUR VARIANT

    When you look at env_setup.sh you will see that on line #68 says G920T. IF you are going to build for example the G920F, you need to change it
    from G920T to G920F and so on.....

    Screenshot_2016-07-30_20-32-54_zpsxmwnfeo2.png


    Now take a look at line #70....that is the defconfig file. So in your kernel source folder go to arch/arm64/configs. You will see the original name
    for one or both config files. I changed the name on mine which correspond with my env_setup.sh. If you are NOT going to change the name on the
    defconfig then you must change it back to original in env_setup.sh.

    Earlier I had you use the Makefile I provided instead of the one that came with your source......That is MY Makefile from Twisted. So, we are going to have
    to make a couple of edits in your defconfig file so you can take advantage of a few things that are included in my Makefile......

    Open the Makefile in your kernel source......look at lines 10-19. Those 2 need to be enabled in your defconfig. So now go to arch/arm64/configs. Open
    the config file that you will be using with a text editor.......add I want you to add these 2 lines just as I have them....

    Screenshot_2016-07-31_12-16-10_zps0r2j9ptn.png


    Now we just made a change to your source. The changes are what is called local. We need to commit them to Github. In order to do that you need
    to open a terminal in your kernel source and type: git status
    You should see this

    Screenshot_2016-07-31_12-23-24_zpszw82hdfn.png


    You need to copy like this

    Screenshot_2016-07-31_12-26-52_zpsasfxqfm2.png


    Then type: git add (paste it here) then enter

    Screenshot_2016-07-31_12-29-27_zpskgvufknu.png


    Now type: git commit and you will get this.....

    Screenshot_2016-07-31_12-32-17_zpsw3iim2sk.png


    You will need to type a commit line. If you leave it blank it WILL NOT commit your changes. See how mine is......

    Screenshot_2016-07-31_13-25-10_zpsgn6f2x8z.png


    Now to commit those changes from above you need to type the following: Ctrl+o enter Ctrl+x.......if you did it correctly it will look like this....

    Screenshot_2016-07-31_13-30-28_zpszby8ip2c.png


    Then type: git push origin master then enter. Type your username and password......And this is what it should look like
    if you did it all correctly...

    Screenshot_2016-07-31_13-33-46_zpsnvsbytgi.png


    Now at this point you can look at your Github page and see that it has been committed.......

    Screenshot_2016-07-31_13-37-55_zpshlspnccv.png



    TIME TO COMPILE

    This part is rather simple. I'm going to give 2 examples on how to build for the G920T and the G920F. Now remember, our env_setup.sh says
    G920T on lines 68 and 69. So thats what we will build....

    In your kernel source open a terminal and type this: sudo build_kernel.sh G920T press enter. It should look like this...

    Screenshot_2016-07-31_13-51-14_zpswpbtizy8.png


    Once you type your password and hit enter it should look like these.....

    Screenshot_2016-07-31_13-55-21_zpsjqg0cp2g.png

    Screenshot_2016-07-31_13-55-34_zps4fk7qt4l.png

    Screenshot_2016-07-31_13-55-48_zpsykmd1g5s.png

    Screenshot_2016-07-31_13-56-05_zpselc2fgog.png


    Now for the G920F build.......all you need to do is change the names in your env_setup.sh. Where it says G920T you change to G920F.
    Same goes for any S6 device. Just change the name in the file.
    Also make sure the name of your config file matches in both the env_setup.sh and in arch/arm64/configs.......

    AT THE END OF THE BUILD YOU WILL BE ASKED TO USE s=stock or c=custom DT.IMG........SELECT S!!!!

    NOW YOU HAVE BUILT IT......NOW WHAT.....

    If you have followed along you will have made sure the output folder in your source has the device name you were compiling. Look in that folder,
    and there will be a flashable zip as well as a tar file for Odin.

    Well folks, that about covers it. In post #2 I will show you how to cherry-pick commits and fix simple HEAD errors. If anyone has issues or is
    lost please post the problem and I will help you the best I can.......


    I dont think I missed anything. If I did we will address it when the time comes. Remember, this is a guide to get you started. I suggest you try to use
    Google to find other kernel threads that has building information and so on.......

    A special thanks to the following folks:
    Especially to my bro @ShinySide for getting me starting in the kernel bizz
    @halaszk for his awesome build script
    @UpInTheAir for various code source and BUILD SCRIPTS
    And of course.....ME

    Telegram Invite
    https://telegram.me/joinchat/DnmUJwsL2XJPvYYSezOnfA

    XDA:DevDB Information
    How to build a Samsung Kernel, Kernel for the Samsung Galaxy S6

    Contributors
    The Sickness
    Kernel Special Features:

    Version Information
    Status: Stable

    Created 2016-08-02
    Last Updated 2016-08-01
    26
    HOW TO CHERRY PICK COMMITS

    This part of the guide isnt really that hard to understand. You just need to make sure what you pick will work on your kernel......I advise for you
    to pick from the same device. If your building for the G920T, you need to pick from the S6.....Please note that it doesnt matter if the commit is
    2 weeks old or 2 years. In another words, firmware isnt a factor. Your stock source is what is from the latest firmware. The kernel code is many
    years old....its just improved over time. So lets get started......

    First question.....where would you cherry pick from? Well Github is the answer. So to make this easy will will use my Twisted Kernel source.
    Go to here. Now in your kernel source open a terminal.....
    What we need to do is "fetch" my source......its a remote hook up you might say. So on the web page click the green tab that says
    Clone or download, then click on the clipboard icon.......go to your terminal and type: git fetch (paste url you just copied), hit enter. It will set
    up a remote hook. Once its done you can pick any or all of my commits.

    A point to remember, you ALWAYS pick from the oldest to newest, unless you commit each pick you make. So, let me show you how. On the Github page
    on the left side it says 388 commits, select it. It will now bring up all the commits. Scroll to the bottom of the page and select older.....keep doing that until
    you reach the end.....so you should be here......

    Screenshot_2016-07-31_20-31-12_zpser2mw0dq.png


    Now, what you really need to do is read the commit BEFORE you pick it. Most have a description, and some dont. But, everyone wants a "permissive" kernel.
    So, the commit that says Set kernel to "permissive" is our first one. To the far right of the commit is a clipboard icon, click it......now in your terminal
    type: git cherry-pick (paste from the clipboard) then hit enter. It will look like this when its done

    Screenshot_2016-07-31_20-41-55_zpsyuw4bjlz.png


    Now we need to commit the cherry-pick we just made. So in your terminal type: git push origin master......then your username, then your password.
    When its done it will look like this

    Screenshot_2016-07-31_20-45-58_zpszlmxvtpl.png


    Now, lets say you made a cherry-pick and you get this error.......

    Screenshot_2016-07-31_20-55-46_zps9ulmj0xd.png


    When you get this error there is a problem with the commit. So in your terminal type: git status.......and it will look like this after

    Screenshot_2016-07-31_20-59-03_zpspfwousnv.png


    So what we need to do is find out what the issue is. 99.9% of the time its a "HEAD" issue......which is the case here. So, go to block/Kconfig.iosched...thats the first issue.
    Open it with your text editor. Look at line 35, 36, and 119. Those NEED to be deleted

    Screenshot_2016-08-01_19-01-58_zpssxorjmwy.png


    Now go to block/Makefile... you can see here that you need to delete lines 18, 19, and 28.
    Screenshot_2016-08-01_19-07-29_zpsrmslotxg.png


    Now once you have fixed those errors you need to commit it. To do that you need to copy the folder location like this.....

    Screenshot_2016-08-01_19-31-46_zpsmla7foc9.png


    Then once you have it copied you will need to type: git add (paste it here)...then it will look like this

    Screenshot_2016-08-01_19-35-57_zps6thsgb5b.png


    Now do the same to the other...it will look like this

    Screenshot_2016-08-01_19-39-31_zpsfbbcedrr.png


    Now we need to commit those changes. Type: git commit.........it will look like this

    Screenshot_2016-08-02_03-33-29_zpskkff5vre.png


    Now you will notice that the commit message is already there....so there is no need to change it. So now we need to commit. To do that
    you need to select Ctlr+o.........then enter.........Ctlr+x...............and it will look like this

    Screenshot_2016-08-02_04-24-53.png


    Then in your terminal type: git push origin master........then your username..then your password. Then take a look at your Github
    page and you will see the commit appear.

    That covers basic cherry-pick..........
    17
    How to use Mkboot to edit your ramdisk

    Here will will learn how to use mkboot to do many things...... The first thing we need to do is clone mkboot.img from Github. So you need to go
    here. Now open a terminal in your home folder and "clone" the source.....it should look like this

    Screenshot_2016-08-04_17-51-21_zpsrkcvzct9.png


    Then when you open the folder it should look like this

    Screenshot_2016-08-04_17-51-54_zpstkz9whui.png


    Now, you need to place your stock boot.img into the folder. Its up to you to get your boot.img from your device firmware. I cant do
    everything for you...lol. Drop the boot.img in like this

    Screenshot_2016-08-04_18-15-54_zpsymrdlief.png


    Now, in the mkbootimg_tools folder you need to open a terminal and type: ./mkboot boot.img unpacked......hit enter. Looks like this

    Screenshot_2016-08-04_18-29-47_zpskrok2exn.png


    When its done unpacking the boot.img it will look like this

    Screenshot_2016-08-04_18-30-03_zpsd1sklsak.png

    Screenshot_2016-08-04_18-30-15_zpsp8cxkcq3.png


    Now, for all non T-Mobile users.........

    In your kernel source you need to go to your build_kernel folder. Now "make" a folder of your device IE: G920F......G920I...etc
    Once you have this folder made you need to take the ramdisk, dt.img, and img_info from the unpacked folder in mkboot_tools and
    place them in the new folder you just created in build_kernel...like this

    url]


    Now your ready to build....
    7
    Well folks, this is goodbye. I have decided to stop developing across the board.

    It's been a fun ride for the past few years. But I'm moving on to other things. I want to thank everyone who has supported me since the S3.

    Especially @bx10r and @slickrick.....

    Take care.....peace
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone