Hey, Guys
Today I'm going to show you a nice tutorial on how to compile your own android kernel from source, this tutorial will be a little bit focused on Sony devices as i had an experience with 'em, but that is not going to prevent that this way can be good for other manufacturers as all of them are Android based (Same programing language)
I have included screenshots and examples of codes to accompany each step of the way. :good:
On XDA Portal:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Chapters:
1.Installing Ubuntu (Alongside with Windows OS)
2.Downloading the source code
3.Installing libraries
4.Preparing the toolchain
5.Adding Features to the Kernel
6.Compiling
7.Trying out your kernel
8.Additional Tips
Click to expand...
Click to collapse
Requirments:
Ubuntu 12.04 LTS or Newer
Manufacturer sources (Links located down for most of the manufacturers)
Linaro Toolchain
Simple background about executing Linux terminals
Click to expand...
Click to collapse
1.Installing Ubuntu
As we all know, Ubuntu is free open source OS that allows you to use it alongside your already installed OS without any problems, you will be promoted at every startup to choose whether your Default OS or Ubuntu OS
So, don't get freaked guys no partitions are going to be formatted or no data loss is going to happen at all.
1)Get the Ubuntu ISO
Go to Ubuntu site (Downloads section)
Choose whether you are on 32-bit or 64-bit (We'll be assuming that we are on 32-bit)
Download the ISO then burn the ISO to DVD then boot it (or you can write install your ubuntu via usb by using this tutorial
Choose "install Ubuntu alongside your windows OS version"
Manage the partitions yourself
You got your Ubuntu ready. Time for some business
2.Downloading the Source Code
Motorola: opensource.motorola.com/
LG: http://opensource.lge.com/osList/list?m=Mc001&s=Sc002
Huawei: http://emui.huawei.com/en/plugin.php?id=hwdownload
Sony: http://developer.sonymobile.com/downloads/xperia-open-source-archives/
HTC: http://www.htcdev.com/
Samsung: http://opensource.samsung.com/
Download the TAR Source file that suits your firmware version for e.g (11.2.A.0.31)
To find your firmware version go to settings then about phone. You will see your firmware version there
Reserved
3.Installing Libraries and Preparing the Environment
As you know guys there are several libraries needed for any software to terminate properly so, if you want to succeed in compiling you have to get these libraries that we're gonna write through the Linux terminal
1)Open the Linux Terminal
2)Write these commands
Code:
sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2
Code:
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
Code:
mkdir android
3)Copy the source code archive into the folder android (that has been created throughout the “mkdir android” command
4)Run these commands
Code:
cd android
Code:
tar -xjvf [COLOR="DarkSlateBlue"]Source Name[/COLOR]
Replace Source Name with the Archive name
4.Preparing the toolchain
(You should download the whole toolchain of DoomLord, But to save our time I decided not to download the whole toolchain since that we're going to use only one folder of it)
The folder will be: arm-eabi-4.33 (Took from Linaro 4.6) (So you can consider your kernel is compiled using Linaro 4.6
Download arm-eabi-4.4.3
and extract it in the root of your home
And if you want to download the whole source run these commands
Code:
cd android
Code:
cd kernel
Code:
git clone git://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains
Reserved
5.Adding Features to the Kernel
A)Automatic Way (Using the toolchain menu)
Code:
cd android
Code:
cd kernel
Code:
ARCH=arm CROSS_COMPILE=~/arm-eabi-4.4.3/bin/arm-eabi- make Device Name
Code:
make ARCH=arm CROSS_COMPILE=~/arm-eabi-4.4.3/bin/arm-eabi- menuconfig
Replace Device Name with the configuration file found at:
Source/arch/arm/configs
It's written in this way something_DeviceCodename_user_defconfig
A menu like this will appear
Choose the features you want.
B)Manual Way
1)Adding Governors
The CPU is just 1 C file (Can be found at sources of any of kernel developers)
Get the Governor file
1.1 If you cant get it through github just view it and use other stock governor file like this
my kernel has already got performance governor, you are going to take it from Kernel Source/drivers/cpufreq/cpufreq_performance.c
Copy cpufreq_performance.c from kernel source to desktop then open it with text editor
delete all the lines in it then copy the lines from the viewed governor on github and rename the whole file name
1.2
Copy the governor C file to KernelSource/drivers/cpufreq and paste it
Open Kconfig
Then Add these lines with proper replacment
Code:
config CPU_FREQ_GOV_GOVNAMEHERE
tristate "'gov_name_lowercase' cpufreq governor"
depends on CPU_FREQ
help
governor' - a custom governor!
For BadAss (For Example)
Code:
config CPU_FREQ_DEFAULT_GOV_BADASS
bool "badass"
select CPU_FREQ_GOV_BADASS
help
Use the CPUFreq governor 'BADASS' as default
Find endchoice
Add these lines below it
Code:
config CPU_FREQ_GOV_BADASS
tristate "'badass' cpufreq governor"
depends on CPU_FREQ
help
'badass' - This driver adds a dynamic cpufreq policy governor.
The governor does a periodic polling and
changes frequency based on the CPU utilization.
The support for this governor depends on CPU capability to
do fast frequency switching (i.e, very low latency frequency
transitions).
If in doubt, say N.
1.3
Open Makefile
Add the line according to the Governor
HTML:
obj-$(CONFIG_CPU_FREQ_GOV_BADASS) += cpufreq_badass.o
1.4
Open Kernel Source/include/linux.* now open cpufreq.h
Add these lines (With Proper Replacments)
Code:
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_badass)
extern struct cpufreq_governor cpufreq_gov_badass;
#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_badass)
2)Adding I/O Schedulers
Get the I/O .c file as the same way you got the Governor File
Paste it to Kernel Source/block
2.1
Now Open Kconfig.iosched
Let's Assume that we now see SIO
HTML:
config IOSCHED_SIO
tristate "Simple I/O scheduler"
default y
---help---
The Simple I/O scheduler is an extremely simple scheduler,
based on noop and deadline, that relies on deadlines to
ensure fairness. The algorithm does not do any sorting but
basic merging, trying to keep a minimum overhead. It is aimed
mainly for aleatory access devices (eg: flash devices).
And we will add the I/O Scheduler VR Below it like:
We will put VR below it
HTML:
config IOSCHED_VR
tristate "V(R) I/O scheduler"
default y
---help---
Requests are chosen according to SSTF with a penalty of rev_penalty
for switching head direction.
Let's assume that we saw SIO (But in different way)
config DEFAULT_SIO
Code:
bool "sio" if IOSCHED_SIO=y
We will put VR below it
Code:
config DEFAULT_VR
bool "V(R)" if IOSCHED_VR=y
Let's assume that we saw SIO (But in another different way)
Code:
default "sio" if DEFAULT_SIO
We will put VR below it
Code:
default "vr" if DEFAULT_VR
2.2
Open the Makefile at the same folder
Lets Assume that we saw SIO And we will put VR below it
Code:
obj-$(CONFIG_IOSCHED_SIO) += sio-iosched.o
Add VR Now
Code:
[obj-$(CONFIG_IOSCHED_VR) += vr-iosched.o
Done We have added the VR I/O Scheduler !
3)Overclocking
Unfortunately, overclocking can't be told the way i said the Governors and I/O Schedulers way because every device has its specific CPU frequencies
But, here is a little help
Go to KernelSource/arch/arm/mach-msm/acpuclock-XxXX.c
You will find files like these
acpuclock-7x30.c
acpuclock-8x50.c
You will see each one of them has only .c file
except one which will have .c and .o file
the one with both .c and .o files will be edited
Explanation will be added as soon as possible
Last
6.Compiling
Part.A
Code:
cd android
Code:
cd kernel
Code:
export ARCH=arm
Code:
export CROSS_COMPILE=~/android/kernel/arm-eabi-4.4.3/bin/arm-eabi-
Part.B (Wanna do some modifications ?)
Code:
make <your_config_name>_defconfig
Replace <your_config_name> with the one found at Source/arch/arm/configs
Code:
make menuconfig
Code:
make -j<cpucore>
Replace <cpucore> with the number of cpu cores that the device has if you are on single core write 1 and if you are on dual core write 2[
Quad core=4
Octa core=8
Part.C
Code:
make clean
Code:
make oldconfig
Code:
make -j<cpucore>
Same as before.
7.Trying out your kernel
Once you have got an output which will be kernel.elf
You have now to try it
Flash it using fastboot
Whether CMD or Androxyde Flashtool
You will have to install your fastboot drivers in both ways
CMD way
Code:
fastboot -i 0x0fce flash boot kernel.elf
Using Androxyde Flashtool (XPERIA Only)
Download it from here
Install the drivers found at (C:/Flashtool/drivers/Flashtool-drivers.exe)
Press on the thunder button above
Then Choose Fastboot mode
Connect your device in fastboot
After that choose the kernel output (.ELF)
Wanna my help fast ?
Mention me or PM me
8.Additional Tips
*To find the number of cores of your CPU, just open terminal and type the following:
Code:
cd android
cd kernel
cat /proc/cpuinfo
You will find the number of cores of CPU in a tag called "cpu cores" (Great Thanks to @#buzz)
*Some other useful packages from apt-get, especially on newer Qualcomm devices. (Might help you if you want to compile whole AOSP ROMs from source)
Code:
sudo apt-get install liblz4-dev liblz4-tool lzop device-tree-compiler
(Thanks bro @savoca)
Android & GPL
Once you have done your kernel and of course you used some parts from past kernel developers, you will also have to give your sources to other people "This which is called GPL Licence"
So, the best way for this process is "GIthub"
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
Credits @TheWizardOfROMs @thewadegeek @DooMLoRD @SatrioDwiPrabowo @Haze028 @abcdjdj
XDA Universty
Good tutorial ! :good::good::good:
DanielFlorin said:
Good tutorial ! :good::good::good:
Click to expand...
Click to collapse
@DanielFlorin
Thanks Bro.
Step 7 just for Sony Xperia Tamsui device like Miro , J , E , Tipo this is different with an other Xperia device so please justify and one more don't re-upload / mirror my files please use original link on my github thanks ....
Truly amazing and descriptive guide. Was thinking about making my own kernel from source just the other day and now this is up!
Nice guide well done:good:
Hi,
Great tutorial. I'm going to try it for my device!
Kernel has more than just I/O, schedulers and governers.
Are you going to expand the tutorial gradually i.e. explain other features? (Would be great if Yes)
Very good . subscribed
Nikhil said:
Hi,
Great tutorial. I'm going to try it for my device!
Kernel has more than just I/O, schedulers and governers.
Are you going to expand the tutorial gradually i.e. explain other features? (Would be great if Yes)
Click to expand...
Click to collapse
Of course bro, but the problem that for now i'm studying but if you need any thing go ahead and message me.
Dilesh Perera said:
Very good . subscribed
Click to expand...
Click to collapse
Thanks very much..... :laugh:
Thanks very much my bro......
Your comment made me really happy ^^
:thumbup:
Sent from my ST26i using XDA Free mobile app
What a coincidence!!
Eliminator79 said:
XDA Universty
Click to expand...
Click to collapse
I don't know whether it a coincidence or not but I have exactly the same wallpaper applied on to my Ubuntu 14.04 x64 bit operating system also with dual boot of Windows 7 Ultimate along side Ubuntu.
Also the second coincidence is, I made the same tutorial on building kernel except for the fact that it is for building linux kernel rather than an android kernel.
Anyway, Good Job! :good:
---------- Post added at 07:13 AM ---------- Previous post was at 07:03 AM ----------
Eliminator79 said:
Code:
make -j<cpucore>"
Replace <cpucore> with the number of cpu cores that the device has if you are on single core write 1 and if you are on dual core write 2
Click to expand...
Click to collapse
To find the number of cores of your CPU, just open terminal and type the following:
Code:
cat /proc/cpuinfo
You will find the number of cores of CPU in a tag called "cpu cores"
Hope that helps.
@Eliminator79 You can add this to your guide.
Eliminator79 said:
3.Installing Libraries and Preparing the Environment
As you know guys there are several libraries needed for any software to be successful so if you want to succeed in compilng you have to get the libraries that i'm going to write through the Linux Terminal
1)Open the Linux Terminal
2)Write these commands
Code:
sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2
Click to expand...
Click to collapse
Some other useful packages from apt-get, especially on newer qcom devices.
Code:
sudo apt-get install liblz4-dev liblz4-tool lzop device-tree-compiler
#buzz said:
To find the number of cores of your CPU, just open terminal and type the following:
Code:
cat /proc/cpuinfo
You will find the number of cores of CPU in a tag called "cpu cores"
Hope that helps.
@Eliminator79 You can add this to your guide.
Click to expand...
Click to collapse
Code:
make -j$(grep -c ^processor /proc/cpuinfo)
^ Works as well, and it's universal.
Wow, I was always curious how people do it. Thanks a lot man.
Nikhil said:
Hi,
Great tutorial. I'm going to try it for my device!
Kernel has more than just I/O, schedulers and governers.
Are you going to expand the tutorial gradually i.e. explain other features? (Would be great if Yes)
Click to expand...
Click to collapse
+1
Thanks a lot!
You got me what I wanted! :victory:
savoca said:
Some other useful packages from apt-get, especially on newer qcom devices.
Code:
sudo apt-get install liblz4-dev liblz4-tool lzop device-tree-compiler
Code:
make -j$(grep -c ^processor /proc/cpuinfo)
^ Works as well, and it's universal.
Click to expand...
Click to collapse
@savoca Thanks so much dude.
Do you give me permisssions to add these tips to the post ?
You motivated me alot bro...Thanks
DarkFalcon said:
Thanks a lot!
You got me what I wanted! :victory:
Click to expand...
Click to collapse
Anytime bro
#buzz said:
I don't know whether it a coincidence or not but I have exactly the same wallpaper applied on to my Ubuntu 14.04 x64 bit operating system also with dual boot of Windows 7 Ultimate along side Ubuntu.
Also the second coincidence is, I made the same tutorial on building kernel except for the fact that it is for building linux kernel rather than an android kernel.
Anyway, Good Job! :good:
---------- Post added at 07:13 AM ---------- Previous post was at 07:03 AM ----------
To find the number of cores of your CPU, just open terminal and type the following:
Code:
cat /proc/cpuinfo
You will find the number of cores of CPU in a tag called "cpu cores"
Hope that helps.
@Eliminator79 You can add this to your guide.
Click to expand...
Click to collapse
Related
~~~~~ Latest release
A500 - V1.0.1 (first stable release)[Size=+1]
ezT20-v1.0.1-a500_S.zip
MD5: 73e25f9970dc5f34d863a2c7155968d2
[/SIZE]
**Please remove all undervolting and overclocking before installing, as different kernels will use the CPU differently, This may require you thus to change the OC/UV levels to be stable with this kernel.
While plenty of work has gone into ensuring this kernel was fit for use: I take no responsibility for any problem the use of this kernel may cause, and/or loss of data if you fail to backup your data before installing it. Proceed at your own risk
Notice: This kernel will only operate on an unlocked ICS bootloader, for the a500 this is the patched bootloader
A500 Installation: : simply flash the zip from recovery, this will extract and replace the zImage (linux kernel) from your current rom; and leave your existing ramdisk unchanged.
A501 Installation: :Your ICS rom requires to load the new simdetect_switch.ko module on boot, if your rom dose not have support for this, but has support for init.d scripts please first install the patchkit ezT20_a501_patchkit_S.zip MD5: 617f558555c13d215103cd3669d3c009, (This kit only includes the init.d script to load the simdetect_switch module if it exists, and doesn’t include the actual kernel or modules)
After the patch kit is installed (or if it has been previously installed/is part of your rom) you can flash the a500 zip above to install the kernel + related modules.
CM (9 and 10) installation Install per your device above, then install the audio patch init.d scripif you have audio problems: ezT20cmaudio_patch_S.zip MD5: 26251900115b0ca433f26f4d95e7f269 (see this post for more information)
Are you an A100 user? you are in the wrong place see here
~~~~~ ICS Kernel Features
- BFQ IO scheduler (details here)
(BFQ is now the default scheduler, previously was noop)
- Lulzactive CPU governor (by tegrak with a500 modifications by myself)
(Interactive will be the default governor for most roms, as defined on the ramdisk, however lulzactive is recommended)
- Max OC speed: 1504MHz (default 1000MHz)
- Min OC speed: 216MHz (default 216MHz)
- Fixed voltage tables to allow OC on devices previously unable to on A500-OCTestV3 and A100-OCTestV1
- initial 3g support thanks to patches from Vash (v1.0.0 - a501) .. switched to acer's code in v1.0.1 (a501/a101)
- ability to disable acer audio settings (v1.0.1)
~~~~~ Kernel Notes/Warnings
** A specialized lulzactive configuration program can be found at: https://play.google.com/store/apps/...1bGwsMSwxLDMsImNvbS50ZWdyYWsubHVsemFjdGl2ZSJd
(note setCPU will also let you change the values, I only mention tegrak's app as it may make it easier to understand what is being changed)
** The kernel ought to work in place of the stock ICS kernel, roms requiring special kernels may not function with this kernel
** de-odexed roms may have graphical artifacts that are made more serious by this kernel, civato and I have been working on a build.prop tweak to re-generate odex like dex files on de-odexed roms to solve this
** Voltage display may not be accurate (a rework of the UV logic is planned) note UV offsets are accurate.
The following is using the following:
* My Near stock rom
* My disk-io tweak for the rom
* lulzactive Min: 216 Max 1504
* BFQ scheduler
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
~~~~~ Kernel History
This kernel is the continuation of the Overclocked Test kernel, originally posted for the A500 here and subsequently for the A100 here
~~~~~ Credits
Thanks to:
* richardtrip - original OC and MIN/MAX code
* tegrak - for lulzactive
* civato - for being a willing advanced tester
* Bobg1231, Metallkasten, pio_masaki, Moscow Desire - additional testers
* Vash - A501 3g modem patch set
* Acer/NVidia for providing the source to our devices
* The countless number of people that have created the linux kernel in the form it is today
~~~~~ Release Build list w/ source links
v1.0.1 ezT20-v1.0.1-a500_S.zip
MD5: 73e25f9970dc5f34d863a2c7155968d2
Github: https://github.com/ezterry/AcerTabKernel
Tag: ezT20_kernel_v1.0.1
Tarball: https://github.com/ezterry/AcerTabKernel/tarball/ezT20_kernel_v1.0.1
v1.0.0 ezT20-v1.0.0-a500_S.zip
MD5: 007f00e576bf82f9439f9567685dd255
Github: https://github.com/ezterry/AcerTabKernel
Tag: ezT20_kernel_v1.0.0
Tarball: https://github.com/ezterry/AcerTabKernel/tarball/ezT20_kernel_v1.0.0
NET-USB modules [Experimental] for this version: http://forum.xda-developers.com/showpost.php?p=27887611&postcount=52
v0.9.9 ezT20-v0.9.9-a500_S.zip
MD5: c43844babbd96ab43399a100d74d60de
Github: https://github.com/ezterry/AcerTabKernel
Tag: ezT20_kernel_v0.9.9
Tarball: https://github.com/ezterry/AcerTabKernel/tarball/ezT20_kernel_v0.9.9
~~~~~ Change Log
v1.0.1
*) Import of acer's 3g code [A101 and A501]
*) audio updates to better work with CM roms when cm audio patch is applied ezT20cmaudio_patch_S.zip MD5: 26251900115b0ca433f26f4d95e7f269
*) Allow lower min-voltage
v1.0.0
*) cleanup graphics logic with more patches from the nvidia tegra test kernel (and other patches to prevent the graphic under-runs causing screen flashes on some roms) [applies to all devices]
*) modify lulzactive (yet again) to attempt to stem a rare deadlock .. frequently resulting in a SoD overnight on my tab (probably not most peoples constant SoD problem) [applies to all devices]
*) Add Acer A501 patches for 3g modem [applies to A501]
*) fix some touch events on the A50X caused by the a100 patch set rolling back the a500 touch driver, the touch drivers are separate so this ought not impact the a100 [a50x only]
v0.9.9
Initial release, providing some bugfixes and new features to the previous OCTestV3
**build instructions in second post
Developers Corner
~~~~~ Background
As you may know the linux kernel is considered Free Software under the GPL.
To the creators of the GPL licence this means:
The Free Software Definition said:
“Free software” means software that respects users' freedom and community. Roughly, the users have the freedom to run, copy, distribute, study, change and improve the software. With these freedoms, the users (both individually and collectively) control the program and what it does for them.
Click to expand...
Click to collapse
Full text here
This means when Linus Torvalds changed the licensing from "Non-Comercial" use to the GPLv2 he was no longer preventing the kernel from being used in commercial products (as is obvious by its use on all android devices) However requested that anyone who received a copy of the software, get or be offered a copy of the source as well, and to be allowed to modify that source and distribute those changes to someone else, with the only restriction being they must also provide the source so the next person can also make changes.
Mind you this dosn't mean free software is actually free. Countless hours of hard work by countless people make the kernel what it is today.
While we all must provide the source, if something isn't already in the kernel that you want you have only the following options:
1) find someone willing to make the change
2) pay someone to make the change
3) roll up your sleeves and make the change yourself.
Also note one makes you give away changes you write to the linux kernel, you only must give the source to those who already have the binary.
~~~~~ This Guide
This guide will help you build the kernel yourself on your computer from source, this is in hopes that you may take an interest in how both the build system, and kernel its self works.
Instructions will be primarily focused on both linux, and cygwin users; however osx users may also be able to follow this guide with only minor modifications.
If you do make changes you think the public is interested in I will also be happy to review and potentially include it in my future builds, remember however while its polite to credit me for the codebase provided, you may always distribute you modified versions of the kernel as long as you adhere to providing the source per the GPLv2 to those you distribute it to.
~~~~~ Getting Started - Downloading The Toolchain
The toolchain is the compiler used to convert the 'C' code of the kernel into the arm instructions red by your device.
To build this kernel I use a custom android toolchain based on gcc4.6.3;
Pre-built binaries are available for x86 linux, cygwin, and osx:
1) Download the one for your platform
x86 Linux: toolchain-4.6.3.tar.bz2 (Sha1: c8c57aba6ad92e9acddf29ba
Cygwin: toolchain-4.6.3.cygwin.tar.bz2 (Sha1: 6947e1c1ba95195019f542eb8ba0708667b63eca)
OSX: toolchain-4.6.3.darwin.tar.bz2 (Sha1: 9a977f0672863fdd9501383a6ad1e30723281f
Additional details about these files are on my Android Software post:
http://forum.xda-developers.com/showthread.php?t=1686310
All users may wish to look over the cygwin building requirements there to ensure there system has the required packages.
Other information on the post will include information about retrieving the source to the tool chain its self and another overview of building android kernels in general, and not just this specific Acer kernel.
2) Now that you have the toolchain you want to extract it; this can be done anywere but I recommend for the sake of this guide in your posix home directory
this is done by running at your posix prompt (cygwin terminal in windows normal terminal in linux/osx)
Code:
mkdir -p ~/android
cd ~/android
tar -xjvf </path/to/>toolchain-4.6.3.cygwin.tar.bz2
substitution '</path/to/>toolchain-4.6.3.cygwin.tar.bz2' with the file you downloaded above
all versions will extract then to '~/android/toolchain-4.6.3/' all the files required to build arm binaries
~~~~~ Getting the source code
This can be done many ways, if you want to build a specific version the tarball may be easiest, however it is recommended that you use the git revision control software if you wish to make changes, as this helps keep track of the changes, and publish them on services such as github. (in addition its easier for other people to take the changes into there own work without you loosing credit)
3) To get the AcerTabKernel source change directory into the ~/android directory used to make the toolchain
Code:
cd ~/android
4) run the command to fetch a copy of my git repository
Code:
git clone git://github.com/ezterry/AcerTabKernel.git
5) change into that directory
Code:
cd AcerTabKernel
~~~~~ GIT only, switching code views
Once you have the source code you can always refresh it with git fetch origin, however more work is required to update the local files
Option A: following a branch (recommended if you want the latest source)
6.A.1) run 'git branch -a'
you will likely see the following:
master - you local version of the master branch
remotes/origin/HEAD -> origin/master -- indication master is the default branch
remotes/origin/master -- the remote version of master (as of the last 'git fetch origin' or 'git pull' command)
remotes/origin/tegra_overclock -- the remote version of tegra_overclock (as of the last 'git fetch origin' or 'git pull' command)
the two branchs of interest are as follows:
master - the acer A100/A500 source including my enhancements w/o overclocking support
tegra_overclock - the full enhancement list with overclocking
6.A.2) Create a local version of tegra_overclock
run:
Code:
git branch tegra_overclock origin/tegra_overclock
6.A.3) Switching branches
you can switch between the branches by calling
Code:
git checkout <branch name>
so if you want to build this kernel you will call:
git checkout tegra_overclock
Option B: retrieving a specific tag
6.B.1) If you want the code to a specific kernel you can force the checkout of a tag
Code:
git chekout -f [color=gray]<tagname>[/color]
so for the v0.9.9 you can run
Code:
git checkout -f ezT20_kernel_v0.9.9
This will fetch the code, however you local branches will not be updated if you make changes, see on screen note for details
~~~~~ Building the kernel
Once you have the code you can build the kernel (or make other changes first)
7) Set up your build enviroment
Most steps above need not be done any time you make a change; however every time you want to build from a new terminal you must set up that terminals environment as follows
A) add the toolchan to your path:
Code:
export PATH=$HOME/android/export PATH=$HOME/android/toolchain-4.6.3/bin:$PATH
B) run the following commands to prepare the cross compiler from within the directory with the code (ie 'cd ~/android/AcerTabKernel')
Code:
export ARCH=arm;export CROSS_COMPILE=arm-linux-androideabi-;export KERNEL_DIR=`pwd`
*note I make this one line to make it easier to copy and paste all at once
8) Now that the enviroment is set up we can configure the kernel by running
For A500 Kernels:
Code:
make picasso_defconfig
For A100 Kernels:
Code:
make vangogh_defconfig
This will grab the default configuration for the device (same as /proc/config.gz on the running kernel) in the source tree this is arch/arm/config/picasso_defconfig or arch/arm/config/vangogh_defconfig
9) if you want to change the config (add/remove modules and components or change the kernels name):
Code:
make menuconfig
this will provide the kernel configuraiton gui that allows you to update the many kernel options including adding modules.
10) build the binary kernel
Code:
make -j5
you should replace the 5 in -j5 with the number of CPU cores in your computer + 1. 5 is ideal for a quadcore CPU.
If the number is lower/higher the kernel will take longer to build. (slightly higher however will have minimal impact)
11) prepare the modules (makes sure the modules are ready for use, they are built in the previous step)
Code:
make modules
~~~~~ Packaging the kernel
At this point you can find the kernel in arch/arm/boot/zImage and if you search for files ending in *.ko you will find all the built modules
However here I will describe creating the update.zip installer
Note this may look difficult as the process is mostly manual not automated
12) Download the template (I will assume you are in the directory with the kernel source still)
Code:
wget [url]http://android-git.devnull.name/gh/tepl/acer_kernel_tmpl.tar.bz2[/url]
This template contains the update_binary, unpackbootimg and mkbootimg binaries
In addition it has the ufsd.ko acer stok module (a closed source kernel module used for mounting ntfs disks) the updater-script you will use, and a nfo.prop template
koush is to thank for the unpackbootimg source (unpackbootimg/mkbootimg I built using the A500 Public Recovery source tree, updater_binary is from the stock ICS installer)
13) for future use move the template outside your source directory in case you delete/refresh it
Code:
mv acer_kernel_tmpl.tar.bz2 ~/android/
14) make the update.zip work directory
Code:
tar -xjvf ~/acer_kernel_tmpl.tar.bz2
15) copy over the zImage
Code:
cp arch/arm/boot/zImage acer_kernel_tmpl/[color=gray]<kernel_name.zImage>[/color]
the kernel_name can be any name you wish to call the kernel
16) copy in the modules
Code:
cp `find | grep ko$ | grep -v ufsd` zImage acer_kernel_tmpl/system/lib/modules/
17) copy in modules.order
cp modules.order acer_kernel_tmpl/system/lib/modules/
18) edit the nfo.prop
update the values as per the comments, this will control the displayed output during install
as well as allow you to specify any name for the zImage to be installed without
touching the edify script
19) generate the installer zip
Code:
cd acer_kernel_tmpl
zip -r ../kernel_install.zip .
cd ..
now kernel_install.zip can be flashed from clockworkmod (as an unsigned zip) or you may optionally sign the zip now to publish
~~~~~ What next
What next is up to you, there are many source files to look at some never used for our devices.. and many that I've never looked at.
One important thing however is learning the basics of git revision control, and how to maintain your local mirror and keep it in sync with the version I have on github.
Other interesting git features include remotes allowing you to compare source from other kernel repositories and even cherry-pick individual commits from other users.
If you know how to code, learning this isn't difficult so off to 'git help' and google you go
Hi there Terry - looking forward to giving this a try. Also, thanks for going above-and-beyond on the GPL thing and giving really detailed instructions - I've never compiled for Android in my life so it made interesting reading.
Hey
Can wé flash it with cwm or wé néed es nvflash
Thank s
rayman95 said:
Hey
Can wé flash it with cwm or wé néed es nvflash
Thank s
Click to expand...
Click to collapse
Look what I found in the OP
Installation: simply flash the zip from recovery, this will extract and replace the zImage (linux kernel) from your current rom; and leave your existing ramdisk unchanged.
Click to expand...
Click to collapse
But if you are using it on the flexreaper rom , please use the patch from that thread .
It has got this kernel in it but also the tweaked build.prop.
Read OP of this thread regarding de-odexed roms.
civato said:
Look what I found in the OP
Click to expand...
Click to collapse
To be fair I added that line after reading the question and bashing my head..
(anyway nvflash really has no idea what to do with raw zImage files.. as that is all that is in the zip; the boot.img that needs to be flashed to your device also requires a ramdisk.. as indicated now in the op the update script extracts the one currently installed on your tab to generate a full boot.img with the new kernel)
ezterry said:
To be fair I added that line after reading the question and bashing my head..
Click to expand...
Click to collapse
ssssssssst nobody needs to know
I'll try to make a clean patch for A501 support. For now it's a mess =)
vache said:
I'll try to make a clean patch for A501 support. For now it's a mess =)
Click to expand...
Click to collapse
well if you followed my commits this last week or two.. things didn't quite go as cleanly with any of these other patches as I'd hope either.. (what 5+ commits trying to iron out issues in lulzactive.. it really didn't want to play well with interactive in the same kernel build.. and these are all ones I thought worked.. pushed to github..then needed to edit.. if it didn't work before I pushed to gh I'd have modified the commit)
Anyway looking forward to it as I know some people are interested.
I am curious about the lulzactive governor ... it isn't something pulled out of little finger like smartass governor, right (and full of crap, such as "sleep frequency")?
Skrilax_CZ said:
I am curious about the lulzactive governor ... it isn't something pulled out of little finger like smartass governor, right (and full of crap, such as "sleep frequency")?
Click to expand...
Click to collapse
Smarass and lulzactive are based on googles interactive, and really don't have much more overhead just more tuneing.
Sleep frequency is screen off frequency.. (useful if music is running or a background task to not OC, default is the 800mhz level.. lower is prob not wise since it will only be this high if something needs the cpu..) if your tablet is actually asleep its in suspend to ram mode and the cpu is off.. (at least until a wake lock fires or you push the power button) .. prob the most useful state of this is when I have my computer attached by usb preventing the full sleep.. but the power wire is not.
otherwise its a more tuned version of interactive. Allowing tunable quicker ramp ups or slower ramp downs.. I'm just using my own pre-tuned defaults ... edit: it ought to be noted I've also added a super ramp up if the inc_cpu_load is <91% (default value is 75%) and the current cpu utilization is > (100 -((100-inc_cpu_load)/4)) .. (94% with inc_cpu_load=75%) to ramp to max speed and not the ramp up interval of 2 speed steps (as will still happen if the cpu is between 75% and 93%)
Times in state shows a good balance of speeds as needed, and the device is responsive unlike say on demand.
The biggest problem with all the interactive based governors is how they intercept kernel idle .. pm_idle global hook.. replace the function and call the original.. until you start having more modules being enabled and disabled until the pointer is pointing somewhere random and your system crashes.. switch all of that to a register/unregister system based off the one in x86_64
I see, so just some tune.
ezterry said:
if your tablet is actually asleep its in suspend to ram mode and the cpu is off..
Click to expand...
Click to collapse
Yeah exactly ... that's why I said "full of crap, such as sleep frequency".
SoD issues
EZTerry -
I have gotten SoD with nearly all ICS kernels that have been released, both from Acer OTA and with Flexreaper and yours. The only one that I do NOT get any SoD from is the .022 pre-release one that Civato put up on one of the FR builds a while back. Since you seem to be one of the resident experts on kernels for the A500, do you have any idea what differences exist between the .022 build and the current ones, including your OC ones, that could possibly be contributing to the SoD?
For instance, I loaded the latest FlexReaper Extreme Rev 4 (which uses your latest OC kernel) and got peristent SoDs. I flashed back to the non-OC kernel (to get the normal modules back) and then loaded .022 from a flashable copy I had kept. I haven't had any SoD since. No OC, of course, but at least it's stable...
I saw your post about sending you the logs. Still plan to try that, but for now I'm happy with a working tablet.
BakaNeko59 said:
EZTerry -
I have gotten SoD with nearly all ICS kernels that have been released, both from Acer OTA and with Flexreaper and yours. The only one that I do NOT get any SoD from is the .022 pre-release one that Civato put up on one of the FR builds a while back. Since you seem to be one of the resident experts on kernels for the A500, do you have any idea what differences exist between the .022 build and the current ones, including your OC ones, that could possibly be contributing to the SoD?
For instance, I loaded the latest FlexReaper Extreme Rev 4 (which uses your latest OC kernel) and got peristent SoDs. I flashed back to the non-OC kernel (to get the normal modules back) and then loaded .022 from a flashable copy I had kept. I haven't had any SoD since. No OC, of course, but at least it's stable...
I saw your post about sending you the logs. Still plan to try that, but for now I'm happy with a working tablet.
Click to expand...
Click to collapse
But how is ezterry going to know what is differents or how can he help if he doesn't have a logcat.
If ezterry needs to test every rom situation we need to start paying him for giving us better support then we will ever get from acer.
So please provide logcat.
PS:
f is looking real good m8.
will report to you tomorrow .......
civato said:
But how is ezterry going to know what is differents or how can he help if he doesn't have a logcat.
If ezterry needs to test every rom situation we need to start paying him for giving us better support then we will ever get from acer.
So please provide logcat.
PS:
f is looking real good m8.
will report to you tomorrow .......
Click to expand...
Click to collapse
Well, now that I have a stable working build, I can do a backup and then play with the new kernels to get the logcat. I was just so happy to get a working build that I hadn't considered my next step.
I'll play some more when I get home from work since I can't have my tablet in my office.
You wouldn't care to provide a step by step guide of how to get the logcat info would you? I know it requires adb, but not much else. Also, in another post you mentioned getting the last_kmsg (or last_kmesg - I forget). How do we get that?
Thanks. I appreciate the help.
BakaNeko59 said:
EZTerry -
I have gotten SoD with nearly all ICS kernels that have been released
Click to expand...
Click to collapse
SoD is simple to understand in these terms:
Think of your computer or laptop, you request it to suspend to ram or sleep depending on your OS
It does so, turns into the low power state but is otherwise off, and waits for your return.
When you try to turn the computer on it attempts to wake up but then instead crashes.
This is exactly what is happening, android noted nothing was running and suspended the tablet to ram, either was woken up by you pushing power or a timer the operating system set when it went to sleep.
However before fully starting again the system crashed.
In development of the kernel sometimes I run into such problems with bugs in the oc code, or undervolting too far.. but once I call a kernel stable-ish it can usually last the day with many sleep/wake cycles.. can't say there is never an odd sod but its not common.
The question for you the is: what when wrong.. the easiest way to see is the kernel log of the now crashed kernel.. this requires looking at the /proc/last_kmsg file but this is a little tricky if you needed to force power off the tab (the log is stored in ram thus is completely wiped after 8-10 seconds of the tab being powered off.
When it does exits adb pull can grab the file as soon as the android animation begins.
Sent from my Galaxy Nexus using Tapatalk 2
Does this kernel have cifs module built-in? I can't try by myself right now, my a500 is in vacation at acer's repair facility.
ezterry said:
.
The question for you the is: what when wrong.. the easiest way to see is the kernel log of the now crashed kernel.. this requires looking at the /proc/last_kmsg file but this is a little tricky if you needed to force power off the tab (the log is stored in ram thus is completely wiped after 8-10 seconds of the tab being powered off
Click to expand...
Click to collapse
Does the last_kmsg ONLY exist if there's a fault registered or does it get updated regularly during operation? In other words could I create a continuously running script (for debugging only of course) that copies the last_kmsg file to another location before the system actually crashes? Then when it enters sleep the last file copied would have the information you need? Or is there a way to execute a script early enough in the boot process to copy the file during that first 8-10 seconds of power up so that it is easier to acquire?
Or how about a batch file that simply loops the command "adb pull /proc/last_kmsg last_kmsg" continuously on my PC? If the file doesn't exist it doesn't get copied - if it does exist it gets copied, and if the system crashes and doesn't respond, the last file copied should exist either before or after I manually power off and on the tablet. Hmmmm - guess I'll give it a try...
Sorry - just thinking out loud now
Thanks.
Sent from my A500 using Tapatalk 2
so is it as easy as flashing in CWM over any ics rom?
can i flash this with AOKP??
thank you =]
BakaNeko59 said:
Or is there a way to execute a script early enough in the boot process to copy the file during that first 8-10 seconds of power up so that it is easier to acquire?
Click to expand...
Click to collapse
What do you mean the file is there until reboot if the log data is found, so there is no hurry to pull it off the device.
The logdata is only stored in ram.. so if you power off overnight or while microwaving a frozen dinner.. when you turn the tab back on no data will remain.
Ram however will hold its values for a short time without power however, if you needed to force the tablet off by holding power for 5 seconds you have under 10 seconds to power back on the device if you wish to see any of the log. (and you need to leave it off 3 seconds or it will ignore your pressing power.)
--
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
INTRODUCTION
There are several guides and tutorials that teach you how to build your own custom firmware from source.
To the trained eye, the steps to be followed are essentially the same.
But to users with relatively lesser experience in programming or software development/scripting of any kind, it often seems to be a daunting task.
One of the many reasons for this is that users usually have atleast 2 similar guides open side-by-side on their screens.
And when one or two lines of code/instruction do not match, all hell breaks loose.
This might not be the case with you, but it sure was with me.
This guide is based solely on my experience in starting from scratch, trying to build a ROM from CyanogenMod and AOKP sources
Before we proceed any further, I would like to clarify that this is NOT a definitive tutorial,
nor is it the best way to get started in ROM development.
There may be ‘kanging’ involved, zipping-unzipping as well.
Purists may take exception to some steps – but then they are purists for a reason.
My purpose is NOT to oppose what the better-skilled developers opine,
nor is it to encourage the said procedures.
However, in the event that I do mention using them –
be aware that the attempt is solely to provide a small impetus to enthusiastic learners, so that it may help them have some know-how on how to finally get started.
I intend to proceed slowly, rather than publishing the entire thing all at once
and then having confused users discussing Step 2 and Step 2002 at the same time.
In order to avoid this, the posts that follow will be updated in parts i.e
we shall together proceed ahead once a sizable majority of participants have successfully completed a chunk of required steps.
This, I feel, will ensure that the ensuing discussions are enjoyed and benefitted from by several more users at any given time.
REQUIREMENTS
We would be using the CM10 and AOKP sources as reference to learn building for our device.
For the purpose of this tutorial, we shall work together on the following environment –
◘ Ubuntu 12.04 64-bit
◘ A minimal requirement of a Quad-Core processor with >= 4 GB RAM
◘ A high-speed connection >= 2 mBps
◘ Solid State Drives are highly recommended.
◘ Google Toolbar
◘ Patience
◘ Patience
◘ And more Patience
Assuming that you would be syncing either one of the source trees, you would require
about 70-80GB of free space to sync repositories and compile a ROM from start to finish.
Users on Windows have an option of dual-booting.
If they are hesitant to do so, they can also run Ubuntu using a Desktop Virtualization Software.
However, in this case you would then require atleast 6GB of RAM, if not more,
to run both operating systems concurrently.
Users building on a remote server, I presume, would be spoilt for choices different Linux distributions available.
Be sure to have an SCP client in handy.
It is my humble request that we all follow good etiquettes and rules all the more strictly to ensure an enriching learning environment.
◘ Please do not troll here.
◘ The thread is not to be used for smug remarks or aspersions (as most of us are accustomed to)
◘ Code Snippets that will be posted on this thread using the code tag, as part of this thread, are supposed to be entered into the Linux terminal.
◘ You are requested to use Pastebin to post logs and build errors
◘ Please do not use any fancy fonts or bold typefaces.
◘ Please do not create Thank You posts if a particular solution solves your problem.
Each and every solution will be verified, and the author in turn will be requested to mark his post in Bold-Green.
Hence the last point above..
It is a given that this shall forever be a Work in Progress.
Things will be added, things will be removed as time flies by.
The only thing that should remain constant is the willingness to learn.
And the willingness to use Google Search.
BIBLIOGRAPHY
◘ [Tutorial] Compile JB on Ubuntu
◘ [TUTORIAL] So You Want To Build AOKP JB? [Ubuntu 12.04+]
◘ CyanogenMod WiKi
◘ Android Open Source Project
◘ Frequent IRC chats with Pier and bajee11
◘ Google chats with other kind developers, users and friends
--
Part 1: Setting-up Build Environment
--
A Build Environment is the state of the machine being used for development, including the directory structure and environment variables for your particular project.
Additionally, the command-line build environment for the platform and projects is your build release directory.
And so it follows that though we have our Ubuntu installations done, we are still required
to install additional packages to set-up a build environment suited for our purpose.
OpenJDK is an open-source implementation of the Java Platform, Standard Edition, and related projects.
We shall use OpenJDK-6. Type the following in your terminal -
Code:
$ sudo apt-get install openjdk-6-jdk
At the end of this step you might get a message in terminal related to the need
to update certain elements to complete installation of required packages.
For this, simply run
Code:
$ apt-get update
Python is a general-purpose, interpreted high-level programming language,
whose design philosophy emphasizes code readability.
It may already be installed on your system. But no harm in checking -
Code:
$ [B]sudo apt-get install python[/B]
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Code:
$ [B]sudo apt-get install git-core[/B]
The Android software development kit (SDK) includes a comprehensive set of development tools.
These include a debugger, libraries, a handset emulator based on QEMU, documentation, sample code, and tutorials.
There are 2 ways to install this.
If your Ubuntu setup is on your Home PC and you have GUI access,
you can download the package from here
http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz
To do the same via command line, type this in your terminal -
Code:
$ [B]wget http://dl.google.com/android/android-sdk_r20.0.3-linux.tgz[/B]
This will download the very same package for you to the current working directory.
Now, you have to extract the folder inside the archive, and place it in your home directory.
To do this, enter the following command in your terminal -
Code:
$ [B]tar -xvzf[/B] <filename>.<extension>
For example, if your archive is named android-sdk_linux.tar.gz
where
android-sdk_linux = filename
tar.gz = extension
you will type -
Code:
$ [B]tar -xvzf android-sdk_linux.tar.gz[/B]
Once your folder is extracted, move it to your home directory. Search Google on how to do it.
Next step is to define the path.
For this, go to your home folder and look for a file named .bashrc
For users having the comfort of a GUI, press Ctrl + H incase the file is not visible.
Remote users can use their SCP Client to find the file easily.
Open the file to edit it, and at the bottom paste the following lines -
Code:
# Android tools
export PATH=${PATH}:~/<folder_name>/tools
export PATH=${PATH}:~/<folder_name>/platform-tools
export PATH=${PATH}:~/bin
In the same manner and place, look for the file named .profile and add the following lines at the end -
Code:
PATH="$HOME/<folder_name>/tools:$HOME/<folder_name>/platform-tools:$PATH"
Once, done you now have the Android SDK successfully installed. :good:
In the end, you have to install the remaining packages and libraries and dependencies and what not.
This varies as per the version of the Ubuntu installation.
Since we are (hopefully) on Ubuntu 12.04 (64-bit) , we need to enter the following command in our terminal -
Code:
$ $ s[B]udo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386[/B]
and then
Code:
$ [B]sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so[/B]
In the even that you get errors relating to unavailability of g++ and gcc
run the following in terminal -
Code:
$ [B]apt-get install gcc[/B]
Code:
$ [B]apt-get install g++[/B]
and then repeat the previous steps.
I would also advise that you install the following as well (more on it later) -
Code:
$ [B]apt-get install lzma[/B]
Code:
$ [B]apt-get install screen[/B]
With the above done, all that is left to do is to initialize the repository that you require and then sync it to your machine or remote server. This we do in the next part.
--
Part 2: Fetching sources
--
Repo is a repository management tool that was built on top of Git
.
Repo unifies the many Git repositories when necessary, does the uploads to the revision control system, and automates parts of the Android development workflow.
Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android.
More information on the subject can be found here.
In our context, we need to download repositories of the correct Android branch (ICS, JB etc) for which we want to build.
But whose branch?
That is completely upto you to decide.
The first step is to 'download and install the repo binaries'. Issue the following commands in terminal -
Code:
$ [B]mkdir ~/bin[/B]
$[B] PATH=~/bin:$PATH[/B]
$ [B]curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo[/B]
$ [B]chmod a+x ~/bin/repo[/B]
With this done, we now make a new folder in our home directory where we would be downloading our rom sources by initializing the relevant repo
Code:
$ [B]mkdir myrom[/B]
$ [B]cd myrom[/B]
For CM10
Code:
$ [B]repo init -u git://github.com/CyanogenMod/android.git -b jellybean[/B]
For AOKP
Code:
$ [B]repo init -u git://github.com/AOKP/platform_manifest.git -b jb[/B]
You will most likely be prompted for certain details like name, email etc. Fill those in and proceed to the next step.
Once you have the above completed ( repo has been initialized in /....) it is time to sync! :good:
Simply issue the command -
Code:
$ [B]repo sync[/B]
You might have come across variations like
Code:
$ repo sync [B]-j4[/B]
or
Code:
$ repo sync [B]-j16[/B]
Essentially, all are performing the same function. Only difference is that by adding that little -j
we are specifying how many jobs we want to run concurrently, which is in a way directly related
to the number of cores powering your machine.
I have a quad-core, he has a dual-core, what should we use?
Go ahead and see for yourself.
Your first sync (rather a download) would likely take around 45 minutes to 1 hour, if you have a decent internet connection.
The first time I decided to do this, I wasn't aware of how big the repositories could be, or what sort of an internet connection one would require.
As long as it was an unlimited data plan (yes we have limited data plans in our country), it would be fine I thought.
I had the screen active for around 6 hours without any signs of stopping, until I was finally put out of my misery by good friend antiochasylum -
me: Wow
It takes us a day to download movies
20kbps. Its party time if I can get anything
above 100kbps
Matt: Holy ****. Lol. Mrs Antis galaxy s2 lte gets 5500 down.
Blows the **** outta my note
me: :sniff:
Click to expand...
Click to collapse
Sit back and enjoy.
Do not get all tensed if the text on your screen suddenly stops moving OR is stuck at some place.
Unless and until you are back to the bash shell with a definite error message explaining why repo sync was interrupted - you are all good. :laugh:
--
rvd
reserved
one more
last
And this one is for me..... Thanks a lot dude... will keep watching this space..
Thank you so much, this is great for us newbies :highfive:
Wow, wanted to learn since longthanks
Great idea toxic, you might've just encouraged me to start compiling and building again
Sent from my GT-N7000 using XDA Premium HD app
thanks
Grrr888888. thank you very much :good:
Thank you, with my computer it gonna take forever compiling , it's is only dual core 2,1 ghz :silly:.
But since i've got patient, i'm gonna try.
PS: I have plans to install gentoo on the same team at some point in the future so this will be easy in comparison.
Please share this with other users who might be interested so that all can benefit.
Thanks
Sent from my GT-N7000 using xda premium
While setting up Ubuntu via VM for windows i am able to run though entire installation procedure but getting an critical error after i restart when the installation is complete..
sorry, this may not be exactly related with the topic directly but i thought i might find my answer here..
Sent from my GT-N7100 using Tapatalk 2
What would the error message be? I mean what exactly does it say?
Sent from my GT-N7000 using xda premium
http://pastebin.com/VLtJzaqd
Ubuntu log for your ready reference.
sunny2303 said:
http://pastebin.com/VLtJzaqd
Ubuntu log for your ready reference.
Click to expand...
Click to collapse
It seems he SATA controller in your VM has only one port configured and is unavailable to make hotplugging work.
Make sure you are not trying to run your installation from a Guest/Limited account.
Also, in case you're trying to run Ubuntu from a CD instead of copying files to the the hard disk, you may face some problems.
Sent from my GT-N7000 using xda premium
Thanks this solution worked You were right the isse was with SATA controller.. I had not assigned it. After assigning it under settings, it worked.
Now I have moved slightly ahead... at the path setting stage
export PATH=${PATH}:~/<folder_name>/tools
export PATH=${PATH}:~/<folder_name>/platform-tools
export PATH=${PATH}:~/bin
while we are writing this in .bashrc are we supposed to replace <folder_name>/ with actual folder name? like say extracted folder name is android-sdk-linux which is placed under home.. so should we write <android-sdk-linux> ?
Hello everyone.
I’ve decided to build this tutorial in order to assist all developers and builders into the ROM and kernel development. I’ve felt motivating into writing this small post because I feel that the current information available is confusing and also do not provide the set of skills and information to help someone in the first steps.
This tutorial will be divided on:
The Machine Configuration
The tools of development
The Source
Hardware
Software
What to do to be able to Innovate
The Machine Configuration
In order to have a good machine configuration you should select your distro based on the packages which are provided to developers. In my opinion the best distros are Fedora and Ubuntu. It is important to learn a bit how Linux works in order to fully understand what we are editing as Android is nothing more than equivalent Linux system where you run java on a virtual machine. In other words, you’ll understand with time that many parts which are used on Linux Operating system it is also used on Android Operating System (example: bionic, kernel libs).
After you installed your Linux system you’ll need to prepare your machine for building. For that you’ll need to install the following packages:
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 maven
sudo apt-get install openjdk-7-jdk
Code:
sudo apt-get install android androidsdk-uiautomatorviewer android-copyright android-src-vendor android-emulator android-tools-adb android-headers android-tools-adbd androidsdk-ddms android-tools-fastboot androidsdk-hierarchyviewer android-tools-fsutils androidsdk-traceview
After you have the basic packages installed we are going to add the repo instructions to you git in your machine. Basically this will interpret the source information when you are syncing new code from google repos and we’ll add to the folder /bin/repo.
To do that we’ll run.
Code:
[B]mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo[/B]
And run the /.profile. Basically this command will reload information of the new settings for your profile, where it’ll read the folder ~/bin/repo information for all situations. In the future only makes sense to load again in case you have added a new repo instruction.
Code:
[B]. ~/.profile[/B]
Now we are going to sync the source code. I’ll use here as an example CyanogenMod as I believe to be the easiest for anyone which is starting. Lets imagine we are going to put all the source on a folder named cm, you’ll have to just run the following commands.
Code:
[B]mkdir ~/cm
cd ~/cm
repo init -u git://github.com/CyanogenMod/android.git -b cm-13.0[/B]
So in order to explain what we’ve done here by steps. The repo init –u basically is a command instructing to go to the GitHub on that specific location and extract what is available on the cm-13.0 branch regarding to manifests. So basically it’ll automatically push the file which has all CyanogenMod source to .repo/ folder with the name manifest.xml
After you have loaded this command you’ll run the repo sync , basically this command consists on downloading all the code into your building folder (in this case cm folder).
After the repo sync is complete you’ll have interest on having a local_manifests. Basically on this local_manifests.xml , where some developers prefer to name it as roomservice.xml it is where you’ll add the changes to the manifest.xml or even sources which you wish to add to your building folder. This is a solution to you never edit the manifest.xml.
Usually it is added on the local_manifests the folders related to your device tree. I’ll give in this example how to build for the OnePlus One (bacon).
A device tree consists on configurations where you set information related to your device. Example if is qualcom, usually is android_device_qcom_common (where is the general settings) together with android_device_oneplus_bacon (where are the specific settings). When I say settings, for you to understand is like compile with the folder hardware/qcom/display for the display. You should take some time to explore to understand what is in it.
So you’ll add your local_manifests.xml this way.
Code:
[B]
mkdir .repo/local_manifests
nano .repo/local_manifests/local_manifests.xm[/B]l
You now add:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="CyanogenMod/android_device_oneplus_bacon" path="device/oneplus/bacon" remote="github" revision="cm-13.0" />
<project name="CyanogenMod/android_device_oppo_common" revision="cm-13.0" remote="github" path="device/oppo/common"/>
<project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" revision="cm-13.0" />
<project name="CyanogenMod/android_kernel_oneplus_msm8974" path="kernel/oneplus/msm8974" remote="github" revision="cm-13.0" />
<project name="TheMuppets/proprietary_vendor_oneplus" path="vendor/oneplus" remote="github" revision="cm-13.0" />
</manifest>
Now you need to run the repo sync command again.
This has to do separately the first time or it won’t sync all the files you need. In case the repo sync fails with an error saying you need to do –force-sync just run repo sync –force-sync (this happens only when you change common git sources with your manifest.
After the sync is done you are ready to build!
To start building you’ll need to run the .envsetup.sh , which will load all the source code into memory. After that breakfast bacon userdebug (in case it is for the OnePlus One device), then later make bacon (the word bacon it is to be used on all devices , here it is just a coincidence with OnePlus One)
Code:
[B]. build/envsetup.sh
breakfast bacon
make bacon[/B]
After it compiled your rom will be located at /cm/out/target/product/bacon/
Easy until here? I hope so.
Possible errors :
Q: Receive error: fatal: duplicate path xxx/xxx in ~/cm/.repo/manifest.xml
A: edit .repo/local_manifests/local_manifests.xml to remove the item which matches the item located in bold.
Q: How big is the repo?
A: 50GB just source code and around 10GB when built per device. Therefore you should aim to have about 60GB free on your system.
The tools of development
Git
Probably many of you question about what it is git, read about it on the github manuals etc and still cannot figure out how to work (I took two weeks to understand that it is really simple). So imagine that you have a diary, but instead of being separated by dates it is separated by titles, which we call commits. And what is a commit? Basically it is a portion of code. So when you make a change and want to record that change, you create a commit and in the end it’ll be a portion of code. This portion of code, known as commit, can be easily ported between different sources.
Here is an example:
https://github.com/jgcaaprom/androi...mmit/9f16b3cd79ad7bb8c821a518ca73725f19c38478
The commit number is: 9f16b3cd79ad7bb8c821a518ca73725f19c38478
This commit has recorded a change of IZAT_DEBUG_LEVEL = 2 .
Now how to bring other commits from different sources into our source.
The process comes in 3 phases:
First we’ll have to add the source where the commits that interests us are with git add source_name link
Second we’ll download that source by using git fetch source command
Thirdly we’ll cherry-pick (bring the portion of code recorded in the commit) into our source in order to make the changes automatically.
So lets see a real scenario. Imagin you are interested on cherry-picking this source:
https://github.com/CyanogenMod/android_device_oneplus_bacon
What you’ll have to do is.
Step one: git add cm https://github.com/CyanogenMod/android_device_oneplus_bacon.git
Step two: git fetch cm
Step three: (imagine this is the commit you want:
https://github.com/CyanogenMod/andr...mmit/58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573 )
The commit number is: 58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573
So you’ll git cherry-pick 58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573
And voila! You’ve done your cherry-pick . Now it is important to have in mind how the cherry-pick process works which I’ll explain on the next step.
Cherry-picking
Cherry-picking is a process of importing code from one source to another. So the process that git does basically is, compares your present files in the source with the files that was on the source you are cherry-picking and if everything is a match it’ll change the code automatically for you.
Now lets pick up the example above and imagine that the changes you are doing instead of being exactly the same as described here:
https://github.com/CyanogenMod/andr...mmit/58027fcbea4dd9fbb5aaeb8ae5f6e32bdf613573
Your source has a difference which doesn’t have this line:
32 private static String CONTROL_PATH = "/proc/touchpanel/keypad_enable";
You’ll notice that it’ll give a conflict. The reason for that is because the git when comparing understood that there was no match between the sources. When that happens means basically that there might be changes you should do in order for the code to be compatible, so you’ll have to review that code.
Now the review process is very simple. For you to see which files are in conflict you’ll have to run git status ( basically this command informs you of the situation of the commits which are being cherry-picked and the changes which you’ve done. )
You’ll notice that the files which need to be edited/review are in red. In case it appears files in green, means that there was a perfect match and doesn’t need a review.
Pretty useful right?
After you finish editing all the code you’ll do git add . and for this exercise do git status again just for you to see what happened . Everything is green. To finish the cherry-pick you’ll now do git commit and done!
How to record my own changes and create a commit with it.
Basically this process is exatly the same as the previous one, the only difference is that after you made the changes, you can make git status, then git add filename in case you want to commit only one file or git add . in case you wish to commit all the files and to record the commit you write git commit, or git commit –m “commit message”.
Congratulations! You’ve just recorded your commit!
Git push/pull
There will be moments where we just wish that we could be lazy and cherry-pick everything all at once. Well there are some scenarios where you can actually do that, but remember it is not perfect. Lets imagine we are using the source above, and CyanogenMod uploaded like 20 different commits, your source is not exactly like CM source but you wish to keep your changes and also have all changes from CM what to do?
1) You can cherry-pick one on one. And waste a lot of time…
2) You can make a new source based on cm and include your changes there
3) You can git pull
Git pull basically will update your source with CM source by merging all the commits. You do that with:
git pull cm cm-13.0 (in case your rom is Marshmallow)
The git pull should only be used when the sources are very similar and you are using as a base. Basically it’ll warn you that’ll merge the code and voila done! 20 commits added to the source.
Now when on the situation that the sources are slight different or very different it’ll create a conflict. Again the git will do comparisons between the entire sources, check which commits are missing, compare the files just like with cherry-picking. And when you do git status, it’ll appear on red all files where you need to review your code.
After you finish, same as before
Code:
[B]git add .
git commit[/B]
Done.
I hope you are understanding everything until here.
git reset HEAD~n
This command is rarely used but is super usefull. Basically you are saying to git that you with to remove n commits you've reated/cherry-picked. For you guys to understand how it works, basically imagin you have just written/cherry-picked 10 commits, and you do git reset HEAD~3 , he'll basically remove from records 3 commits. But... That doesn't mean he reverted the code! In case you wish reset the code you need to do git reset --hard.
Also it is very usefull to help rewrite the history. Lets think the example I given before. When you do a git reset HEAD~3 , basically on a history of A B C D E F G H I J commits, the git will remove only the recorded commits H I J. If you do after a git status, you'll understand that the code is still there, which means the changes you done on H I J will still be there. So you can create a new commit with H I J all together . Simple!
Another way to create a unique commit with H I J is by using git rebase -i HEAD~3 , where you basically are instructing the git that you wish to rebase the source with an interactive selection. You'll see that it'll appear a commit list where you can remove other commits from history. But since you wish to create a unique commit you'll wish to change the instruction from pick with the letter s (without capslock term for squash) . Example:
Code:
[B]pick d0c49f4 UsbDeviceManager: Remove charging from persisted function composition
s 2c755a6 SystemUI: fix NFC tile sometimes hiding
s e39d1d7 Revert "base: start nfc service prior to systemui"
pick 9164274 DocumentsUI : Hide advanced menu option when in forced mode
pick 5f8d3f8 Themes: Expose Power Dialogs
pick 9153396 SysUI: Don't let rogue themes ruin notifications
pick 226797c Revert "Only show keyguard panel if on lockscreen + no activity on top"
pick e843aaf Fix NPE in DocumentsUI when rotate UI before format as internal
pick 26079d3 SystemUI: detect rotation and resize mKeyguardBlur accordingly
pick 80b060d Automatic translation import
pick 4282864 Automatic translation import
pick d442df6 wifi: Enable WiFi IpReachabilityMonitor by default
pick 9cf937f SystemUI: Add margin in qs_tile_top between instruction text and add button[/B]
Cool right?
And I believe I've covered with some examples the git. As you can see, once you get used to git you'll be able to use it easily.
Toolchains
There has been a big debate from many developers on which toolchains to use. Many prefer sabermod, others prefer uber, others google toolchain, etc. It is in fact debatable. If you ask me which one to use, I would say google or uber (very similer to google) and the gcc used by stock on the source. The reason is simple, the code is optimized for a certain gcc version, if you start using a gcc version which is not prepared to be used on the code, it won't translate correctly your instruction.
The source
When you start building roms, you should at least know a little about how the source of android is organized, what language it is used, etc. On android it is used C, C++, Java, Assembly. Withing the following folders inside the source it is used:
Java
Frameworks
Packages
external (some packages)
C++
ART
bionic
hardware
C
kernel
hardware
Assembly
bionic
some of the kernel libs
This is important for you to navigate easily within it. Some of you ask yourselfs what is one thing or another. I'll represent that to the following image which is published on the google developers page.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Now I believe you wish to know which parts should be used in order to put a rom working for a certain device. Those parts are:
Hardware
Kernel
device tree
Vendor blobs
These parts are the "base" of your build to put a certain device in a working, since on these parts is where lies the instructions for the device to understand what to do.
The build folder is where you specify instructions of the building process. For example : Certain optimization, which GCC to use, where will the compiler find the apps to compile.
frameworks, system, packages and some of the folders within the external folder are the packages of what you will have inside the rom which is general and can be present on any rom.
external folder has present different things, compilers such as proguard, jemalloc. external software used by the rom such as sqlite.
prebuilts folder has present everything related to stuff which is already compiled, in this case clang, gcc toolchains.
I've done a very summarize version of the source in order for you to understand how that google built things, so I hope it is simple to understand these basics.
(to continue)
reserve1
reserve2
reserve3
Another great contribution bro. Thanks for your work and for your help. Starting read right now
Edit: Amazing guide
Just one request, please bold when you write a command. I think it becomes more eligible.
@jgcaap I think this is useful
For those already have JDK8 installed, they can use it by adding this code to $HOME/.bashrc
Code:
EXPERIMENTAL_USE_JAVA8=true
You just have to source ~/.bashrc before make bacon
There's nothing better than learning something from a professional who you know has done such a great work. Thanks a million!! @jgcaap
Very useful.. Thanks for sharing =D>
Sent from my A0001 using XDA-Developers mobile app
FSadino said:
@jgcaap I think this is useful
For those already have JDK8 installed, they can use it by adding this code to $HOME/.bashrc
Code:
EXPERIMENTAL_USE_JAVA8=true
You just have to source ~/.bashrc before make bacon
Click to expand...
Click to collapse
I'll speak about different custom GCC and also other compilers, but it'll be on another section. I'll continue writing this on wednesday (exam tomorow). I believe that my guide will help understand all the basics.
If I speak about that mode, I believe it'll give the idea that it is a feature of linux and it isn't. It is something you can change inside the source in many different ways.
jgcaap said:
I'll speak about different custom GCC and also other compilers, but it'll be on another section. I'll continue writing this on wednesday (exam tomorow). I believe that my guide will help understand all the basics.
If I speak about that mode, I believe it'll give the idea that it is a feature of linux and it isn't. It is something you can change inside the source in many different ways.
Click to expand...
Click to collapse
This might sound a little stupid but which JDK version is recommended? 7 or 8? Seems like 7 cause you have to enable "Experimental Use" for 8.
Great guide! Can you, if you have time, also post a guide only focusing on kernel building?
abhibnl said:
Great guide! Can you, if you have time, also post a guide only focusing on kernel building?
Click to expand...
Click to collapse
The guide is incomplete, will write more on wednesday. I'll cover everything in a very simple waywith praticle solutions.
thank you , that what was looking to develop on my tablet , I can use basic as this tutorial for other devices.
continue with tutorial , as many want to learn, but has no simple guide to base
you must wrote revision="cm-13.0" /> instead of revision=”cm-13.0” /> 'cause it give you an error that you can't be able to repo sync
fafa77140 said:
you must wrote revision="cm-13.0" /> instead of revision=”cm-13.0” /> 'cause it give you an error that you can't be able to repo sync
Click to expand...
Click to collapse
i literally stared at this for like 1h and didn't find any difference could you please elaborate more...
baconxda said:
i literally stared at this for like 1h and didn't find any difference could you please elaborate more...
Click to expand...
Click to collapse
The quotation marks surrounding cm-13.0 in first post are not the right ones. So you need to replace those quotation marks if you copied and pasted the code in your manifest. Just delete the quotation marks and type them again.
joshuous said:
The quotation marks surrounding cm-13.0 in first post are not the right ones. So you need to replace those quotation marks if you copied and pasted the code in your manifest. Just delete the quotation marks and type them again.
Click to expand...
Click to collapse
ohhhkayyy.........:good:
fafa77140 said:
you must wrote revision="cm-13.0" /> instead of revision=”cm-13.0” /> 'cause it give you an error that you can't be able to repo sync
Click to expand...
Click to collapse
good catch. I never thought the keyboard would be writting differently when not on the terminal. Thanks
jgcaap said:
good catch. I never thought the keyboard would be writting differently when not on the terminal. Thanks
Click to expand...
Click to collapse
No problems
fafa77140 said:
No problems
Click to expand...
Click to collapse
updated more stuff today.
[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
IntroductionSo, I will start off by telling a little bit about myself. I got interested in Android building in November 2017. I found most of the guides "inadequate" for pure newbies like me.
This is my second guide and the first one for No-Knowledge newbies so please do correct me . I will also add some humor so you don't get bored
The guide will be divided into a few parts-
Using linux and enjoying it(No offense to GNU/Linux enthusiasts. please don't start a debate, its just my personal opinion)
Basic git for complete newbies
Compiling your first ROM(Lineage)
Compiling your first non-Lineage ROM
Choosing a Programming lanugage
Basics to resolving conflicts
Compiling AOSP-based roms for CAF devices(For which I couldn't find a guide)
It will probably take a while for you to read this but its must to read everything carefully. Lets start off right away
Using Linux and Enjoying it!
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
There are more than adequate guides for using Linux. I will just help you choose the distro and recommend some guides
Personally, I used Linux wayyyy before I started building android(~2013) I didn't do much at first so I got most of my Linux experience in 2016-2018
Some distros I recommend-
Ubuntu 16.04 or 18.04 (Probably the best for newbies imo) - https://www.ubuntu.com/download/desktop
Arch Linux(Could be problematic to install for newbies so I recommend you install Antergos first - https://Antergos.com/try-it/ )
Linux Mint - https://linuxmint.com/download.php (Newbie friendly)
Debian GNU/Linux (Easier than Arch imo, slightly(very slightly) harder than Ubuntu) - https://www.debian.org/
You absolutely MUST live boot them and feel them. I highly recommend you to install them on a small partition(~40GB) to get the best experience. Please don't use linux on a server at first!
I personally started with Ubuntu 12.04 for a month or so, 14.04 as well for a few months. I became a daily user when 16.04 came out.
Currently, I am using Antergos. However, for building I liked Arch as it had everything "bleeding edge"(Search it if you don't know what this means xD)
Here are some absolutely noob friendly guides-
https://www.youtube.com/watch?v=opBKvGi77cU
For Ubuntu (Long guide but indepth!)
https://www.youtube.com/watch?v=G0AFuhVSvEk
For Linux Mint (Again, Long but indepth!)
Use them for atleast a week or two before you even jump into android building! A month of daily usage is recommended so you know how to tackle basic problems. Youtube will always be your friend and so will be google. You can't hate Linux once you know how to use it! The only reason why I use Windows is because of gaming and applications such as Photoshop and Illustrator(I know there are alternatives, again just my personal opinion!)
See you after a week! No? Seriously use linux for atleast a week!
Using Linux will also hone your google skills(Not even kidding)
Basic git for complete newbies
Personally, I myself don't do advanced stuff with git myself and here are the subcommands you will be using the most with git -
clone
cherry-pick
revert
merge
commit
push
I will give a brief explanation of each and link some guides! Why brief? Because I expect you to have a thinking like a linux user now . Also, you can switch to a server now!
Here is a playlist by github -
https://www.youtube.com/watch?v=noZnOSpcjYY&list=PLg7s6cbtAD15G8lNyoaYDuKZSKyJrgwB-
If you are not satisfied(I wasn't) you can search youtube for a specifc command as well! (i.e cherry-pick)
clone -
Simply clones the repository including its commit history!
Usage-
Code:
git clone <repo> -b <branch> <directory>
If you don't specify a branch, it will clone from the default branch.
If you don't specify a directory, it will make a folder with the name of the repo
Example -
Code:
git clone https://github.com/ChimeraKernelProject/chimera_land-current -b lineage-16.0 chimera
(Shameless self advertising xD)
cherry-pick-
Generates a diff from a commit and applies it to the local repo
Usage-
Code:
git cherry-pick sha
You do need to fetch the repository from which you are picking a commit
Using-
Code:
git fetch <repo> <branch>
If the branch isn't specified, it fetches the default branch instead
Cherry-picking multiple commits-
Code:
git cherry-pick sha1^..sha2
This picks all the commits from sha1 to sha2(i.e the commits between sha1 and sha2, including sha1 and sha2)
You may or may not get a conflict for which I will have a seperate section.
Example-
Code:
git fetch https://github.com/ChimeraKernelProject/chimera_land-current lineage-16.0
git cherry-pick 9e8a821ba64f5b498843b025d1804e3818dda480^..8e80e52915492328e80378f7ecff0cb44fdc1344
(Try figuring out what I did )
What is SHA you ask? You don't have to know what it actually is so just consider it to be an identifier for a commit.
revert
Generates a diff of the commit and reverses it(pretty much the opposite of cherry-pick)
The usage is same as cherry-pick.
merge
Kind of like cherry-picking multiple commits but it compares the history of the local and the remote and then generates a common diff for the commits that are not in local
Also, you do need to fetch before merging.
Usage-
Code:
git merge <remote>
Example-
Code:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git v3.18.125
git merge FETCH_HEAD
(The example here is of upstreaming the kernel )
commit and push
Generates a commit for staged files
Usage-
Code:
git commit -m "some message" -m "sub-message"
some optional parameters-
--signoff
--author="name <author email>
If you forgot to add a file to the commit, you can -
Code:
git commit --ammend
Again, you can use the optional parameter.
how to stage files you ask?
you simply use-
Code:
git add <filepath>
If you did your linux lessons correctly, you might know that, you can use "." and ".." in filepath(redo them if you don't know xD)
finally, to "push" your changes to a remote repo-
Code:
git push -u <repolink>
It will ask for authentication. You use your github(or whatever you prefer) account for that.
After using -u once, you won't have to pass the parameter again.
Lets end this with an example-
Code:
git add .
git commit -m "add 69 hour battery life" -m "best" --signoff --author="someone <[email protected]>"
git push -u https://github.com/ChimeraKernelProject/chimera_land-current
(Also please don't use a stupid commit message like the one I showed xD. This one was just for the lulz)
This one was big. oof. Took me a while to write and probably will take a while for you to read too .
You might ask why did I tell you to search xyz in this one so much! Simple reason- I want you to get used to searching your problems!
Mastering git takes alot of time! I am not any good myself and I search alot of stuff on google myself! (Sometimes even problems related to merging and checking out!)
Compiling your first ROM(LineageOS)
I bet you have been getting restless by now! The previous guides were to build the excitement to build your first ROM!
Why Lineage? Simple. Its one of the easiest ROM to build. Pretty well documented and most importantly, alot of video guides to check if you are confused at any point!
It is highly recommended to use a server at this point as you will be pulling alot of data and you will require alot of processing power.
You can build locally if you have good internet.
Here are the minimum requirements(imo)-
i3 6100 or equivalent
8 GB RAM
300GB HDD(500 GB+ is highly recommended)
Lets start off by the dependencies. I am assuming you are on Ubuntu or Linux Mint. These are the dependencies you need to install -
Code:
openjdk-8-jdk
git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip
You know how to install them don't you now
Lets install Repo now-
Code:
mkdir ~/bin
edit your .bashrc in the home directory with your preffered file editor(I use nano) and add this line to the bottom (Hint - hold pgdwn to jump to the bottom quickly)-
Code:
PATH=~/bin:$PATH
Then execute these commands-
Code:
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Code:
chmod a+x ~/bin/repo
Lets sync Lineage now shall we
First add your github account to the git config using-
Code:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Here, you should use your github email! (See https://help.github.com/articles/about-commit-email-addresses/ if you don't want to use personal email)
Make a dir in which you will do the rom stuff and cd to it
Before we initialize and sync LineageOS, you have to decide which branch you are choosing as well
You can check your device forum and see what Android versions does the device have. PS- You might wanna check the LineageOS thread. The developer must have provided a link to their kernel source(If they didn't, report the thread to mods kek). Click and navigate through their github. you will find a repo named- android_device_(vendor)_(devicecodename) . you probably know the vendor and the codename from the forum don't you?For example its- android_device_xiaomi_land for my device(Yea right I have an old as hecc device pls no laugh ). Check the branch of the ROM. It will probably something like lineage-16.0 or 15.1 etc. Also if you have an official device, you can check its branch at- https://github.com/LineageOS .
Welp now you know the branch, lets start!
Code:
repo init -u git://github.com/LineageOS/android.git -b <branch>
repo sync
To sync a little bit faster, here's a better command I got from StatiXOS git -
Code:
repo sync -c -f --force-sync --no-tag --no-clone-bundle -j$(nproc --all) --optimized-fetch --prune
Also, if your sync stopped midway because of your ISP(BSNL :'( ), you can just start the sync again.
If you are on another distro such as arch, you might have to do some extra steps- https://wiki.archlinux.org/index.php/android#Building
Now that you have synced, You may choose one of the 2 paths-
If you have official LineageOS, choose me!
Setup the environmental Variables with-
Code:
source bu*/e*
Clone your vendor blobs from TheMuppets repo - http://github.com/TheMuppets
or, from your preferred developer.
The usual repo name is proprietary_vendor_(vendorname). For example, in my case its proprietary_vendor_xiaomi . It should have a folder with your device codename
If not, try changing the branch!
You should be cloning them to vendor/(vendorname)
start bulding right away with-
Code:
brunch lineage_<codename>-<buildtype>
here, codename is your device codename and buildtype is one of these-
user, userdebug, eng .
I recommend userdebug at first. user builds are pretty much as limited as your stock rom. eng builds are actually the one you should use for debugging the rom. These are not secure for daily usage.
This will start the build and you probably won't get an error as its official. If you do, you can just search it up on google. Once the build is done, you will get filepath in the command output. Generally, the build is in
<workingdir>/out/target/product/<codename>/xyz-UNOFFICIAL.zip .
If you have unofficial Lineage, choose me!
I am assuming you are in the working directory
Welp, lets start off by searching for the required trees.
Here's what you need-
Device Tree
Kernel Source
Vendor Blobs
Usually I find them by checking the post of the unofficial Lineage thread and click the kernel source link(Again, if they didn't post it, you should report the thread ). Go to the dev's profile and check his repositories. Here are the usual naming schemes for each one of them-
Device tree - android_device_(vendorname)_(devicecodename)
Kernel Source - android_kernel_(vendorname)_(devicecodename) or! android_kernel_(vendorname)_(soccodename)
Vendor Blobs - proprietary_vendor_(vendorname) or, proprietary_vendor_(vendorname)_(devicecodename)
Device tree should be obvious. It should be cloned to - device/(vendorname)/(devicecodename)
As for kernel tree, soccodename menas the codename of the SoC you have in the device. The thread should have it already as the kernel is licensed in GPL v2(GNU Public License V2, for more info check - https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html ). To know where you need to clone the kernel tree, check the "BoardConfig.mk" of your Device tree and check the "TARGET_KERNEL_SOURCE" line. It tells where you need to clone the kernel
vendor name should be obvious as well now. If your vendor name doesn't have the codename, it should be cloned to vendor/<vendorname>
if it has the devicecodename, it may or may not be the device tree and still be like this-
If it doesn't look like this, it should be cloned to vendor/<vendorname>/<devicecodename>
Here's the repo list of an ideal dev-
Setup environmental variables-
Code:
source bu*/e*
Start the build! -
Code:
brunch lineage_<codename>-<buildtype>
here, codename is your device codename and buildtype is one of these-
user, userdebug, eng .
I recommend userdebug at first. user builds are pretty much as limited as your stock rom. eng builds are actually the one you should use for debugging the rom. These are not secure for daily usage.
Now since you are using an unofficial tree, it is likely that you might hit an error. One of the most common error is when brunch is unable to find your target device. a simple fix for that is to navigate to your device tree and make a file called "vendorsetup.sh"
It should have this line in it-
Code:
add_lunch_combo lineage_<codename>-userdebug
where(you guessed it), codename is your device codename. Run the environmental variable setup again and you should be ready to build.
You might hit errors. Google is always your friend. If you are absolutely sure that you can't find it on google, check the help group section in the thread!
Once the ROM is ready, you will find the filepath in the command ouput. Generally its in out/target/product/<codename>/xyz-UNOFFICIAL.zip
Uploading files to google drive
There's a really nice guide availabe here- http://olivermarshall.net/how-to-upload-a-file-to-google-drive-from-the-command-line
Congratulations! You just made your first rom. If you find this hard, this is just the beginning! There's a very rough road ahead.
Compiling your first Non-Lineage ROM
PS. - The ROM has to be "Lineage-based".
thee aren't eft f'r aosp bas'd roms!
I will be using XenonHD as an example as it is pretty easy to build and it was pretty much one of the first roms i ever built.
Building a Lineage-based rom is as easy as building Lineage!
You go to the rom's git(I usually google search or check it in one of the rom's thread for any device) and check the repo manifest. The usual naming scheme for a repo is-
android_manifest
platform_manifest
manifest
android
etc.
In xenonHD's case, its platform_manifest(and all other repo names will start with platform prefix)
A proper ROM source should have the syncing instructions and building instructions. Lets check the XenonHD's example
make a working dir for the rom in which you will do your rom stuff.
Initialize and sync it. The initializing and syncing part is always the same across the ROMs. (You know which branch to use now. Don't you?)
Again, clone all the required trees!
Now now now, don't get excited yet! Before you start brunching, there is some stuff you need to change.
Usually you can refer to one of the official trees in the ROM organization. For example, https://github.com/TeamHorizon/android_device_xiaomi_kenzo has proper commits. You should be looking at the "Initial XenonHD" commit. You can obviously ignore commits like https://github.com/TeamHorizon/andr...mmit/c076f8c7199d0cddbe6a1e0d05bf3ffc63080d1d as they are device specific. The basics are always the same-
Rename lineage.mk to (romname).mk . refer to the device tree if you are unsure about the romname
edit the (romname).mk and change all the lineage instances to (romname). refer to the commit if unsure.
rename lineage.dependencies to (romname).dependencies .
Renaming the kernel defconfig isn't really necessary so you can ignore that.
Setup the environmental variables(Same across all the roms)-
Code:
source bu*/e*
start the build using the supported command given by the ROM devs.
Code:
brunch codename-<buildtype>
in XenonHD's case. However its different across most of the roms so never forget to read manifests!
You are more likely to hit errors with these spinoffs. Google is your friend(I can't remember how many times I have repeated this) and so is LineageOS repo! You have alot of references if the error is not device specific. Learn to fix derps! Check the help groups sections and ask if its absolutely necessary! Again, the command output will have the filepath of the final ROM zip!
You aren't ready yet. You need to gain alot more experience in compiling ROMs and here are some ROMs that you should be able to build at this point- Resurrection Remix, DotOS etc. Most of the lineage based roms support brunch. (Be careful tho, as a few AOSP based roms support it too. You might have a hard time compiling those!)
Choosing a programming language
At this point, it is highly suggested to learn a programming language if you want to escape the Buildbot stage. I am not forcing you, but you will have alot of trouble in doing advanced stuff.
There are several beginner friendly languages-
bash (the easiest)
Python (Recommended)
Kotlin (Android App development, quite easy)
Harder, recomended to learn after the easy langages-
Java (Gotta learn java if you want to make your own custom ROM at some point :3 )
C/C++ (Other than System UI, most of the other stuff for Android is written in C or C++)
Anything else you like! Once you get the basics, its not hard to learn another language .
The reason why I recommend Python is because it was the first language I learnt! Its pretty easy(Though, the OOP, Object Oriented Programming part is slightly advanced). It has wide applications and THE preferred language for Machine Learning and AI stuff, Period(OMG BUZZWORDS).
Kotlin is also fairely easy. I haven't programmed much in kotlin though I know basic syntaxes. If you learn it first, you won't have much trouble with learning Java. Probably. You can learn Java at first as well but you might have trouble! C is a must learn if you want to modify the Kernel and C++ is a must if you want to modify other code like HALs!
Python takes a day or two to learn! Not even kidding. I recommend this nice playlist by CSDojo - https://www.youtube.com/watch?v=Z1Yd7upQsXY&list=PLBZBJbE_rGRWeh5mIBhD-hhDwSEDxogDg
If you are interested in programming Machine learning, I recommend this playlist- https://www.youtube.com/playlist?list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal
I learnt Kotlin basics from this Video - https://www.youtube.com/watch?v=H_oGi8uuDpA but there are more advanced videos as well.
I can't link Java tutorials as I haven't learnt it and nor do I plan to anytime soon. You can of course check youtube .
I learnt C from books and The C programming language by Dennis Ritchie and Brian W Keringhan is a must read! I quite liked "Programming in ANSI C" by E. Balagurusamy as well. You can of course, learn it on youtube.
Getting into programming takes a while and you might not like it at first but if you do, you will always enjoy it!
Basics To Conflict Resolution
It is assumed that you have a mind of a programmer and thus the guide will have alot less spoon feeding!
Lets get back to git and discuss about Conflict resolution. From time to time, you might want to cherry-pick something or perform a merge and you might get a "conflict".
Here's a basic idea!
The code between <<< HEAD and ===== is your previous code and the code between ====== and >>>> (commit SHA) is the new code from the commit. You get this if a part of the file in the commit is not the same as your local file.
There are 3 possibilities -
The code between <<<< HEAD and ===== is not required, thus you can delete that (Mostly)
The code between ===== and >>>>> is not required, thus the new change is not required (Rarely)
Both the old code and the new code is required (Pretty common!)
How do you decide between the three? You actually check the commit you are picking. In case of a merge, you can just view the history of a file and check the changes on github. Mostly, that should be enough for a decision. In case of a conflict while upstreaming my kernel, I usually refer to android-linux-stable project - http://github.com/android-linux-stable . Other times, I actually use my brain and figure out the option myself!
Compiling AOSP-based roms for CAF devices
Welp, I took alot of your time! You surely learnt plenty. Its the final part of this guide Took me a while to write all this ;_; .
I am assuming that you are fairly experienced now and you have atleast basic programming knowledge and plenty experience with git.
For starters, I recommend you to try AOSIP! It is highly compatible with Lineage trees and it shouldn't be much trouble to modify your device tree for it.
No spoon feeding at this point . Lets revise the basic idea! -
Find the rom source
Find the appropriate branch
Check the manifest for syncing and building instructions
Refer to another device tree(Possibly a tree of a similar device) and modify your device tree! (The hard part as its different from lineage based roms)
Environment setup
Start the build
Most of the AOSP-based roms use these commands-
Code:
lunch <codename>-<buildtype>
Code:
mka bacon
The lunch part is always there in Maximum AOSP based ROMs and the building command maybe different(i.e
Code:
time mka kronic
in AOSIP)
Another part I want to mention is about "HALs" . Usually most of the ROMs (even AOSP-based) ship with CAF HALs and support project pathmaps. However, some ROMs don't. Probably because they are not intended for CAF devices or the sources aren't properly complete yet! To build these ROM succesfully, I clone the CAF HALs from the lineage repo. These are- display-caf, media-caf, audio-caf, bt-caf and wlan-caf.
The first 3 HALs are usually platform specific so do check the branch on LineageOS! (for example, its lineage-16.0-caf-8996 branch for 821 series family SoCs for pie). The next step is to remove project pathmpas from both the device tree and the HALs. You can refer to the changes done by PedroKalil -
https://github.com/KAOSP/platform_hardware_qcom_display-caf/commits/aosp-8.1-8996
https://github.com/KAOSP/platform_hardware_qcom_media-caf/commits/aosp-8.1-8996
https://github.com/KAOSP/platform_hardware_qcom_audio-caf/commits/aosp-8.1-8937
Don't be lazy. Don't clone these HALs as these are outdated! Refer to them and do the appropriate changes on the latest Lineage HALs. the libbfqio changes may not be required as alot of AOSP-based roms have started to ship with it.
As for the Changes required in Device tree, you can refer to -
https://github.com/rupansh/pie_device_xiaomi_land/commit/c118701ba20a70fd59e32833417adeb7b08ab1d0 (The custom Audio policy is probably already enabled so no need to do that)
and https://github.com/rupansh/pie_device_xiaomi_land/commit/23215a2d8d5f1976657190f2a8f19f3fd111c250 (Depends on the path you cloned your HAL to)
You should now be able to compile any AOSP-based ROM! Experience is the key. Some other AOSP-based roms I recommend - NitrogenOS, AEX, AOSCP, Pixel Experience(Fairly easy), Pixel Dust(One of the hard), AOSPA( teach me when you fix the cneserver error lulz) .
Thats all you need to know to build AOSP-based ROMs for CAF devices .
If you wish to get into Android and Linux Kernel Development, Learning C is a must! I recommend this guide by nathanchance if you are ready! - https://forum.xda-developers.com/an...erence-how-to-compile-android-kernel-t3627297
Groups for help
https://t.me/AndroidBuildersHelp
https://t.me/LinuxKernelNewbies (Linux Kernel only)
Your device groups
Let me know if you want your group here
Credits
@tanish2k09 and @Swapnil Soni ( For guiding me even though I had 0 knowledge, co-operating with my idiotic requests)
ABH (Helping me realise that you can fix most of the errors by just searching properly)
@nathanchance (for his awesome kernel guides)
@KalilDev (For helping me with building AOSP based roms)
@ZeroInfinity (For machine learning tutorials kek)
@riteshsaxena (Bess sources for reference xD, Helping me with pie bringup which caused rapid progress for me)
You, the reader
I hope you learnt plenty of stuff from the guide. It took me a while to type this you see :3 .
awesome sir
rupanshji said:
@KalilDev (For helping me with building AOSP based roms)
Click to expand...
Click to collapse
This is one of the best or the most helpful guide I've ever read! I'll Recommend this for anyone who wants to join the ROM building club.
10/10 tutorial, thanx dev.
Thank you for this, OP
any guide like this for mtk devices?