[ACS][DEV][TUTORIAL] How to Build A Custom Kernel for the Samsung Epic 4G Touch

Status
Not open for further replies.
Search This thread

bubby323

Senior Member
Jul 31, 2010
1,636
1,468
Michigan City, IN
How to Build a Kernel for the Samsung Epic 4G Touch

So you want to learn how to build a kernel? I guess you've more than likely come to the right place considering that's what the title has led you to believe, so why don't we get started?

As with all things worth doing, this is going to take a little time, and a little patience. If you don't get everything on the first try just go back and pick up where you left off. I'm 15. I started out the same way you did, all of us developers did. You can do it, it just takes practice and effort.

Prerequisites

First off, your going to need some sort of Linux distribution installed on your hard drive or running in a virtual machine. I personally prefer Ubuntu for it's user friendliness and easy learning curve but there are more bare distros out there you can mess around with. A mac might also work as well, but having never owned one I can't say for sure.

Setting up your build environment.

Once you have made sure you have a Linux distribution up and running (er..Mac) you can head on over to this link and download SPH-D710-Build-A-Kernel.zip. This zip archive includes everything you are going to need, even an automatic building script I was nice enough to provide for your building pleasure.

You are going to want to extract the contents of this zip compression archive to your home folder, like so.

extract-to-home-folder.png


Breakdown of contents.

Let's take a look at what is included in the contents we just extracted, shall we?

Code:
kernel
--source
--initramfs
----stock
--toolchain

build.sh

contents-kernel.png


Inside the folder labeled kernel we have the folders source, initramfs, and toolchain. Let's break this down and explain what each is and what it means when compiling a kernel.

Source.

The kernel source is included in the source folder (duh..). This includes everything that is used to compile the kernel itself. These files are provided by Samsung after every update we get on our phones. So it's always a good idea to pay attention to when updates are released and then to check for kernel source updates at the Open Source Samsung website.

I plan to keep this all updated as soon as the source drops for updates as well if you don't feel comfortable updating it yourself.

Initramfs.

Moving on we have the initramfs folder. The initramfs of a kernel is like the insides of a human. It tells the kernel what to do, it's the brains of the whole operation. This is really where all the customization takes place and things like root and Clockworkmod Recovery are added. More on this all later in the tutorial.

Stock initramfs.

What we have currently in this folder is another sub-folder dubbed stock. This included the stock initramfs that I was able to pull from the kernel I grabbed from a stock Epic Touch. By building a kernel with this initramfs we are building a completely stock kernel.

As with every kernel however, unless it is custom signed by Samsung then the yellow triangle will occur on boot. That is unless you use a usb jig to rid yourself of this problem.

Toolchain.

Lastly, we have the toolchain folder. The toolchain is what is used to actually compile the kernel using the source.

In software, a toolchain is the set of programming tools that are used to create a product.

Custom build script.


Going back to our home directory (remember: the directory we extracting everything to), we have build.sh.

Me being the nice person that I am, I have included a custom build script so you don't have to manually have to type in commands in Terminal, that is what build.sh is. Double clicking it will reveal a prompt asking you what you wish to do, since we want to build the kernel we should probably select 'Run in Terminal'.

run-in-terminal.png


Once we do choose to actually click the 'Run in Terminal' option in the prompt we will be presented with...well, a Terminal that is running our custom build script. This script does alot of things without much effort, just a few button clicks, on your part.

running-in-terminal.png


It sets the path for the toolchain and the initramfs, something that we normally have to do manually, and it also takes the time to compile the kernel, pull the compiled modules, copy them to the initramfs, and recompile the kernel again. Afterwards, the compile zImage (kernel) is copied to the Desktop and automagically created into a .tar archive for flashing immediately via Odin.

tar-on-desktop.png


Profit!

Bam! You've created your very first [stock] kernel.

Give yourself a pat on the back for being able to follow directions and be patient.

Flashing.

Once you've flashed your custom kernel you can flash it on your phone head on over to Settings and then to About Phone and find some interesting information under kernel that is sure to make you smile.

Part II coming very soon to a second post near you.
 

Attachments

  • SPH-D710_Kernel_Gingerbread.tar
    5.5 MB · Views: 138
Last edited:

marcosowns

Member
Aug 22, 2007
31
0
Thanks Bubby! This is exactly what I have been looking for... especially the build script. Now I don't have an excuse for being lazy, it's time to wipe off the dust from my old linux box!
 

Econ212

Member
Feb 16, 2011
46
7
Thank you Bubby! This is awesome, I'm pretty excited I've always wanted to play around with Android, I think this will be a great place to start! I just installed Ubuntu on my work laptop, probably a ****ty idea but wth. Looking forward to the later posts!


PS Can we get this Stickied?
 
Last edited:

deano0714

Senior Member
Sep 9, 2010
1,766
356
OMG>>>>>>>> you rock. iv been looking all over for this and could never find anything for a samsung phone. they were all htc.......

Wheres the donate button? you have a KEG coming your way. THANK YOU.
A keg of juice ;) hes 15 lol... So am i :)... Thanks bubby for this :)


Sent from my SPH-D710 using XDA App
 

MoMatt

Senior Member
Oct 31, 2010
99
27
Wow. I'm impressed. The sky is the limit for you. The way you conduct yourself on these forums is incredibly professional, responsible and void of any childish behavior that people twice your age get wrapped up in.

Thanks and keep up the great work! I look forward to the rest of the guide. Every couple of years I get an install of Linux going to play around with; I think I've just found a reason to try it out again!

Sent from my SPH-D710 using XDA App
 

amoricaorbust

Senior Member
Jun 28, 2010
64
0
Austin, TX
This is awesome! Personally I probably won't ever make my own kernel but I appreciate the knowledge. Does anyone know if there is a custom rom tutorial guide?
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 31
    How to Build a Kernel for the Samsung Epic 4G Touch

    So you want to learn how to build a kernel? I guess you've more than likely come to the right place considering that's what the title has led you to believe, so why don't we get started?

    As with all things worth doing, this is going to take a little time, and a little patience. If you don't get everything on the first try just go back and pick up where you left off. I'm 15. I started out the same way you did, all of us developers did. You can do it, it just takes practice and effort.

    Prerequisites

    First off, your going to need some sort of Linux distribution installed on your hard drive or running in a virtual machine. I personally prefer Ubuntu for it's user friendliness and easy learning curve but there are more bare distros out there you can mess around with. A mac might also work as well, but having never owned one I can't say for sure.

    Setting up your build environment.

    Once you have made sure you have a Linux distribution up and running (er..Mac) you can head on over to this link and download SPH-D710-Build-A-Kernel.zip. This zip archive includes everything you are going to need, even an automatic building script I was nice enough to provide for your building pleasure.

    You are going to want to extract the contents of this zip compression archive to your home folder, like so.

    extract-to-home-folder.png


    Breakdown of contents.

    Let's take a look at what is included in the contents we just extracted, shall we?

    Code:
    kernel
    --source
    --initramfs
    ----stock
    --toolchain
    
    build.sh

    contents-kernel.png


    Inside the folder labeled kernel we have the folders source, initramfs, and toolchain. Let's break this down and explain what each is and what it means when compiling a kernel.

    Source.

    The kernel source is included in the source folder (duh..). This includes everything that is used to compile the kernel itself. These files are provided by Samsung after every update we get on our phones. So it's always a good idea to pay attention to when updates are released and then to check for kernel source updates at the Open Source Samsung website.

    I plan to keep this all updated as soon as the source drops for updates as well if you don't feel comfortable updating it yourself.

    Initramfs.

    Moving on we have the initramfs folder. The initramfs of a kernel is like the insides of a human. It tells the kernel what to do, it's the brains of the whole operation. This is really where all the customization takes place and things like root and Clockworkmod Recovery are added. More on this all later in the tutorial.

    Stock initramfs.

    What we have currently in this folder is another sub-folder dubbed stock. This included the stock initramfs that I was able to pull from the kernel I grabbed from a stock Epic Touch. By building a kernel with this initramfs we are building a completely stock kernel.

    As with every kernel however, unless it is custom signed by Samsung then the yellow triangle will occur on boot. That is unless you use a usb jig to rid yourself of this problem.

    Toolchain.

    Lastly, we have the toolchain folder. The toolchain is what is used to actually compile the kernel using the source.

    In software, a toolchain is the set of programming tools that are used to create a product.

    Custom build script.


    Going back to our home directory (remember: the directory we extracting everything to), we have build.sh.

    Me being the nice person that I am, I have included a custom build script so you don't have to manually have to type in commands in Terminal, that is what build.sh is. Double clicking it will reveal a prompt asking you what you wish to do, since we want to build the kernel we should probably select 'Run in Terminal'.

    run-in-terminal.png


    Once we do choose to actually click the 'Run in Terminal' option in the prompt we will be presented with...well, a Terminal that is running our custom build script. This script does alot of things without much effort, just a few button clicks, on your part.

    running-in-terminal.png


    It sets the path for the toolchain and the initramfs, something that we normally have to do manually, and it also takes the time to compile the kernel, pull the compiled modules, copy them to the initramfs, and recompile the kernel again. Afterwards, the compile zImage (kernel) is copied to the Desktop and automagically created into a .tar archive for flashing immediately via Odin.

    tar-on-desktop.png


    Profit!

    Bam! You've created your very first [stock] kernel.

    Give yourself a pat on the back for being able to follow directions and be patient.

    Flashing.

    Once you've flashed your custom kernel you can flash it on your phone head on over to Settings and then to About Phone and find some interesting information under kernel that is sure to make you smile.

    Part II coming very soon to a second post near you.
    6
    Part III: Being creative within the initramfs.
    6
    Part IV: Messing around with the source.
    4
    Part II: What does the build script actually do?
    4
    Part V: A conclusion to a story that just began.