[GUIDE][TOOL] How Build/Compile your own kernel for LG G2 - G2 General

There is still no "how to" specific to the LG G2, so I'll try to share the maximum of my experience (or almost) with ["kernel", "build", "LG G2"] here. I'll show two methods different using CM12 kernel, The method for LG ROMs is very similar, I show some tips for LG ROMs also. The first method is the "manual" and second is the "automatic" using my "tool" called DCC. So come on! For this you will need a computer running Linux (x64) and have knowledge about basic Linux commands. I'm using a laptop (i3-2328M and 4GB of RAM) running Ubuntu 14.10 :good:
Setting Up the Environment
First install the essential tools (common environment for those already working with C/C++):
Code:
sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-7-jdk openjdk-7-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
Check Java and Java Compiler version:
Code:
java -version && javac -version
If the default Java is 1.6.x, Use this command and select java-7-openjdk as default:
Code:
sudo update-alternatives --config java
Click to expand...
Click to collapse
Setting Up the kernel Environment
Code:
mkdir -p ~/android/mykernel && cd ~/android/mykernel && mkdir out
This will create a folder and two subfolder in your home, Within mykernel folder will get all the tools that we will set up. Now we set the toolchain, Particularly I use Linaro 4.9.3, the version optimized for Cortex-A15 by @Christopher83, so I will use it here.
Clone Linaro GCC 4.9.3:
Code:
git clone https://github.com/Christopher83/arm-cortex_a15-linux-gnueabihf-linaro_4.9
Now the required binaries (Common essential binaries to work with msm8974):
Code:
git clone https://github.com/ferreirawax/mkboot_exec ~/android/mykernel/executables
Clone the RAM disk compiled from CM12:
Code:
git clone -b aosp https://github.com/ferreirawax/ramdisk_g2 ~/android/mykernel/ramdisk
For stock Kitkat:
This RAM disk was extracted from my d805 (d805 is a d802 which was released in latin america), then so will work on the d802, d805 and d806 (d806 is a d802 as the d805) If the variant is another you will have to draw your own device using a tool such AIK or search repositories of other developers.
Click to expand...
Click to collapse
Code:
git clone -b lge https://github.com/ferreirawax/ramdisk_g2 ~/android/mykernel/ramdisk
Now finally the source code of the kernel, Here I will use a configured kernel to compile the code without CM12 source, you can use the source code that is in the official repositories of CM12, but you will face some errors and warnings during the build that can be solved using the commits that are in my source and supply of other developers.
Clone kernel source:
Code:
git clone -b cm-12.0 https://github.com/ferreirawax/kernel_lge_msm8974-patched ~/android/mykernel/msm8974
For stock KitKat:
Code:
git clone -b lge-kitkat https://github.com/ferreirawax/kernel_lge_msm8974-patched ~/android/mykernel/msm8974
Apparently not but we already have a complete environment, see the folders in mykernel to have a shadow on it. Now let's the good part of the story. :fingers-crossed:
Click to expand...
Click to collapse
Compiling
Enter in kernel folder:
Code:
cd msm8974
Export Architecture and Toolchain:
Code:
export ARCH=arm
export CROSS_COMPILE=~/android/mykernel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-
For stock KitKat you need export LZ4 path:
Code:
export PATH=$PATH:tools/lz4demo
Select the model of the device you want to compile your pointing due defconfig, If you are using source code directly from the repositories of the CM12, defconfig each supported model is called "cyanogenmod_MODEL_defconfig".
Select model to build (In my case I will compile for d802):
Code:
make d802_defconfig
Now let's clear the specific waste of d802:
Code:
make clean && make mrproper
Select model again to generate new .config:
Code:
make d802_defconfig
Now we start to build:
Code:
make -j4
-j4 is suitable for dual-core processors and -j5 for quad-core.
Depending on the configuration of your PC can take up to 20 minutes. In my laptop the build time is about 10 minutes. If you are using VirtualBox, can take much longer. Upon completion, will generate a zImage and some dtb (Device tree binary) files, The dtb files will be used to create a specific image (dt.img) file containing board informations. Now let's create a RAM disk and then dt.img to later put it all together and result in a final boot.img.
Enter in executables folder:
Code:
cd ~/android/mykernel/executables
Create GNUZip compressed RAM disk:
Code:
./mkbootfs ~/android/mykernel/ramdisk | gzip > ~/android/mykernel/out/ramdisk.gz
Create dt.img:
First copy the dtc file that is in executables folder to /usr/bin
Code:
gksu nautilus
This will open the file manager with root privileges, After click the left mouse button and select the dtc as executable.
You may need to restart, After that create the dt.img with the following command.
Code:
./dtbTool -s 2048 -o ~/android/mykernel/out/dt.img ~/android/mykernel/msm8974/arch/arm/boot/
Finally assemble boot.img file:
Code:
./mkbootimg --kernel ~/android/mykernel/msm8974/arch/arm/boot/zImage --ramdisk ~/android/mykernel/out/ramdisk.gz --cmdline "XXXX" --base 0x00000000 --pagesize 2048 --offset 0x05000000 --tags-addr 0x04800000 --dt ~/android/mykernel/out/dt.img -o ~/android/mykernel/out/boot.img
Replace the XXXX for the following:
console=ttyHSL0,115200,n8 androidboot.hardware=g2 user_debug=31 msm_rtb.filter=0x0 mdss_mdp.panel=1:dsi:0:qcom,mdss_dsi_g2_lgd_cmd androidboot.selinux=permissive
Do not remove the quotes. Replace the panel model (red) for your model. if you are compiling for stock KitKat, remove everything that is green.
Click to expand...
Click to collapse
Now let's add a "signature" in your kernel for the damn locked LG G2 bootloader so you can not be invalidated. If you do not do this procedure, the bootloader of your LG G2 will verify that this kernel has a particular signature, as it does not have your device will be unable to boot. We have two tools for this, Loki is able to fool the bootloader and open_bump (This tool is controversy) is able to add a "valid" signature using illegal means. I'll show how to use both. To this is very simple..
open_bump method:
You need Python to run any Python code, open_bump requires Python 2.x
Code:
git clone https://github.com/CyboLabs/Open_Bump
cd Open_Bump && python open_bump.py ~/android/mykernel/out/boot.img
You will now have an output "boot_bumped.img".
loki_tool method:
First get a copy of the bootloader of your G2, For this you need the adb installed and your G2 properly connected to your PC.
Get bootloader:
Code:
sudo apt-get install android-tools-adb
adb devices && adb shell "su -c dd if=/dev/block/platform/msm_sdcc.1/by-name/aboot of=/sdcard/aboot.img"
adb pull /sdcard/aboot.img
Do not forget the USB debugging enabled
Patch kernel:
Code:
./loki_patch boot aboot.img ~/android/mykernel/out/boot.img ~/android/mykernel/out/loki_boot.img
Will generate an output "loki_boot.img" on mykernel/out folder.
You can install using "my easy installer" (Attached at the end of post):
Download the attachment and extracted, Place your boot.img in the delta folder and
copy all the modules that are in your kernel source for the modules folder:
Code:
find ~/android/mykernel/msm8974/. -name "*.ko" -type f -exec cp {} ~/android/mykernel/installer/system/lib/modules \;
Now zip folder and install on your device. This installer already have panel detection script by @dr87
{
"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"
}
Finally now you have your own kernel! Now I will show the second method of how to automatic compile your kernel using my tool.
To rebuild you have to use the following:
Code:
make clean && make mrproper
make MODEL_defconfig
make -j4
Click to expand...
Click to collapse
Some tips
To not export the toolchain path every time you restart the system, Create a Shell executable in /etc/profile.d as follows:
Code:
sudo nano /etc/profile.d/export_gcc.sh
Copy and paste:
export PATH=~/android/mykernel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin:$PATH
Click to expand...
Click to collapse
CTRL + X, Y, ENTER
Now you just use:
Code:
export ARCH=arm
export CROSS_COMPILE=arm-eabi-
Useful guides:
If you are new, you can start learning about git, One of the main tools for working with modifications to your kernel. Below I leave some links with some guides that can help you.
How to use Github
How to cherry-pick a github commit
Click to expand...
Click to collapse

DCC is a tool I developed to simplify my day, DCC is just a simple Python code that can help you save your time! See the features:
Command-line arguments like M$'s DiskPart
Real-time Shell executer
Manage builds for AOSP and LG ROMs
Build for single or ALL variants in same time
Manage the parameters of your kernel
DCC works with embedded open_bump
Manage your favorite toolchain
Easy to configure and use
I'll show how to use DCC is easy
Setup kernel environment:
Code:
reset && cd $HOME
mkdir dev && cd dev
git clone https://github.com/ferreirawax/dcc
cd dcc && find . -name '.gitignore' -delete
git clone https://github.com/ferreirawax/ramdisk_g2_aosp ramdisk/aosp
git clone https://github.com/ferreirawax/kernel_lge_msm8974-patched msm8974/aosp
Build kernel:
Code:
python dcc.py
do boot d802
exit
You know what happens to these magical commands? An immediate flashable zip of your kernel ready to flash. But for that you need to "setup" to your taste, see the page on github.

@ferreirawax this is great i was waiting for something like this so much, tommorow i will try your guide and post the results
EDIT
I followed everything and got stuck here:
[email protected]:~/android/mykernel/msm8974$ make clean && make mrproper
make: /home/simex/android/mykenel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-gcc: Command not found
THANKS for help
EDIT 2
I tried method with DCC and im stuck here:
[email protected]:~/dev/dcc$ python dcc.py
Traceback (most recent call last):
File "dcc.py", line 19, in <module>
from colorama import *
ImportError: No module named colorama
[email protected]:~/dev/dcc$
Sorry if im annoying but i hope someone can help me

Boris31 said:
@ferreirawax this is great i was waiting for something like this so much, tommorow i will try your guide and post the results
EDIT
I followed everything and got stuck here:
[email protected]:~/android/mykernel/msm8974$ make clean && make mrproper
make: /home/simex/android/mykenel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-gcc: Command not found
THANKS for help
EDIT 2
I tried method with DCC and im stuck here:
[email protected]:~/dev/dcc$ python dcc.py
Traceback (most recent call last):
File "dcc.py", line 19, in <module>
from colorama import *
ImportError: No module named colorama
[email protected]:~/dev/dcc$
Sorry if im annoying but i hope someone can help me
Click to expand...
Click to collapse
This error happens when the toolchain path is wrong.
Colorama module need to use DCC (I forgot to mention that)
Code:
sudo pip install colorama

Really exited to see sutch a complete guide for how to make a kernel for our G2
Will try and see if I can manager to compile my first kernel with this guide today..

ferreirawax said:
This error happens when the toolchain path is wrong.
Colorama module need to use DCC (I forgot to mention that)
Code:
sudo pip install colorama
Click to expand...
Click to collapse
ok thanks i got i working
---------- Post added at 10:43 AM ---------- Previous post was at 10:21 AM --------- @ferreirawax you got a typing mistake here thats why method 1 didnt work i finaly figured it out:
Export Architecture and Toolchain:
Code:
export ARCH=arm
export CROSS_COMPILE=~/android/mykenel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-
It should be myKERNEL and that it works
Now i succesfully build my kernel but im having problems with bump, i cant get past this:
[email protected]:~$ python open_bump.py ~/android/mykernel/out/boot.img
python: can't open file 'open_bump.py': [Errno 2] No such file or directory
but im sure its there i tryed nearly everything but cant get bumped boot.img

Thank you!!!! I have wanted something like this to compile different kernels .

It would have been totally awesome if @dorimanx did a tutorial once where he shared how he makes his (stock) kernels..anyways will this work on a 11 year old PC with 1gb RAM and 1,7 GHz processor?

any help for bumping boot.img ?

Boris31 said:
any help for bumping boot.img ?
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?p=56987541
(OP gave cmd lines too)

6ril1 said:
http://forum.xda-developers.com/showthread.php?p=56987541
(OP gave cmd lines too)
Click to expand...
Click to collapse
Yeah thanks i finally got it

Norside said:
It would have been totally awesome if @dorimanx did a tutorial once where he shared how he makes his (stock) kernels..anyways will this work on a 11 year old PC with 1gb RAM and 1,7 GHz processor?
Click to expand...
Click to collapse
This is willpower

Boris31 said:
Yeah thanks i finally got it
Click to expand...
Click to collapse
Now you have what start modifying your kernel!

ferreirawax said:
Now you have what start modifying your kernel!
Click to expand...
Click to collapse
Yeah finally i'v built a kernel now i need to learn to modify it. Any good guide for that maybe

Boris31 said:
Yeah finally i'v built a kernel now i need to learn to modify it. Any good guide for that maybe
Click to expand...
Click to collapse
For that you need to read a little about git, then see the changes made by other developers and place them in your own kernel.

ferreirawax said:
For that you need to read a little about git, then see the changes made by other developers and place them in your own kernel.
Click to expand...
Click to collapse
Thanks, I'm finally beginning to understand Linux terminal commands.

@ferreirawax
I am aware that the rules prohibit posting simple thanks but I feel duty do it here because it is really nice to find shared topics showing how to fish rather than giving fish.
Big thank you to you so, great initiative !

@ferreirawax
Thanks for taking the time to post this. I would love for more people to try their hand at Custom Kernels! Otherwise you end up with the same kernel, different name.

DTB combiner:
Input directory: '/home/bolt890/dev/dcc/msm8974/aosp/arch/arm/boot/'
Output file: '/home/bolt890/dev/dcc/outputs/dt.img'
Found file: msm8974-v2-2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-v2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
=> Found 0 unique DTB(s)
error: dt.img not found, failed to make target
Keep getting this error

bolt890 said:
DTB combiner:
Input directory: '/home/bolt890/dev/dcc/msm8974/aosp/arch/arm/boot/'
Output file: '/home/bolt890/dev/dcc/outputs/dt.img'
Found file: msm8974-v2-2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-v2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
=> Found 0 unique DTB(s)
error: dt.img not found, failed to make target
Keep getting this error
Click to expand...
Click to collapse
Seem to lack the DTC binary on your system. Download the attachment and follow:
Code:
sudo cp ~/dtc.zip /usr/bin/dtc
Or you can simply remove the extension and copy the file to /usr/bin any other way, may be necessary to a log-in/out for effect. Then compile again.

Related

[AS AT 04/08][AOSP/CM7/ICS/CM9][GUIDE]Wanna try compiling for Galaxy Ace?

Hello everyone yet again
Info: This also works for CM7 , just that the Cooper repo is already natively included in the files and folders , so you can skip step 2.5
I'm creating a new thread for all those people who know a little bit of code but don't know what to do to compile for Galaxy Ace (AOSP or CM7).
THANKS TO http://source.android.com and http://wiki.cyanogenmod.com
32-bit computers are not recommended to compile Gingerbread and above versions!
For now, I'll cover AOSP. (I'll show a CM7 guide once I learn how to compile it)
Alright, to compile Gingerbread AOSP you'll need a computer that has:
-At least an Intel Core i3 at 2.4Ghz or a similar AMD processor
-4GB RAM (my RAM speeds are at 1333Mhz). If lesser RAM, then swap is needed (for 2GB RAM use 15GB swap, that what I used before)
-40GB Partition for single compilation or 80GB for multiple versions (NOT including Ubuntu installation)
-Ubuntu 10.04 LTS OR Mac OSX 10.6 (other versions of Ubuntu, including 09.10 or lower or 10.10 or higher, may not work as well as 10.04)(Same thing goes for Snow Leopard, Lion has certain problems)
Here's how to compile for Gingerbread:
Step 1: Setting up the build environment.
Linux:
In general you will need:
-Python 2.4 - 2.7
-JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older.
-Git 1.7 or newer.
To install Sun JDK 6 do the following:
Code:
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
You will also need to install certain packages:
For 64-bit computers:
Code:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils
For 32-bit computers (experimental):
Code:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev \
libx11-dev libreadline6-dev libgl1-mesa-dev tofrodos python-markdown \
libxml2-utils
(***NOTE: I've gotten errors when trying to apt-get install lib32ncurses5-dev.)
IF you're on Ubuntu 11.10 you might need to do this:
Code:
$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
Now for OSX (taken from http://source.android.com):
To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.6 (Snow Leopard).
Android must be built on a case-sensitive file system because the sources contain files that differ only in case. We recommend that you build Android on a partition that has been formatted with the journaled file system HFS+. HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OSX.
If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead. To create the image, launch Disk Utility and select "New Image". A size of 25GB is the minimum to complete the build, larger numbers are more future-proof. Using sp**** images saves space while allowing to grow later as the need arises. Be sure to select "case sensitive, journaled" as the volume format.
You can also create it with this:
Code:
# hdiutil create -type SP**** -fs 'Case-sensitive Journaled HFS+' -size Xg ~/android.dmg
Where "X" is how big your image will be (in GB).
This will create a .dmg (or possibly a .dmg.sp****file) file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your ~/.bash_profile to mount the image when you execute "mountAndroid":
Code:
# mount the android file image
function mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }
Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.
Installing required packages:
-Install XCode from the Apple developer site. We recommend version 3.1.4 or newer, i.e. gcc 4.2. Version 4.x could cause difficulties. If you are not already registered as an Apple developer, you will have to create an Apple ID in order to download.
-MacPorts from http://macports.org
Note: Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, add:
Code:
export PATH=/opt/local/bin:$PATH
to your ~/.bash_profile.
-Get make, git, and GPG packages from MacPorts:
Code:
$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
If you're on MacOS 10.4, install bison too:
Code:
$ POSIXLY_CORRECT=1 sudo port install bison
Bugs and fixes:
-Reverting from gmake3.82:
There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using MacPorts by taking the following steps:
-Edit /opt/local/etc/macports/sources.conf and add a line that says:
Code:
file:///Users/Shared/dports
above the rsync line. Then make this directory:
Code:
$ mkdir /Users/Shared/dports
-In the new dports directory, run:
Code:
$ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
-Create a port index for your new local repository:
Code:
$ portindex /Users/Shared/dports
-Finally, install the old version of gmake with:
Code:
$ sudo port install gmake @3.81
-Setting a file descriptor limit:
On MacOS the default limit on the number of simultaneous file descriptors open is too low and a highly parallel build process may exceed this limit.
To increase the cap, add the following lines to your ~/.bash_profile:
Code:
# set the number of open files to be 1024
ulimit -S -n 1024
Your Linux/MacOS build environment is now complete, moving on to downloading....
Step 2: Downloading the source
You'll need to use repo to download sources from repositories.
Here's how I did it:
-Make a /bin directory in your home directory and it must be in your PATH:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
-Download the Repo script and ensure that it can be executed:
Code:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Now that downloading repo is done and executable, we need to initialise it.
Create an empty directory for where all your Android files will be downloaded, stored and made:
Code:
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
Where WORKING_DIRECTORY can be any name you want (as long as it has no spaces)
Use repo init to grab the latest branch (or rather, the gingerbread branch)
Code:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-x.x.x_r1
Where "x" can be 2.3, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6 or 2.3.7.
For now use the versions that the Galaxy Ace currently has (2.3.3-2.3.5 and 2.3.7)
Optional step:
When prompted, please configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.
Click to expand...
Click to collapse
Once you're done with that, you'll need to download them.
This simple 8-character command is easy to execute but it'll be hard on your internet connection:
Code:
$ repo sync
Ensure that you have at least 5Mbps of internet if you want it completed in a day.
Once you're done syncing, use this code:
Code:
$ gpg --import
To sign what you've downloaded.
Once you entered that, copy and paste this long line of ****:
Code:
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv
aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k
cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX
gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI
2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl
QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up
hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk
C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX
LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+
OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M
pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----
Paste it into your terminal and press Ctrl+D.
You now have a complete local copy of the Android codebase.
Step 2.5: Include the Samsung COOPER source for compilation (AOSP only)
Yes, this has to be done so you can compile for cooper (Samsung Galaxy Ace).
-Navigate the terminal to the ~/WORKING_DIRECTORY/device/samsung folder:
Code:
$ cd ~/WORKING_DIRECTORY/device/samsung
Where WORKING_DIRECTORY = your android folder
-Make use of git to clone a folder from PabloPL's GitHub:
Code:
$ git clone git://github.com/PabloPL/android_device_samsung_cooper
Once it's done, you should see a folder with that name in the root of your working directory. Rename it to "cooper" and cut & paste it to device/samsung.
Download the Android SDK Tools and make sure you set ADB correctly to be in your PATH.
For more info and how-to steps go here: http://www.lineardroid.co.uk/2010/04/how-to-set-up-adb-in-ubuntu/
Once you're done setting up ADB, go to the cooper folder and run extract-files.sh in the terminal.
ADB should pull some files from your device and automatically close the terminal. (You might need to be in CM7 for ADB to successfully pull all libs, I may be wrong though. Someone test it and tell me if it works)
Now we're done for now.
Oh yes, before I forget:
Have a copy of CM7 before you build!
AOSP does not fully support ARMv6 devices and therefore uneeded errors may arise, so the CM7 files can save you.
Step 3: Building Android (most exciting/boring part)
Initialize the environment with the envsetup.sh script.
Code:
$ . build/envsetup.sh
Choose your target to build with lunch.
Code:
$ lunch cooper-eng
(***NOTE: Change full_base.mk in device_cooper.mk to full.mk) (AOSP only)
(***NOTE2: There'll be another error about an unknown architecture: ARMv6-VFP. That's where your CM7 files come in handy.) (AOSP only)
Build everything with make. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. E.g. on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.
I usually use this (thanks to cdesai):
Code:
$ make -j8 update-api
$ make -j8 otapackage
OR:
Code:
$ make -j16 update-api
$ make -j16 otapackage
Do have patience because your computer will get inevitably laggy.
Once you're done debugging all errors and stuff you will have a flashable .zip located in WORKING_DIRECTORY/out/target/cooper.
Thanks for reading this whole chunk, though I know it's an XDA App eyesore.
If you do encounter errors feel free to ask here
Alright, now you've built AOSP and CM7 and you love it, what next?
Ice Cream Sandwich *insert holy choir here*
Requirements (they are much more different now):
A computer that's capable of 64-bit
A dual-core processor of a speed of at least 2.2Ghz (Intel Xeon/Core i7 recommended)
Either Ubuntu 10.04 LTS 64-bit (later versions have experimental support) but if you're using a later version that's fine.
Or Mac OSX 10.6
At least 8GB of RAM and 10~GB swap maybe? (Otherwise you could have 4Gb of RAM and ~20GB swap this time)
At least a 70GB partition for Ubuntu (to make sure there is space for compiling + installing required stuff)
Well, here are the steps to build it:
Instructions (Taken from http://source.android.com/source/initializing.html & http://wiki.cyanogenmod.com/wiki/Android_SDK_Emulator:_Compile_CyanogenMod_(Linux)):
---------ONLY FOR UBUNTU 10.10--12.04---------
Chapter 1: Initializing a Build Environment
This section describes how to set up your local work environment, how to use Repo to get the Android files, and how to build the files on your machine. To build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported.
Note: The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 90GB (or more) for a full set of builds.
Section 1 (Linux/Ubuntu): Setting up a Linux build environment
The Android build is routinely tested in house on recent versions of Ubuntu LTS (10.04), but most distributions should have the required build tools available. Reports of successes or failures on other distributions are welcome.
Note: It is also possible to build Android in a virtual machine. If you are running Linux in a virtual machine, you will need at least 16GB of RAM/swap and 30GB or more of disk space in order to build the Android tree.
In general you will need:
Python 2.5 -- 2.7.
GNU Make 3.81 -- 3.82.
JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older.
Git 1.7 or newer.
Detailed instructions for Ubuntu 10.04+ follow.
Step 1: Installing the JDK
The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used.
To download Java 6, do this:
Code:
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
Note: The lunch command in the build step will ensure that the Sun JDK is used instead of any previously installed JDK.
Alternatively you can follow eoghan2t7's instructions:
eoghan2t7 said:
as you may no the Java JDK has been removed from the ubuntu ppa so i have uploaded the jdk deb file for users to use and to skip the sudo apt-get install java_jdk command
link
http://www.mediafire.com/?b57gqo7t46k1ibc
Click to expand...
Click to collapse
Or bs828's instructions:
bs828 said:
I'm currently out will do later
Edit: im on 12.0.4 and this seemed to work http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7/
Click to expand...
Click to collapse
Step 2: Installing required packages (Ubuntu 10.04 -- 11.10)
You will need a 64-bit version of Ubuntu. Ubuntu 10.04 is recommended. Building using a newer version of Ubuntu is currently only experimentally supported and is not guaranteed to work on Git branches other than master (http://github.com/android).
To install the required packages, do this:
Code:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc
---------ONLY FOR UBUNTU 10.10--11.10---------
For Ubuntu 10.10 users, do this as well:
Code:
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
Note: This is used to avoid a compile error with libGL later on.
For Ubuntu 11.10 users, do this:
Code:
$ sudo apt-get install libx11-dev:i386
---------END FOR UBUNTU 10.10--11.10---------
----------ONLY FOR UBUNTU 12.04----------
Step 2: Installing required packages (Ubuntu 12.04)
Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master.
To install the required packages, do this:
Code:
$ sudo 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-dev:i386 \
g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown \
libxml2-utils xsltproc zlib1g-dev:i386
---------END FOR UBUNTU 10.10--12.04---------
I won't do MacOSX for ICS, mainly because it has a very unstable success chance of compilation.
Your build environment is good to go! Proceed to
Chapter 2: Downloading the Source Tree
Section 1: Repo
Repo is a tool that makes it easier to work with Git in the context of Android.
It is also a tool that allows you to download source files from Android easily.
Step 1: Installing Repo
To install, initialize, and configure Repo, follow these steps:
Make sure you have a bin/ directory in your home directory, and that it is included in your path:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
Download the Repo script and ensure it is executable:
Code:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
For version 1.15, the SHA-1 checksum for repo is 8eb56d98b36d615c3efec51868e87bebe757feb1
For version 1.16, the SHA-1 checksum for repo is f3bfa7fd2d0a44aa40579bb0242cc20df37b5e17
Step 2: Initializing a Repo client
After installing Repo, set up your client to access the android source repository:
Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:
Code:
$ mkdir I_HATE_STEVE
$ cd I_HATE_STEVE
Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.
For AOSP:
Code:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.1_r1
or
Code:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.1_r2
or
Code:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.1_r3
or even
Code:
$ repo init -u https://android.googlesource.com/platform/manifest -b ics-plus-aosp
For CM9:
Code:
$ repo init -u git://github.com/CyanogenMod/android.git -b ics
When prompted, please configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.
A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.
Step 3: Getting the files
To pull down files to your working directory from the repositories as specified in the default manifest, run
Code:
$ repo sync
The Android source files will be located in your working directory under their project names. The initial sync operation will take an hour or more to complete, depending on your Internet bandwidth.
Note: If you initialize your repo on your root area for all projects, the time for downloading will decrease
If you haven't set up ccache now, now is a good time to set it up.
Chapter 2.5 (AOSP only): Downloading the various device specific configurations from GitHub
Now that you have a full copy of AOSP, you will realise that inside your working directory/device you will only see only a few device configurations. That's because AOSP only supports those devices and you will need to manually download other devices for use with AOSP.
You can either adapt from MaclawStudios' repo of the Galaxy Gio: https://github.com/MaclawStudios/android_device_samsung_gio
Or make an ICS device config yourself.
Meanwhile PabloPL has made an ICS branch here, but currently nothing is being worked on, as it seems.
Chapter 3: Building the System
The basic sequence of build commands is as follows:
Step 1: Initialize
Initialize the environment with the envsetup.sh script. Note that replacing "source" with a single dot saves a few characters, and the short form is more commonly used in documentation.
Either:
Code:
$ source build/envsetup.sh
or
Code:
$ . build/envsetup.sh
Step 2: Choose a target
Choose which target to build with lunch. The exact configuration can be passed as an argument, e.g.
Code:
$ lunch full-eng
The example above refers to a complete build for the emulator, with all debugging enabled.
If run with no arguments lunch will prompt you to choose a target from the menu.
Step 3: Build the Code
Build everything with make. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. E.g. on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.
If you are using a dual-core computer do either of these:
Code:
make -j2
or
Code:
make -j4
It is usually recommended that you make the -jN amount twice the number of cores your processor has.
Therefore if you have a quad-core processor do this:
Code:
make -j4
or
Code:
make -j8
There are different ways to run make:
Code:
$ make clean
or
Code:
$ make clobber
Cleans the compile directory and deletes all compiled files.
Code:
$ make update-api
Makes part of the framework, usually used to update the API.
Code:
make otapackage
Makes a flashable .zip file, as otapackage = Over The Air package.
Code:
make (app name, like framework-res)
Makes the specified app and the .apk will be compiled in the output directory.
Once you finish make, you are done! Congratulations!
Chapter 4: Troubleshooting Common Build Errors
Sometimes, things don't go as planned such as unexpected build errors. Here are some solutions to common problems:
Section 1: Wrong Java Version
If you are attempting to build froyo or earlier with Java 1.6, or gingerbread or later with Java 1.5, make will abort with a message such as
Code:
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: WRONG_VERSION.
The correct version is: RIGHT_VERSION.
Please follow the machine setup instructions at
https://source.android.com/source/download.html
************************************************************
This may be caused by:
failing to install the correct JDK as specified on the Initializing chapter. Building Android requires Sun JDK 5 or 6 depending on which release you are building.
another JDK that you previously installed appearing in your path. You can remove the offending JDK from your path with:
Code:
$ export PATH=${PATH/\/path\/to\/jdk\/dir:/}
Section 2: Python Version 3
Repo is built on particular functionality from Python 2.x and is unfortunately incompatible with Python 3. In order to use repo, please install Python 2.x:
Code:
$ apt-get install python
Optional Step: Setting up ccache
You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products.
Put the following in your .bashrc or equivalent.
Code:
$ export USE_CCACHE=1
By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.
Code:
$ export CCACHE_DIR=
The suggested cache size is 50-100GB. You will need to run the following command once you have downloaded the source code, if you use CCache.
Code:
$ prebuilt/linux-x86/ccache/ccache -M 50G
Optional Step: Using a separate output directory
By default, the output of each build is stored in the out/ subdirectory of the matching source tree.
On some machines with multiple storage devices, builds are faster when storing the source files and the output on separate volumes. For additional performance, the output can be stored on a filesystem optimized for speed instead of crash robustness, since all files can be re-generated in case of filesystem corruption.
To set this up, export the OUT_DIR_COMMON_BASE variable to point to the location where your output directories will be stored.
Code:
export OUT_DIR_COMMON_BASE=
The output directory for each separate source tree will be named after the directory holding the source tree.
For instance, if you have source trees as /source/master1 and /source/master2 and OUT_DIR_COMMON_BASE is set to /output, the output directories will be /output/master1 and /output/master2.
It's important in that case to not have multiple source trees stored in directories that have the same name, as those would end up sharing an output directory, with unpredictable results.
This is only supported on branches newer than 4.0.x (IceCreamSandwich).
Wow dude. That's all I can say.
Woohoo, read through all that but I wont wanna try, and my comp is a piece of ****
Sent from my Galaxy Ace running J.A.F CM 7.2 Odexed using XDA App
MrChaosDesire said:
Woohoo, read through all that but I wont wanna try, and my comp is a piece of ****
Sent from my Galaxy Ace running J.A.F CM 7.2 Odexed using XDA App
Click to expand...
Click to collapse
Those are the recommended specs , not minimum
Wow nice tutorial Matt.but I can do nothing bcz i don't Know how to do coding lol...........
Sent from my GT-S5830 using xda premium
Lot of things to install, thanks for the tuto!
You never fail to impress buddy
Sent from my HTC Sensation XL with Beats Audio X315e using Tapatalk
traduz said:
Lot of things to install, thanks for the tuto!
Click to expand...
Click to collapse
Any errors occured ? Just post them in the thread .
Any solutions for unsolved errors ? Post them here too . Will update solutions
Sent from my GT-S5830 using XDA App
nice tut's bro..
Well i'm reading this day by day, just w8ing for money for a new computer lol, got one with 1gb only and freezes a lot with it =/
Thanks man, its gonna be my little anti-social project for tomorrow
Sent from my GT-S5830 using xda premium
Nice tut,Matt
thanks....everything clear from your tutorial......
one question : how much downloading will be done for AOSP and CM7 both....if i want to work on gingerbread
rocking.nitesh007 said:
thanks....everything clear from your tutorial......
one question : how much downloading will be done for AOSP and CM7 both....if i want to work on gingerbread
Click to expand...
Click to collapse
I think at least 50GB
thanx ...... will download it ill tke days .....
Sent from my GT-S5830 using XDA App
i have installed ubuntu 11 64bit in vmware .... does it affect when the rom ill be compling.....i use 3.2gb of 4gb ram in my virtual machine
Sent from my GT-S5830 using XDA App
rocking.nitesh007 said:
i have installed ubuntu 11 64bit in vmware .... does it affect when the rom ill be compling.....i use 3.2gb of 4gb ram in my virtual machine
Sent from my GT-S5830 using XDA App
Click to expand...
Click to collapse
If you're compiling gingerbread , there's no problem .
Sent from my GT-S5830 using XDA App
EmoBoiix3 said:
If you're compiling gingerbread , there's no problem .
Sent from my GT-S5830 using XDA App
Click to expand...
Click to collapse
thanks..... waiting for cm7 tut also ..... u guys rock
Sent from my GT-S5830 using XDA App
one more question .... what about 50GB .... i means i have read in different places somebody says its arnd 2GB of source of cm .. if u can specify dat would be great....
Sent from my GT-S5830 using XDA App

Guide on how I build my own CM10 test builts

This is a follow up on my "old" "Guide on how I build my own CM9 test builts" thread.
Guide how I build CM10 for my Mango.
For the first time you try to build CM10.
Create ~/bin and download repo to that directory. Afterwards set executable bit to make it possible to ”execute”.
Code:
mkdir -p ~/bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now reboot the computer.
Create ~/android/system and initialize the repository.
Code:
mkdir -p ~/android/system
cd ~/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b jellybean
Unpack the attached local_manifest.xml.bz2 and place local_manifest.xml into ~/android/system/.repo
Synchronise towards the current git repositories.
Code:
repo sync
Setup the environmental settings and initialize the Mango build.
Code:
. build/envsetup.sh
breakfast mango
Initialize the Mango build.
Code:
cd ~/android/system/device/semc/mango/
./setup-makefiles.sh
Download the prebuilts
Code:
~/android/system/vendor/cm/get-prebuilts
Check for new changes
Code:
cd ~/android/system/
repo sync
Setup the environment again and build the ROM (takes long time)
Code:
. build/envsetup.sh
brunch mango
You will now find the build here (change DATE into the date).
~/android/system/out/target/product/mango/cm-10-DATE-UNOFFICIAL-mango.zip
The next times you try to build it, you only need to do the following.
Delete build.prop, if not will build.prop not get generated.
Code:
rm -f ~/android/system/out/target/product/mango/system/build.prop
Syncronise the git repositories.
Code:
cd ~/android/system/
repo sync
Setup the environmental settings.
Code:
. build/envsetup.sh
Configure/build.
Code:
brunch mango
You will now find the build here (change DATE into the date).
~/android/system/out/target/product/mango/cm-10-DATE-UNOFFICIAL-mango.zip
EDIT (August 14. 2012): If the boot.img is not booting, is it most likely due to the bootloader bug.
To make it "work", do the following (replace mango with your own device)
Code:
cd out/target/product/mango/
rm -f ./boot.img ./combinedroot.cpio ./combinedroot.fs ./ramdisk.img
cp ./root/logo.rle ./root/waste_of_space1
cp ./root/logo.rle ./root/waste_of_space2
cp ./combinedroot/logo.rle ./combinedroot/waste_of_space1
cp ./combinedroot/logo.rle ./combinedroot/waste_of_space2
cd ../../../..
brunch mango
just a technical: is it really necessary to reboot the computer after downloading the repo binary? and if so, why is that??
bokrug said:
just a technical: is it really necessary to reboot the computer after downloading the repo binary? and if so, why is that??
Click to expand...
Click to collapse
It is only necessary on some Linux distributions, where you will not be able to execute anything from that directory, before a reboot. You can try to see if you can do it without. If it is working, do you not need it.
hnl_dk said:
It is only necessary on some Linux distributions, where you will not be able to execute anything from that directory, before a reboot. You can try to see if you can do it without. If it is working, do you not need it.
Click to expand...
Click to collapse
There's no really need to reboot - edit .bashrc in your home directory and add
Code:
export PATH=~/bin/:$PATH
Save, then run:
Code:
source ~/.bashrc
It have to work on all distros
pikpok said:
There's no really need to reboot - edit .bashrc in your home directory and add
Code:
export PATH=~/bin/:$PATH
Save, then run:
Code:
source ~/.bashrc
It have to work on all distros
Click to expand...
Click to collapse
I just want to show the "universal" way.
Not everyone is using bash
hnl_dk said:
I just want to show the "universal" way.
Not everyone is using bash
Click to expand...
Click to collapse
If someone use another shell, e.g. zsh, then he'll know what files he have to edit IMO rebooting is wasting time.
pikpok said:
If someone use another shell, e.g. zsh, then he'll know what files he have to edit IMO rebooting is wasting time.
Click to expand...
Click to collapse
no it is not, as you do not need to edit any files. It will work automatically.
It is as much a waste of time to edit the resource-definition scripts.
hnl_dk said:
no it is not, as you do not need to edit any files. It will work automatically.
It is as much a waste of time to edit the resource-definition scripts.
Click to expand...
Click to collapse
Reboot - about 1 min
Edit one file and paste single command in terminal - for me it's 10secs
But it comes to offtop discussion, so it would be better to end it now
@edit - now when I think about it... bin in home folder won't be added to PATH automatically, at least in Arch Linux. Maybe Ubuntu is more "intelligent" :laugh:
pikpok said:
Reboot - about 1 min
Edit one file and paste single command in terminal - for me it's 10secs
But it comes to offtop discussion, so it would be better to end it now
@edit - now when I think about it... bin in home folder won't be added to PATH automatically, at least in Arch Linux. Maybe Ubuntu is more "intelligent" :laugh:
Click to expand...
Click to collapse
It does not take that long for me to make a reboot
No matter what, is it always good to have more methods to make something work.
It did the last time I tried Arch Linux... and no I am not using Ubuntu (too flashy for me )
Assuming that there is an entry in your ~/.profile that adds ~/bin to PATH, a reboot won't do anything that logout/login wouldn't. Furthermore, logout/login (in this case) won't do anything that sourcing ~/.profile wouldn't. So, simply issuing "source ~/.profile" is sufficient on most distributions. If you are using a distribution or a shell that doesn't do this by default, then you probably already know what you need to do.
I do, however, commend hnl_dk's efforts to make things simpler for newcomers to Android and Linux, even if it's not the the "fastest" or the "best" way. Whenever you start getting into one of those "what if?" arguments, things tend to spiral out of control. Sometimes it's better to just make a few assumptions and go with what is most likely to work.
A reboot might be a bit of an overkill, though. :laugh:
Can't run 64-bit prebuilts on my 32-bit Linux
I have a 32-bit Linux box so get the errors:
/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc: cannot execute binary file
Had a quick look around, but are there gcc etc. prebuilts for 32-bit Linux boxes?
TIA,
AK-A
ak-a said:
I have a 32-bit Linux box so get the errors:
/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc: cannot execute binary file
Had a quick look around, but are there gcc etc. prebuilts for 32-bit Linux boxes?
TIA,
AK-A
Click to expand...
Click to collapse
Did you try to build it as described?
It is working fine on my 32bit debian machine.
If not, please describe hos you try it build it.
hnl_dk said:
Did you try to build it as described?
It is working fine on my 32bit debian machine.
If not, please describe hos you try it build it.
Click to expand...
Click to collapse
Yeah, followed the instructions as per the first post. Will re-try and see if I missed/messed something and report back.
Hey !!! Do you think I should post my AOSP errors in this thread...so that its easier for us to keep track..?? :highfive:
As this is a Tutorial Thread for "how to build cm10 on your own" I don't think it makes sense posting errormessages of errm. "android open source project"? As I am writing this I recognize that I do not really understand what you mean.
CosmoDroid said:
Hey !!! Do you think I should post my AOSP errors in this thread...so that its easier for us to keep track..?? :highfive:
Click to expand...
Click to collapse
Like Snoopo is saying, should that be in this thread. Compiling AOSP is not as "user friendly" as CM, as our devices are officially supported by CM and not AOSP.
If you want, can you make a new thread about compiling "AOSP - Jelly bean".
i always stop at "repo sync"
i always stop at "repo sync"
and it always tell me
"Fetching projects: 21% (66/313) fatal: unable to connect to github.com:
github.com[0: 207.97.227.239]: errno=??????"
can you help me
thanks
shufuking said:
i always stop at "repo sync"
and it always tell me
"Fetching projects: 21% (66/313) fatal: unable to connect to github.com:
github.com[0: 207.97.227.239]: errno=??????"
can you help me
thanks
Click to expand...
Click to collapse
Same also happens for me, then I try again and again and again and then it is working.
Lots of people are accessing github, and there is only a limited "whole" for the data to get through.
hnl_dk said:
Same also happens for me, then I try again and again and again and then it is working.
Lots of people are accessing github, and there is only a limited "whole" for the data to get through.
Click to expand...
Click to collapse
thanks for your suggestion
finally i make it.
another question.
when i perform " brunch smultron"
i got lots of "cannot execute binary file"
and final "make: *** [out/target/product/smultron/obj/lib/crtbegin_static.o] Error 126"
do you know what it means?
shufuking said:
thanks for your suggestion
finally i make it.
another question.
when i perform " brunch smultron"
i got lots of "cannot execute binary file"
and final "make: *** [out/target/product/smultron/obj/lib/crtbegin_static.o] Error 126"
do you know what it means?
Click to expand...
Click to collapse
without more details, my best guess is that you may be building it on a FAT32 or NTFS partition?
then there is a good chance that linux is not able to read the executable bits.

[CM] Building for expressltexx (GT-I8730)

There's an easy way to do whatever's discussed below, except for a) getting the SDK, b) syncing the repos, and c) building the ROM; and that way is using this script. But it's still better to do the steps below manually as it gets you acquainted with the terminal - you'll be using it a lot.
Thanks to @klvnhng for the original tutorial for mako
Credits to him.
You will need:
A computer running Ubuntu with at least 2GB memory and around 40-65 GB of free space
If you don't want to install Ubuntu, run it instead in VMWare Player or VirtualBox.
make sure you provide the virtual machine with the amount of recommended disk space or more
give it no less than 3-4GB of RAM
A (preferably fast) internet connection (trust me, you don't want to do this with a 256 or 512 kbps connection)
Familiarity with Android and Linux. Read up at source.android.com.
Setting up the build environment
1. Install JDK
DO NOT USE OPENJDK. Remove it by entering
Code:
sudo apt-get purge openjdk* icedtea* icedtea-6*
Install Oracle Java 6 by typing this into a terminal:
Code:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
Android SDK requires the x86 compatibility packages, ia32-libs. Install it by entering this:
Code:
sudo apt-get -y install ia32-libs
As an alternative, you can also do this (thanks to @jjchico):
Code:
sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
2. Android SDK
Download it here.
Extract it to a folder of your choice (in this guide, I will refer to it as ~/android/sdk).
Enter these commands into the terminal:
Code:
cd ~/android/sdk/adt-bundle/sdk/tools
./android sdk
Click Install packages. cd to ~/android/sdk/adt-bundle/sdk/platform-tools and type:
Code:
./adb
./fastboot
If you've done everything correctly, you should get a big block of text for both (which list all of the adb/fastboot commands).
3. Install required packages
Copy and paste this command into the terminal:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev \
ia32-libs x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 \
lib32z-dev libgl1-mesa-dev g++-multilib mingw32 \
tofrodos python-markdown libxml2-utils xsltproc readline-common \
libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev \
lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 \
libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev \
libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev
4. Install the repo command
Make directories called bin and android in your home folder, respectively.
Code:
mkdir -p ~/bin
mkdir -p ~/android
Download and setup the repo binary:
Code:
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now add it to your path:
Code:
export PATH="$PATH:~/bin"
And make sure it belongs in your path between subsequent reboots:
Code:
echo "export PATH="$PATH:~/android/sdk:~/bin"" >> ~/.bashrc
source ~/.bashrc
5. Configuring USB
You must configure USB to detect your Android device(s) properly.
Do this in a terminal:
Code:
curl https://raw.githubusercontent.com/aureljared/build-env-init/master/51-android.rules > ~/bin/51-android.rules
chmod a+r ~/bin/51-android.rules
sudo cp -vfp ~/bin/51-android.rules /etc/udev/rules.d/51-android.rules
6. Syncing up
The next step is to initialize the repository and download the source code to your computer.
Type the following lines into the terminal:
Code:
mkdir -p ~/android/cm-11.0
cd ~/android/cm-11.0
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
To download all the necessary device-specific files for our device, do this:
Code:
curl https://raw.githubusercontent.com/aureljared/android-manifests/expresslte-cm-11.0/local_manifest.xml >> .repo/local_manifests/local_manifest.xml
Now run
Code:
repo sync
You have now begun downloading all of the CM source code to your build directory. Depending on your internet speed, this can take from a couple of hours to a few days. If the sync interrupts, don't worry. Simply continue the sync (you don't have to restart completely, only the project you were downloading when the interrupt occured, lol) by entering:
Code:
repo sync
Some tips:
You can interrupt the process by pressing Ctrl + C, it will continue where it left off the next time anyway.
Remember, you need to cd into your build directory (~/android/cm-11.0, if you've been following this guide) for the command to work.
If you want only one project to be synced at a time, run repo sync -j1 instead.
This step takes a long time depending on your internet connection speed (FYI you're downloading ~20 GB of code!)
7. Building CM (yay!)
You must download the necessary pre-built apps:
Code:
~/android/cm-11.0/vendor/cm/get-prebuilts
Now let's build! cd to your build directory and run the following commands in the terminal:
Code:
. build/envsetup.sh
brunch expressltexx
Now, just let your computer do the rest. This step is very demanding for your computer, so you better leave it alone while it builds. Usually this takes an hour or more. Go get some sleep or eat something.
Done? If everything went correctly, cd to ~/android/cm-11.0/out/target/product/expresslte and you should see your newly built ROM entitled:
cm-11.0-20xxxxxx-UNOFFICIAL-expressltexx.zip
Congratulations! You've successfully built CM 11.0!
For re-builds (i.e. when the source code has been updated and you would like to make a new nightly), just do this:
Code:
cd ~/android/cm-11.0
make clobber
repo sync
. build/envsetup.sh
brunch expressltexx
Have fun building!​
I suggest you to modify step 5 inserting before repo sync
Code:
mkdir .repo/local_manifests
cd .repo/local_manifests
wget https://raw.github.com/KINGbabasula/android_device_samsung_expresslte/cm-10.2/local_manifest.xml
cd ..
cd ..
This will download the specific necessary repos with repo sync
Then remove this in step 6
Code:
mkdir files
cd files
git clone https://github.com/KINGbabasula/proprietary_vendor_samsung.git
as it isn't needed
And change make clean with make clobber because with clobber it will rebuild faster
EDIT: And before step 6 you need to replace these 2 files with the 2 in the attachment
Code:
system/core/mkbootimg/bootimg.h
system/core/mkbootimg/mkbootimg.c
KINGbabasula said:
I suggest you to modify step 5 inserting before repo sync
Code:
mkdir .repo/local_manifests
cd .repo/local_manifests
wget https://raw.github.com/KINGbabasula/android_device_samsung_expresslte/cm-10.2/local_manifest.xml
cd ..
cd ..
This will download the specific necessary repos with repo sync
Then remove this in step 6
Code:
mkdir files
cd files
git clone https://github.com/KINGbabasula/proprietary_vendor_samsung.git
as it isn't needed
And change make clean with make clobber because with clobber it will rebuild faster
EDIT: And before step 6 you need to replace these 2 files with the 2 in the attachment
Code:
system/core/mkbootimg/bootimg.h
system/core/mkbootimg/mkbootimg.c
Click to expand...
Click to collapse
Original post updated.
Can you help me with ia32-libs?
It says that it's referred to by a handful of other packages but it has no installation candidates or something. The bottom line is that I can't install it.
I'm using 13.10 x64 on an ASUS K43SJ.
- Intel i5-2410M Quadcore (2.3GHz normal, 2.9GHz Turbo Boost)
- 2GB RAM available to Ubuntu VM
Sent from my International Galaxy Express using Tapatalk 4
aureljared said:
Original post updated.
Can you help me with ia32-libs?
It says that it's referred to by a handful of other packages but it has no installation candidates or something. The bottom line is that I can't install it.
I'm using 13.10 x64 on an ASUS K43SJ.
- Intel i5-2410M Quadcore (2.3GHz normal, 2.9GHz Turbo Boost)
- 2GB RAM available to Ubuntu VM
Sent from my International Galaxy Express using Tapatalk 4
Click to expand...
Click to collapse
You have to apt-get install every missing library one by one
Inviato dal mio GT-I9070 utilizzando Tapatalk
aureljared said:
2. Android SDK
Download it here.
Extract it to a folder of your choice (in this guide, I will refer to it as ~/android/sdk).
Enter these commands into the terminal:
Code:
cd ~/android/sdk/adt-bundle/sdk/tools
./android sdk
Click Install packages. cd to ~/android/sdk/adt-bundle/sdk/platform-tools and type:
Code:
adb
fastboot
Click to expand...
Click to collapse
Shouldn't it be
Code:
./adb
./fastboot
Or have you added the sdk to your path?
I guess the compilation process will need the sdk. How does it find the sdk? Do you need to provide the path anywhere?
Thanks for the great tuto.
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
---------- Post added at 12:08 PM ---------- Previous post was at 11:29 AM ----------
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
jjchico said:
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
---------- Post added at 12:08 PM ---------- Previous post was at 11:29 AM ----------
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
Click to expand...
Click to collapse
jjchico said:
Shouldn't it be
Code:
./adb
./fastboot
Or have you added the sdk to your path?
I guess the compilation process will need the sdk. How does it find the sdk? Do you need to provide the path anywhere?
Thanks for the great tuto.
Click to expand...
Click to collapse
Updated original post.
Sent from my GT-I8730 using Tapatalk
Thanks. Just note the missing double quotes in the export PATH.
Enviado desde mi GT-I9000 mediante Tapatalk
jjchico said:
Thanks. Just note the missing double quotes in the export PATH.
Enviado desde mi GT-I9000 mediante Tapatalk
Click to expand...
Click to collapse
Haha lol sorry. I was very sleepy when I updated last night.
Updated post.
My repo sync is finished with 65 out of 401 projects. ia32-libs now okay thanks to you @jjchico.
Sent from my GT-I8730 using Tapatalk
I get this
[email protected]:~/android/cm-10.2$ repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
No command 'repo' found, did you mean:
Command 'repro' from package 'repro' (universe)
Command 'repl' from package 'nmh' (universe)
Command 'repl' from package 'mailutils-mh' (universe)
Command 'rep' from package 'rep' (universe)
repo: command not found
[email protected]:~/android/cm-10.2$
Any ideas? All seemed good before that
Bazzan
Check that repo is in the bin folder in your user main folder.
Check that repo is executable
chmod a+x ~/bin/repo
Enviado desde mi GT-I9000 mediante Tapatalk
"6. Building CM (yay!)"
"In order to make a working build, you have to get the proprietary files (mainly device build files and drivers) for the device."
so how do I get the propriety files and where do I put them? ADB from your phone?
After this you direct us to prebuilt apps so it appears there is a step missing unless I am pulling proprietary files down from KINGbabasula's Github
Bazzan
bazzan said:
"6. Building CM (yay!)"
"In order to make a working build, you have to get the proprietary files (mainly device build files and drivers) for the device."
so how do I get the propriety files and where do I put them? ADB from your phone?
After this you direct us to prebuilt apps so it appears there is a step missing unless I am pulling proprietary files down from KINGbabasula's Github
Bazzan
Click to expand...
Click to collapse
Yeah, the files are located somewhere in KINGbabasula's github. If you want to use ADB then refer to the text file located in android_device_samsung_expresslte.
Or if you want to download the files themselves, do this in a terminal:
Code:
mkdir proprietary
cd proprietary
git clone https://github.com/KINGbabasula/proprietary_vendor_samsung.git
The files will be located in proprietary/proprietary_vendor_samsung/expresslte.
Sent from my GT-I8730 using Tapatalk
Finally got build going. Thanks for the tutorial @aureljared. You were not kidding when you said takes a while. Not too sure where to from here. Welcome suggestions if anyone wants me to try anything
Bazzan
URGENT
Before proceeding to build any more ROMs, let me ask some questions.
What toolchain for building the kernel are you using? Toolchains that might work are arm-eabi-4.4.3 upwards or linaro 4.4.3 upwards.
What is your configuration for the kernel? It is written to a file called ".config" insinde the kernel source.
Have you applied any kind of patch to the code before compiling? If so, what?
Click to expand...
Click to collapse
Thank you for your time. Your answers to the above questions will be highly appreciated and will be of utmost importance. There is also a good chance that we might build a proper kernel with your reports!
:good: :victory:
Sent from my GT-I8730 using Tapatalk
aureljared said:
URGENT
Before proceeding to build any more ROMs, let me ask some questions.
What toolchain for building the kernel are you using? Toolchains that might work are arm-eabi-4.4.3 upwards or linaro 4.4.3 upwards.
What is your configuration for the kernel? It is written to a file called ".config" insinde the kernel source.
Have you applied any kind of patch to the code before compiling? If so, what?
Thank you for your time. Your answers to the above questions will be highly appreciated and will be of utmost importance. There is also a good chance that we might build a proper kernel with your reports!
:good: :victory:
Sent from my GT-I8730 using Tapatalk
Click to expand...
Click to collapse
No toolchain experience at all. Just substituted kernels from elsewhere. Maybe if you are leaning toward Linaro, I should find myself a tutorial for arm-eabi-4.4.3 upwards and give that a go. then we can cover more ground.
Bazzan
bazzan said:
No toolchain experience at all. Just substituted kernels from elsewhere. Maybe if you are leaning toward Linaro, I should find myself a tutorial for arm-eabi-4.4.3 upwards and give that a go. then we can cover more ground.
Bazzan
Click to expand...
Click to collapse
Sure.
I'm not saying that I'm relying on Linaro now, it's just that Linaro is a toolchain developed by a consortium of technology companies including Samsung that aims to build Linux kernels that perform extremely well on mobile devices.
CM 10.2 uses Linaro 12.09, I think.
I tried building with Linaro a couple of days ago but make threw me some errors, the most confusing being something like this
Code:
make [cypress_touchkeys.o] *** Error 2
I don't even know what Cypress is.
Sent from my GT-I8730 using Tapatalk
aureljared said:
Sure.
I'm not saying that I'm relying on Linaro now, it's just that Linaro is a toolchain developed by a consortium of technology companies including Samsung that aims to build Linux kernels that perform extremely well on mobile devices.
CM 10.2 uses Linaro 12.09, I think.
I tried building with Linaro a couple of days ago but make threw me some errors, the most confusing being something like this
Code:
make [cypress_touchkeys.o] *** Error 2
I don't even know what Cypress is.
Sent from my GT-I8730 using Tapatalk
Click to expand...
Click to collapse
Cannot help with Cypress. Some time ago I downloaded a file called GT-I8730_JB_Opensource.zip - not sure where I found it.
It appears to be what is says it is. Within it is a text file called README_Kernel.txt
It has the following
################################################################################
1. How to Build
- get Toolchain
From android git server , codesourcery and etc ..
- arm-eabi-4.4.3
- edit Makefile
edit "CROSS_COMPILE" to right toolchain path(You downloaded).
EX) export CROSS_COMPILE= $(android platform directory you download)/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
Ex) export CROSS_COMPILE=/usr/local/toolchain/arm-eabi-4.4.3/bin/arm-eabi- // check the location of toolchain
$ export ARCH=arm
$ make msm8930_express_defconfig
$ make
2. Output files
- Kernel : arch/arm/boot/zImage
- module : drivers/*/*.ko
3. How to Clean
$ make clean
################################################################################
Way out of my depth but will try sometime next week to give it a go with arm-eabi-4.4.3. Major interview Monday so nothing before then.
Bazzan
bazzan said:
Cannot help with Cypress. Some time ago I downloaded a file called GT-I8730_JB_Opensource.zip - not sure where I found it.
It appears to be what is says it is. Within it is a text file called README_Kernel.txt
It has the following
################################################################################
1. How to Build
- get Toolchain
From android git server , codesourcery and etc ..
- arm-eabi-4.4.3
- edit Makefile
edit "CROSS_COMPILE" to right toolchain path(You downloaded).
EX) export CROSS_COMPILE= $(android platform directory you download)/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
Ex) export CROSS_COMPILE=/usr/local/toolchain/arm-eabi-4.4.3/bin/arm-eabi- // check the location of toolchain
$ export ARCH=arm
$ make msm8930_express_defconfig
$ make
2. Output files
- Kernel : arch/arm/boot/zImage
- module : drivers/*/*.ko
3. How to Clean
$ make clean
################################################################################
Way out of my depth but will try sometime next week to give it a go with arm-eabi-4.4.3. Major interview Monday so nothing before then.
Bazzan
Click to expand...
Click to collapse
That's from Samsung. It contains the kernel source as you already have seen
It's stock 3.4.0 so I don't know if it will work with CM :good:
Sent from my GT-I8730 using Tapatalk
Quote from jt1134:
jt1134 said:
I use the d2 family kernel source.
For stock ROMs and CM10, you can use the source and ramdisk provided by samsung.
For CM10.1 or higher, you'll have to get your hands very dirty. IMO the easiest route would be to port the missing drivers from stock samsung source to the msm8930-common kernel, and modifying it to work with them. This is how I did it for the I437 : http://review.cyanogenmod.org/#/c/47947/ . You may then use the serrano device trees as a template once the kernel is ready.
Click to expand...
Click to collapse
Updated first post with this info.
Sent from my GT-I8730 using Tapatalk

[GUIDE][COMPLETE] All in one Android Development [NOOB FRIENDLY]

Hi All,
I and @akhilnarang decided to post this guide to help anyone wanting to learn building of Roms and kernels. We will be using Ubuntu 14.04 Trusty Tahr here.
You can find instructions to install it elsewhere, just remember rom building needs 64bit OS, minimum 4GB RAM, and 100GB space on HDD. Kernel can be built on less hardware, but will take long
Make sure you have fast net, as you have to download at least 16GB of ROM sources, or more kernel, only 1GB of sources max.
Be prepared to spend a lot of time downloading, learning, and fixing bugs
More RAM, or faster CPU, or SSD will speed up the process.
From our personal experiences we have found that this is the best, stable, up-to-date version of Ubuntu yet. This has come from my trial and errors, searching all over the web, and bits I picked up from here and there.
We will move Rom building part when we completed this step properly. Step by step we will learn compiling kernel, using Github, Gerrit, Cherry-picking.
At the end of the post I have linked a script by @akhilnarang which if run will automatically install all these programs for lazy people like us haha [emoji14]
If you not interested to do all procedure from below just use the script. Simply it will automatically configure the build environment.
NOTE-------- some of these packages may already be on your machine. Obviously, if you complete a step and you have one of these installed, the machine simply will not do anything. So...it will not hurt anything. Some of the packages are different from Ubuntu 12.04 and 13.04 (use these packages for Ubuntu 14.04 as many of the old ones have obsoleted - these are new replacements).
So if you set up your pc with Ubuntu we are good to go.
All code will be in code boxes like this:
Code:
$
means you have to run that command in the terminal (don't type the $).
All commands with sudo, gksudo, or gksu means it requires root permission.
It will ask for password.
Once you type, then in that terminal session it will not ask you for a few minutes again.
Any time you make changes to .bashrc or .profile file, make sure to run
Code:
$ source ~/.bashrc
$ source ~/.profile
Or exit and open new terminal else the changes will not take place
Setting up build environment:
Installing Java JDK
Note: You need JDK 7 when you willing to compile Lollipop. If you wanna compile KitKat or lower you need JDK 6.
Open terminal (CTRL + ALT + T)
Then execute the following commands in terminal one by one:
Download & install java
Code:
$ sudo apt-get update && sudo apt-get install openjdk-7-jdk openjdk-7-jre
CHECK if java properly installed or not
Code:
$ java -version
If you get output like
Code:
java version "1.7.0_79"
on the first line then all is good
Now JDK is configured!
Note: Only for Ubuntu 14.04 or higher
Installing Required Packages
Open Terminal
Now execute this command:
Note: This will take some time, has to download about 500MB or so of packages
Code:
$ sudo apt-get update && sudo apt-get install git-core python gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-7-jdk pngcrush schedtool \
libxml2 libxml2-utils xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib liblz4-* android-tools-adb android-tools-fastboot ccache
Configuring USB Access
Now we need to set permissions so that our USB ports can detect our android devices [emoji14]
Type in the following commands, it will download a file with the permissions, give it permission to execute, and restart the service.
Code:
$ sudo curl --create-dirs -L -o /etc/udev/rules.d/51-android.rules -O -L https://raw.githubusercontent.com/snowdream/51-android/master/51-android.rules
$ sudo chmod 644 /etc/udev/rules.d/51-android.rules
$ sudo chown root. /etc/udev/rules.d/51-android.rules
$ sudo service udev restart
$ sudo killall adb
ADB & Fastboot are configured
Installing Repo Package
Open terminal and type:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Configure Git
Open terminal and type:
Code:
$ git config --global user.email ""
$ git config --global user.name ""
Git is configured.
Configure ccache
Open terminal and type:
Code:
$ gksu gedit ~/.bashrc
Enter these lines
Code:
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
Save & close
Open terminal & execute:
Code:
$ source .bashrc
$ ccache -M 50G
I usually use 50 gigs. You can use more if you have more space, or build for many devices
Make a GitHub account using the same email address you used for configuring git
Then follow these
So if you not interested in doing above all steps then simply use this script by my friend @akhilnarang
Open terminal and type:
Code:
$ sudo apt-get install git-core
then do
Code:
$ git clone https://github.com/akhilnarang/scripts.git
$ cd scripts
$ . build-environment-setup.sh
This script will install all required packages
Congrats
YOUR BUILD ENVIROMENT IS NOW SETUP
Now move onto #2nd post for Git and repo tutorial
To be continued
How To Use Git!
Now, to explain about git
Its a version control system, for code, like mercurial or subversion
Most android source code is either at AOSP
Most custom ROMs like CyanogenMod,Radium, host their code over at GitHub
So to start off, make a GitHub Account!
Here, you will find all the various repositories, full of code
All files are stored in repositories
When browsing a repository, you will see a button called fork
This will make a copy of it in your account, so you can edit it, and even submit changes for approval to the parent account
Now, to download the source of a repository onto your computer, we use git clone command
Code:
$ git clone https://github.com/akhilnarang/scripts
So we download the scripts from my github onto your PC, so we can run them
Now, if you added your ssh key as shown in bottom of post #1, then when cloning a repo from your account, while copying the link from bottom right corner, choose ssh link.
If you, when pushing(uploading)local changes, you will not be prompted for username and password, your ssh key will identify you .
After cloning, cd to the directory
Run
Code:
git remote -v
This will show a list of remotes
Default is origin, i.e. the link you have cloned from
Now once we make our changes locally
Code:
$ git add -A
This stages all modified/added/deleted files to be committed
Code:
$ git commit
This opens a text editor for you to write a commit message for your commit
Just give me brief description of your changes or something :v.
Then
Code:
$ git push <remote-name> HEAD:<branch>
If you have cloned, then remote will be origin
Branch can be checked by
Code:
git branch
, and also online from where you cloned
If you used https:// URL then you will be prompted for username and password to authenticate yourself
If git:// URL you can't push, you will need to use a https:// or ssh link
Another way to push can be
Code:
$ git push <link> HEAD:<branch>
Now say you want to make your own git repository of your files
Click on the new repository button on GitHub, give a name
You can do initial commit online, or locally
Follow the instructions it gives you
i.e. if you have all files ready (in a folder)
Code:
$ git init
$ git add -A
$ git commit
$ git push <link> HEAD:<branch>
A VERY important thing to be noted while using version control systems like git, is to preserve authorship of a commit
If someone else has made some changes to a file, and we want them, we should not copy the changes and commit, but should give them authorship either by cherry-picking(will be explained)
Or using this syntax
Code:
$ git commit --author="Author Name <[email protected]>"
Through this git will know the correct authors
Not giving proper authorship is known as kanging, not appreciated here on XDA,(or anywhere else for that matter), and can cause you to be banned :3
Anyway, on to cherry-picking
Go to your repository
Code:
$ git remote add blahblah link-to-url-you-want-commit-from
$ git fetch blahblah branch-commit-is-on
$ git cherry-pick Commit-sha1-hash
If you see a commit on GitHub, or GitLab, or BitBucket, there is a unique(to that repo) SHA for every commit to identify it
Fetch the correct repo as shown above, and paste the commit id
That will fetch the changes
However, if your local source is quite different from the source you cherry-picked from, it will conflict
If so your terminal will display it
then run
Code:
$ git status
Files shown in red color have conflicts
Open them with a text editor like Atom(my favorite), nano, gedit, vim, etc
Look for <<<<<<<
From there, the content till ======
is the original content
=======
till >>>>>>> *insert commit message here* is the new stuff
So check the commit, figure out what's wrong, fix it, save.
Then
Code:
$ git add -A
$ git commit
If no conflicts it will commit on its own and you just need to
Code:
$ git push
as explained earlier :v
Running
Code:
$ git log
will show you a list of commits , authors, and SHA
If for some reason you wanna remove some commit, use
Code:
$ git revert commit-SHA
Just like cherry-picks, it may have conflicts
Anyway, this is just a small guide to get started off
You can easily found out more by searching, and experimenting
I will add more stuff here soon
Enjoy with this much till then
Building CyanogenMod for those device which officially supported​If our build environment setted up successfully and after we learnt some Git and repo thing now we will concentrete on rom building
Now we have to Initialize Repo. We will try to build CyanogenMod.
Initialize the repo:
Code:
Code:
$ mkdir cm
$ cd cm
$ repo init -u git://github.com/CyanogenMod/android.git -b cm-13.0
$ repo sync -f --no-clone-bundle
For people who have already done a repo init:
Code:
$ cd cm
$ repo sync -f --no-clone-bundle
When prompted, enter your real name and email address.
Continue onto adding a device
~How To Add A Device To The List~
Find the github for your device you wish to add. (We will give Android One Devices(sprout4&sprout8) as an example
Navigate back to your home directory for building:
Code:
$ cd ~/cm
$ source build/envsetup.sh
Or
$ . build/envsetup.sh
That sets up your environment for building
Get your list of devices:
Code:
$ brunch
Choose your device from the list, till will fetch tree and dependencies if needed, sometimes vendor tree will need to be added manually (In case of CyanogenMod, rest all ROMs keep in dependencies)
Build will start,enjoy!
For users who like understanding>
Code:
. build/envsetup.sh
runs a shell script, which adds various environment variables,etc, and some commands.
Calling "brunch" actually runs the command
Code:
breakfast [email protected] && mka bacon
(for CM)
[email protected] in shell script means all the parameters that have been passed, so if you passed brunch sprout, it would pass sprout
breakfast calls lunch, which selects the device, prepares the environment for building for it, fetches dependencies with the help of roomservice python script
"mka bacon"
This calls GNU make, and passes bacon as a parameters, to be "made"
mka is used instead of make, as it automatically uses all available threads of your CPU
If you have a quad core Intel, or octa core AMD, you could run make -j8 bacon
This is just the gist of it, reading through the envsetup.sh would make it clearer
If successful, you will get a zip in out/target/product/device
If not, check post #6
Most likely, you will find a solution there.
If not, please ask us in the thread, we would be happy to assist you
To be continued
Kernel Compilation
As many of you'll already know, kernel of an operating system
Android devices use a modified version of the linux kernel
Firstly, most important thing to note, in that the Linux Kernel is licensed under the GNU GPL (General Public License), which can be found here
Basically, you must always keep your work on the kernel open-source, and display the link to it when publishing your work on XDA Threads, etc
In order to do this, make sure you fork, or push the kernel source you're working on to your GitHub account so that you can push the changes you're making
Make sure you give proper authorship, as explained in post #2
If unable to, give credits to author in commit message, but don't kang please [emoji14]
Please try to have at least a basic knowledge of C, so that you can fix errors
Else, use Google before asking in thread, there's a huge chance someone has already gotten and solved it :v
So now, getting to work
I will give an example using Android One Device (sprout4&&sprout8)
The kernel source be found here(branch android-mediatek-lollipop-mr1 for 5.1,or something, not sure, check), and also here, branch cm-12.1 for 5.1 ROMs
So fork it to your GitHub account, or clone from AOSP and push to your git
I'd recommend the one from CM git, as it usually has small bugs fixed compared to stock
In my device's case, a whole lotta broken stuff is fixed, so I would take from cm
So start off, by installing all dependencies as shown in 1st post
Code:
$ git clone https://github.com/akhilnarang/android_kernel_mediatek_sprout -b cm-12.1 sprout-kernel
Replace the link with your own, ssh if you wish, as explained in #2
You must specify -b cm-12.1,as the default is cm-11.0, and you will end up will KitKat source!
The last parameter is optional, it saves it in that directory, in this case sprout-kernel
Now, all kernel source's have a file called a defconfig, or default configuration, that is device-specific
You will find it in arch/*your devices architecture*/configs
Your device may be arm, arm64, x86
Make sure you remember the name of the defconfig, you can rename it too [emoji14]
If you would like to give your kernel a name, simplest way would be to look for the CONFIG_LOCALVERSION in the defconfig
Make it something like
Code:
CONFIG_LOCALVERSION="-Your-Kernel-Name"
Anyway, so now you need a toolchain
For starting off, we will use GCC 4.8 from Google
For ARM devices
Code:
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/
For aarch64/arm64
Code:
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8/
For x86 I'm not sure, go have a look here
Now remember where you saved it
Now open the file called "Makefile" in the root of kernel source
Look for a line that has ARCH?=
that dosen't start with a # (lines starting with # are comments)
And make it
Code:
ARCH ?= arm
or
Code:
ARCH ?= arm64
And look for CROSS_COMPILE ?=
make it
Code:
CROSS_COMPILE ?= path/to/downloaded/toolchain/bin/arm-eabi-
for arm devices
Code:
CROSS_COMPILE ?= path/to/downloaded/toolchain/bin/aarch64-android-linux-
for arm64 devices
This may differ on Custom toolchains, etc, you can find out about that by viewing the commits of different kernels, and going through various threads
I'm only gonna explain how to compile the kernel, not how to add stuff (at least for now)
If you wish now, you can refer to #2, and commit and push these changes [emoji14]
Now run
Code:
$ make cyanogenmod_sprout_defconfig
That's what my defconfig is called, yours maybe called something else [emoji14]
And now finally to start the build
First, check how many cores/threads your CPU has
A quad core Intel, an octa core AMD, will have 8
So if you have one, run
Code:
$ make -j8
This will compile the code on all 8 threads parallely
However this makes debugging errors harder
If you have an error, just run
Code:
$ make
to reduce output and identify error
Anyway, the process generate a zImage in arch/arm/boot/zImage
or arch/arm64/boot/zImage
This is a binary file
If you check the zip of your favorite custom kernel, you will find one too
In most cases, you can simply replace it with this, update the updater-script, and flash
Most of these zips use anykernel format, meaning it utilizes ramdisk from existing kernel, so if you find such a zip for your device, you're good to go
Else unpack your boot.img and add this add the file boot.img-zImage, repack, flash
If you don't understand any of these terms [emoji14], please google about them first, and then if you are unable to find out ask here please
Enjoy
More stuff will be added soon
Uses of Local_manifests​
Now we will learn what is Manifest. Its used for syncing source from Github,Bitbucket. Its driven via XML. Basically XML is a markup language. We can modify Rom's default.xml but it can cause of conflicts next time. So never think of editing default.xml
Now you can say how we sync our desired repo without modifying default manifest? There is a option called local manifests. By local manifests we can sync our desired repository. You can add,remove any project from default manifest without modifying default.xml
So now we will learn using local manifests-----
Open terminal and type
Code:
cd your source directory name/.repo
e.g: cd cm/.repo
Now create a new directory called local_manifests
Then type
Code:
cd local_manifests
Now type
Code:
nano localmanifest.xml
Now add whatever you want and save it via "ctrl+X"
Adding or Removing repo
Open localmanifest.xml then
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remove-project name="CyanogenMod/android_frameworks_base" />
<project path="frameworks/base" name="Anik1199/android_frameworks_base" remote="github" revision="cm-13.0"/>
This will remove project from CyanogenMod and sync from Anik1199's git.
When adding a new project that replaces an existing project, you should always remove that project before defining the replacement.
You can simply add a new project to the source code, such as when you want to add your own app to the build.
Note that when adding new projects, there are at least three parts defined:
• remote -- the name of the remote. this can be one that was defined in either the default manifest or local_manifest.xml.
• name -- the name of the git project-- for github it has the format account_name/project_name.
• path -- where the git repository should go in your local copy of the source code.
• revision -- (optional) which branch or tag to use in the repository. If this attribute is omitted, repo sync will use the revision specified by the <default ... /> tag in the default manifest.
After creating .repo/local_manifests.xml, you should be able to repo sync and the source code will be updated accordingly
In many Manifest.xml you ll find many stuff not needed by our device. Also there are files needed and that is not present in the default.xml.
Adding Projects to local_manifest.xml
So, to add projects to your local_manifest.xml for your device refer the following format that explains the same.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project path=" directory in work tree" name="name of the repository in remote" remote="name of remote defined earlier" revision="branch of the repository" />
</manifest>
If you have any doubt? See my localmanifest.xml
Device Example Used Here : Android One (Sprout)
Code:
<manifest>
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!--Devices-->
<project path="device/google/sprout4" name="CyanogenMod/android_device_google_sprout4" remote="github" revision="cm-13.0" />
<!--Devices commons-->
<project path="device/google/sprout-common" name="CyanogenMod/android_device_google_sprout-common" remote="github" revision="cm-13.0" />
<!--Kernels-->
<project path="kernel/mediatek/sprout" name="CyanogenMod/android_kernel_mediatek_sprout" remote="github" revision="cm-13.0" />
<!--Vendors-->
<project path="vendor/google" name="TheMuppets/proprietary_vendor_google" remote="github" revision="cm-13.0" />
</manifest>
This will download your device Identity needed for Rom Building
Making CM Device Tree Compatible With Your Rom For Compiling​
We learnt how to initialize build environment,learnt some git,how to use local_manifest and learnt how to build CyanogenMod. Now we will learn how to compatiable CyanogenMod device tree for other Rom. We used Android One aka sprout as a reference. Now we will try to build another CyanogenMod based Rom for sprout.
I am using Team-Radium Rom as reference. So we can start......
There are 3 files in CM Tree Which Should Be Modified.
They are,
1) cm.mk
2) cm.dependencies
3) vendorsetup.sh
We have to edit this 3 files for building Team-Radium
1) Rename cm.mk to radium.mk
As You can see That WE HAVE JUST REPLACED CM WITH Radium
Now you all must be thinking why did we rename cm.mk to radium.mk
A Simple Answer is we go to the vendor folder and check the name and replace it.
So now you must be wondering about the product name ...as in the above image only the "cm" changes to "Radium" with the same logic of the vendor name
In this case we see that Radium is the vendor ...so we rename the cm.mk to radium.mk
this same rule applies to the content inside the radium.mk too ... we first make sure that the files are available in that location .
2) Now we have to move second file "cm.dependencies"
This file will be simply renamed by Vendor Name ...
In This Case "Radium" ....so we rename it to "radium.dependencies"
3) The Last And The Final Change Required Is In The "vendorsetup.sh"
Open vendorsetup.sh and rename cm as radium and save.
Thats it!! So simple i think
Happy building
Good luck!!! :good:
Last one in case
Will soon add some common bugs and their fixes
If repo sync gives error like cannot overwrite work tree
then
Code:
$ repo sync --force-sync
For those with slow net
You can download highly compressed sources by @regalstreak and some others from here!
Unless its a one time build, i'd recommend getting the one with .repo folder, else you won't be able to easily update the source to the latest version!
Thanks guys like @OwnDroid @westcripp @##W4TCH0UT## @varun.chitre15 @CaptivateKing and many others who have inspired me about Android
Reserved
Anik_khan and akhilnarang ( My Encyclopedia of Development), love u guys. Keep doing awesome work
This is a nice guide... I think most of the people in India do not have high speed internet or continuous electricity for repo sync
This puts limitations on using own PCs for ROM building. I have seen lots of people who are using rented servers for this purpose. These servers are located somewhere in Europe or USA and one can access them (or VMs on them) remotely. These servers have internet speeds in GBs so the repo sync does not take more than 30 minutes...
I've recently started learning about ROM building and I've started with Google Cloud. Google have 2 months free service (so interested guys can start the ROM building right away without thinking about the time required for downloading 15-20 GBs )
@Anik_khan may be you can think of adding this as a tip in the OP...
@akhilnarang thanks for helping me and be ready... I'll be coming with lots of questions
Great work guys.
This will help a lot of newbies.
Add use of build scripts maybe.
P.S : Sometime I forget actual commands because of too much use of build scripts
corphish said:
Add use of build scripts maybe.
P.S : Sometime I forget actual commands because of too much use of build scripts
Click to expand...
Click to collapse
I was planning too, the guide is gonna be improved over the next few days
Sent from my A0001 using Tapatalk
a small correction in installing java procedure, you need jdk 7 to build lollipop, you mentioned as jdk7 and higher but you can't build with jdk8. awesome guide so far, regards from me.
Sent from my XT1033 using Tapatalk
Great Post , Thanks my two most favorite Brother .
I am searching for this awesome post , and you give the way with a easy way .
Awesome written . Really easily to understand.
Thanks man thanks
Thanks guys..finally got a 'noob friendly guide'..
Sent from my HM 1SW using XDA Free mobile app
OMG!! It's awesome and damn noob friendly!! It's the best guide I have ever seen!!
Thanks to you @Anik_khan & @akhilnarang
Keep your awesome work guys!!
Anik_khan said:
There are 3 files in CM Tree Which Should Be Modified.
They are,
1) cm.mk
2) cm.dependencies
3) vendorsetup.sh
Click to expand...
Click to collapse
Just add this point as a note :-
Some ROMs extensively need device dependencies in their vendor source, be sure that u add it before building (if necessary)
Sent from my A0001 using Tapatalk
Its really a nice guide, but i need your help as am stuck on how to add a device to aosp/CM source, whenever i tried to add a device, I follows all instructions but it always give me an error
Which would you like? [aosp_arm-eng] 7
build/core/product_config.mk:222: *** Can not locate config makefile for product "ha_i9500". Stop.
** Don't have a product spec for: 'ha_i9500'
** Do you have the right repo manifest?
Frostyagent said:
Its really a nice guide, but i need your help as am stuck on how to add a device to aosp/CM source, whenever i tried to add a device, I follows all instructions but it always give me an error
Which would you like? [aosp_arm-eng] 7
build/core/product_config.mk:222: *** Can not locate config makefile for product "ha_i9500". Stop.
** Don't have a product spec for: 'ha_i9500'
** Do you have the right repo manifest?
Click to expand...
Click to collapse
Rename cm.mk to ha_i9500.mk
Sent from my A0001 using Tapatalk
ujwal.p said:
Rename cm.mk to ha_i9500.mk
I have done it but still no luck and error continues to display, I want to know what am i doing wrong, I was trying all the night but bad luck
Click to expand...
Click to collapse

✦✦✦ [GUIDE] Build LineageOS ✦ How To use Github ✦✦✦

{
"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"
}
How-to Build LineageOS​
Introduction​
These instructions will hopefully assist you to start with a stock device, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for LineageOS (based on Google’s Android operating system) for your device. Using these, you can build both LineageOS and LineageOS Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home . And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
What you’ll need
* A device (supported by LineageOS)
* A relatively recent 64-bit computer (Linux, OS X, or Windows) with a reasonable amount of RAM and about 100 GB of free storage (more if you enable ccache or build for multiple devices). The less RAM you have, the longer the build will take (aim for 8 GB or more). Using SSDs results in considerably faster build times than traditional hard drives.
* A USB cable compatible with the OnePlus One (typically micro USB)
* A decent internet connection & reliable electricity
* Some familiarity with basic Android operation and terminology. It would help if you’ve installed custom roms on other devices and are familiar with recovery. It may also be useful to know some basic command line concepts such as cd for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /. etc.​​
Summary
1. Install SDK
2. Install build packages
3. Java
4. Create the directories
5. Install the repo command
6. Initialize the LineageOS source repository
7. Download the source code
8.Prepare the device-specific code
9. Extract proprietary blobs
10. Turn on caching to speed up build
11. Configure jack
12. Start the build
13. Install the build
Build LineageOS and LineageOS Recovery​
1. Install SDK
If you haven’t previously installed adb and fastboot, you can download them from Google. Extract it using:
Code:
unzip platform-tools-latest-linux.zip -d ~
Now we have to add adb and fastboot to our path. Open ~/.profile and add the following:
Code:
# add Android SDK platform tools to path
if [ -d "$HOME/platform-tools" ] ; then
PATH="$HOME/platform-tools:$PATH"
fi
Then, run this to update your environment.
Code:
source ~/.profile
2. Install build packages
Several packages are needed to build LineageOS. You can install these using your distribution’s package manager.
You’ll need:
Code:
bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev
For Ubuntu versions older than 16.04 (xenial), substitute:
libwxgtk3.0-dev → libwxgtk2.8-dev
3. Java
Different versions of LineageOS require different JDK (Java Development Kit) versions.
LineageOS 11.0-13.0: OpenJDK 1.7 (install openjdk-7-jdk)*
LineageOS 14.1: OpenJDK 1.8 (install openjdk-8-jdk)
* Ubuntu 16.04 and newer do not have OpenJDK 1.7 in the standard package repositories. See Ask Ubuntu question How do I install openjdk 7 on Ubuntu 16.04 or higher Note that the suggestion to use PPA openjdk-r is outdated (the PPA has never updated their offering of openjdk-7-jdk, so it lacks security fixes); skip that answer even if it is the most upvoted.
4. Create the directories
You’ll need to set up some directories in your build environment.
To create them:
Code:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
5. Install the repo command
Enter the following to download the repo binary and make it executable (runnable):
Code:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Put the ~/bin directory in your path of execution
In recent versions of Ubuntu, ~/bin should already be in your PATH. You can check this by opening ~/.profile with a text editor and verifying the following code exists (add it if it is missing):
Code:
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Then, use this to update your environment.
Code:
source ~/.profile
6. Initialise the LineageOS source repository
Enter the following to initialize the repository:
Code:
$ cd ~/android/system
$ repo init -u https://github.com/LineageOS/android.git -b lineage-16.0
7. Download the source code
To start the download of the source code to your computer:
Code:
$ repo sync
The Lineage manifests include a sensible default configuration for repo, which we strongly suggest you use (i.e. don’t add any options to sync). For reference, our default values are -j 4 and -c. The -j 4 part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3 or -j 2. -c will ask repo to pull in only the current branch, instead of the entire LineageOS history.
8. Prepare the device-specific code
After the source downloads, ensure you’re in the root of the source code (cd ~/android/system), then type:
You have to change DEVICE with the codename of your device (for example: Oneplus ONE codename is bacon)
Code:
$ source build/envsetup.sh
$ breakfast "DEVICE"
This will download your device’s device specific configuration and kernel.
Important: Some maintainers require a vendor directory to be populated before breakfast will succeed. If you receive an error here about vendor makefiles, jump down to Extract proprietary blobs. The first portion of breakfast should have succeded, and after completing you can rerun breakfast​
9. Extract proprietary blobs
Method 1
Now ensure your device is connected to your computer via the USB cable, with ADB and root enabled, and that you are in the ~/android/system/device/your_device/codename folder. Then run the extract-files.sh script:
Code:
$ ./extract-files.sh
The blobs should be pulled into the ~/android/system/vendor/your_device folder. If you see “command not found” errors, adb may need to be placed in ~/bin.
Method 2 (Recomended)
Search for your device blobs on TheMuppets or Donkeycoiote and add them to local manifest
10. Turn on caching to speed up build
You can speed up subsequent builds by running:
Code:
$ export USE_CCACHE=1
And adding that line to your ~/.bashrc file. Then, specify the maximum amount of disk space you want cache to use by typing this from the top of your Android tree:
Code:
$ prebuilts/misc/linux-x86/ccache/ccache -M 50.0G
Where 50G corresponds to 50GB of cache. This needs to be run once. Anywhere from 25GB-100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s Android build environment initialization page.
11. Configure jack
Jack is the new Java compiler used from Lineage 14. It is known to run out of memory
Simple fix is to run this command:
Code:
$ export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
Adding that command to your ~/.bashrc file will automatically configure Jack to allocate a sufficient amount of memory.
If this doesn't help, you can reduce the number of Jacks to 1 in config.properties
$HOME/.jack-server/config.properties
jack.server.max-service=1
12. Start the build
Time to start building! Now, type:
Code:
$ croot
$ brunch [COLOR="red"]device[/COLOR]
Remember, device is the codename for your device
The build should begin.
13. Install the build
Assuming the build completed without errors (it will be obvious when it finishes), type the following in the terminal window the build ran in:
Code:
$ cd $OUT
There you’ll find all the files that were created. The two files we’re interested in are:
recovery.img, which is the LineageOS recovery image.
lineage-14.1-build_date-UNOFFICIAL-device.zip, which is the LineageOS installer package.
Success! So… what’s next?​
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now, what to do next? You can jump to next section of this guide to understand how Github works and how to pick some commits from other developers/teams to improve your custom ROM​
This guide was taken from Official LineageOS wiki and all credits goes to LineageOS Maintainers ​
What is Github and how to use it
GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. It is a powerful tool with many features available and here i´m going to talk about how you can use it to help you build and customize your "Custom ROM"​
Summary
1. Repositories
2. How to add/remove repositories
3. How to add/remove remotes
4. Repository Fork
1. Repositories
Now that you have built custom lineage from source to your device, you can explore deeper and see how things work and change them according to your needs.
First we are going to se what is inside .repo folder
Code:
cd ~/working_dir/.repo
ls
It will show you something similar to this:
Inside the .repo folder are the necessary "manifest files" that tell the repo sync command what to include or remove from our project when synchronizing with the source
Open manifest.xml
Code:
gedit ~/working_dir/.repo/manifest.xml
Inside that file you have all information about which repositories belongs to source. These are the base repositories to build LineageOS.
Inside ~/working_dir/.repo/local_manifests/roomservice.xml you can see the repositories needed to build for your specific device. This file is created after breakfast device step and includes, besides others, device tree and kernel.
2. How to add/remove repositories
Lets take a look at how we use roomservice.xml to add/remove repo's from our project, i will use Oneplus ONE device tree for example
Code:
<project name="LineageOS/android_device_oneplus_bacon" path="device/oneplus/bacon" remote="github" revision="cm-14.1" />
* project name="LineageOS/android_device_oneplus_bacon Name of repository (without https://github.com)
* path="device/oneplus/bacon" Here is where the files will reside in our working directory
* remote="github" Is the for remote we are using, in this case is github (see below how to add/remove remotes to your project)
* revision="cm-14.1" Revision is the branch we want to sync
Image:
3. How to add/remove remotes
Code:
<remote fetch="https://github.com" name="github" />
* remote fetch="https://github.com Url for remote you want to add to your project (in this case, we are working with github)
* name="github" This is the name for remote
Now that you understand the concept of repository, you can "fork" one and start making your
changes and keep it up to date with LineageOS source. For that, you need a Github Account.​
4. Repository Fork
In this example, i will fork Oneplus ONE device tree
1. Create Github Account
2. Go to https://github.com/LineageOS/android_device_oneplus_bacon and tap on Fork button. After that you can see that repository on you Github account
Image:
3. Now that you have "forked" one repository, you need to edit ~/working_dir/.repo/local_manifests/roomservice.xml and change the default location to your location on your github.[/SIZE]
Image:
This is the basic steps you need to understand how to use Github to keep your code saved and updated. On next section, i will tell you how use Git so you can work on your project and start to pick some cool commits from others projects.​
Reserved
Reserved
Hello ,
Thanks for your tutorial. It was very well explained.
I have a question in the step: "Prepare the device-specific code".
The last available branche of my device at https://github.com/LineageOS/android_device_samsung_treltexx/tree/cm-13.0, is the cm-13.0 version,
Should I tell which of the options on the device?
$ Source build / envsetup.sh
$ Breakfast "[COLOR =" Red] Samsung Galaxy Note 4 (Exynos) or treltexx [/ COLOR]
Another question: since the last branche is from cm-13.0, if I follow your tutorial, will it compile a, lineage 14.1 rom? Or CYanogenmod 13.0?
Thank you
John Jefferson said:
Hello ,
Thanks for your tutorial. It was very well explained.
I have a question in the step: "Prepare the device-specific code".
The last available branche of my device at https://github.com/LineageOS/android_device_samsung_treltexx/tree/cm-13.0, is the cm-13.0 version,
Should I tell which of the options on the device?
$ Source build / envsetup.sh
$ Breakfast "[COLOR =" Red] Samsung Galaxy Note 4 (Exynos) or treltexx [/ COLOR]
Another question: since the last branche is from cm-13.0, if I follow your tutorial, will it compile a, lineage 14.1 rom? Or CYanogenmod 13.0?
Thank you
Click to expand...
Click to collapse
Since your device tree doesn't have 14.1 branch you have to sync Lineage 13.0 branch
Code:
repo init -u https://github.com/LineageOS/android.git -b cm-13.0
After that you have to sync your especific device repos
Code:
$ source build/envsetup.sh
$ breakfast treltexx
A3 2017
Hi , I have Galaxy A3 2017 I got to point of breakfast and I cound download files for my phone. What I have to do if I want to have Lineage OS Nuggat in my phone. I hate original rom :-{
breakfast a3y17lte
including vendor/cm/vendorsetup.sh
build/core/product_config.mk:249: *** Can not locate config makefile for product "lineage_a3y17lte". Stop.
build/core/product_config.mk:249: *** Can not locate config makefile for product "cm_a3y17lte". Stop.
build/core/product_config.mk:249: *** Can not locate config makefile for product "lineage_a3y17lte". Stop.
Device a3y17lte not found. Attempting to retrieve device repository from LineageOS Github
Repository for a3y17lte not found in the LineageOS Github repository list. If this is in error, you may need to manually add it to your local_manifests/roomservice.xml.
build/core/product_config.mk:249: *** Can not locate config makefile for product "lineage_a3y17lte". Stop.
build/core/product_config.mk:249: *** Can not locate config makefile for product "lineage_a3y17lte". Stop.
** Don't have a product spec for: 'lineage_a3y17lte'
** Do you have the right repo manifest?
Is that mean that I have to wait for support from LineageOS dvlpr team <?
Roman
roman01110 said:
** Don't have a product spec for: 'lineage_a3y17lte'
** Do you have the right repo manifest?
Is that mean that I have to wait for support from LineageOS dvlpr team <?
Roman
Click to expand...
Click to collapse
Yes
Thanks for the great post! I have two questions to ask:
1. How to change LINEAGE_VERSION? Currently when performing brunch I've got
Code:
LINEAGE_VERSION=14.1-20170311-UNOFFICIAL-oneplus3
and I wish to change it to
Code:
LINEAGE_VERSION=14.1-20170311-HAZUKI-oneplus3
to distinguish my personal modified build.
2. When I wish to sync again to obtain latest commits, how far should I go back? Is performing "repo sync" and then "brunch oneplus3" already good enough? Do I need to perform "make clean" or something similar?
Thanks in advance!
I'm trying to build this for my galaxy s5 and I'm using that same guide to the letter and I'm just getting errors. And all those packages listed in op don't work either. I also get an error when extracting proprietary blobs. The extracting isn't the error it's that all the files aren't found in source code at all?!? I'm splitting bloody atoms trying to figure this crap out. Any help at all??
Hazuki Amamiya said:
Thanks for the great post! I have two questions to ask:
1. How to change LINEAGE_VERSION? Currently when performing brunch I've got
Code:
LINEAGE_VERSION=14.1-20170311-UNOFFICIAL-oneplus3
and I wish to change it to
Code:
LINEAGE_VERSION=14.1-20170311-HAZUKI-oneplus3
to distinguish my personal modified build.
2. When I wish to sync again to obtain latest commits, how far should I go back? Is performing "repo sync" and then "brunch oneplus3" already good enough? Do I need to perform "make clean" or something similar?
Thanks in advance!
Click to expand...
Click to collapse
1. In order to add some code to your build, you have to get familiar with git/GitHub. I'm preparing my next chapter to talk about it
2. Yes, you have to "make clean" everytime before build
thatsupnow said:
I'm trying to build this for my galaxy s5 and I'm using that same guide to the letter and I'm just getting errors. And all those packages listed in op don't work either. I also get an error when extracting proprietary blobs. The extracting isn't the error it's that all the files aren't found in source code at all?!? I'm splitting bloody atoms trying to figure this crap out. Any help at all??
Click to expand...
Click to collapse
You have to show all your errors and all your steps in order to get help!
I'm using the exact same directions in the OP. No different order exactly the same order only for my specific device. The first pic is when I extract the proprietary blobs from the lineage ROM zip. The second pic is after trying to build it I get the ninja wrapper error 1 at the end. Oh and I'm running ubuntu 16.10 on VirtualBox. And my build environment was setup step by step off the android website
thatsupnow said:
I'm using the exact same directions in the OP. No different order exactly the same order only for my specific device. The first pic is when I extract the proprietary blobs from the lineage ROM zip. The second pic is after trying to build it I get the ninja wrapper error 1 at the end. Oh and I'm running ubuntu 16.10 on VirtualBox. And my build environment was setup step by step off the android website
Click to expand...
Click to collapse
Why did you run: " ./extract-files.sh ~/original"
FSadino said:
* A relatively recent 64-bit computer (Linux, OS X, or Windows) with a reasonable amount of RAM and about 100 GB of free storage (more if you enable ccache or build for multiple devices). The less RAM you have, the longer the build will take (aim for 8 GB or more). Using SSDs results in considerably faster build times than traditional hard drives.
Click to expand...
Click to collapse
Can you tell me, where the space is nescessary in the file-sytem on a linux-PC?
Of course /home needs much space, as the build is done there, but where else?
JamBax said:
Can you tell me, where the space is nescessary in the file-sytem on a linux-PC?
Of course /home needs much space, as the build is done there, but where else?
Click to expand...
Click to collapse
It depends on which Linux distribution you install. Usually between 10Gb/15Gb should be enough for file system partition "/"
FSadino said:
It depends on which Linux distribution you install. Usually between 10Gb/15Gb should be enough for file system partition "/"
Click to expand...
Click to collapse
It is kubuntu 16.04.02, so this means all the hard disk space will be for /home filesystem, correct?
Another question, where is the space for the cache, for i can't see any parameter.
edit ok, looks like the cache is located at /home/..ccache, is there a possibility to move this location?
Could it be, that java 8 can be used for 13.0 also? I did not install java 7, but was able to build a working lineage 13.0.
JamBax said:
It is kubuntu 16.04.02, so this means all the hard disk space will be for /home filesystem, correct?
Click to expand...
Click to collapse
You have to make root partition for system (/) with 10Gb/15Gb and home partition (/home) with the remaining disk space.
Another question, where is the space for the cache, for i can't see any parameter.
edit ok, looks like the cache is located at /home/..ccache, is there a possibility to move this location?
Click to expand...
Click to collapse
Search on Google "how export ccache to other location"
Could it be, that java 8 can be used for 13.0 also? I did not install java 7, but was able to build a working lineage 13.0.
Click to expand...
Click to collapse
Yes
I have a question. I repo synced lineage 13. The build was successful but doesn't boot. I am building for Moto E surnia. I breakfast surnia it didn't ask for vendor files but built correctly. What could be wrong? The kernel log doesn't tell me too much. It's frustrating. All my previous builds booted up before.( I compiled DU for the surnia) Also use the same environment to build Twrp recoveries. I am downloading lineage 14 to try again. Maybe someone can point me in the right path please
Hi, I am building klte version of CrdroidAndroid ( a LineageOS based ROM) on a ubuntu 16.04 LTS VM.
I am getting the following error. I am not sure what to do here. I have been cleaning the build folder and ccache and trying to build. I keep ending at this error. Any help to solve this issue is greatly appreciated.
----------------------------------
/usr/bin/x86_64-linux-gnu-ld: /home/sadanand/crdroid/android/system/out/host/linux-x86/obj/SHARED_LIBRARIES/libart_intermediates/base/allocator.o: relocation R_X86_64_PC32 against protected symbol `_ZN3art18g_malloc_allocatorE' can not be used when making a shared object
/usr/bin/x86_64-linux-gnu-ld: final link failed: Bad value
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
------------------------------
Thanks
[email protected] said:
I have a question. I repo synced lineage 13. The build was successful but doesn't boot. I am building for Moto E surnia. I breakfast surnia it didn't ask for vendor files but built correctly. What could be wrong? The kernel log doesn't tell me too much. It's frustrating. All my previous builds booted up before.( I compiled DU for the surnia) Also use the same environment to build Twrp recoveries. I am downloading lineage 14 to try again. Maybe someone can point me in the right path please
Click to expand...
Click to collapse
Try build with vendor files
sada23 said:
Hi, I am building klte version of CrdroidAndroid ( a LineageOS based ROM) on a ubuntu 16.04 LTS VM.
I am getting the following error. I am not sure what to do here. I have been cleaning the build folder and ccache and trying to build. I keep ending at this error. Any help to solve this issue is greatly appreciated.
----------------------------------
/usr/bin/x86_64-linux-gnu-ld: /home/sadanand/crdroid/android/system/out/host/linux-x86/obj/SHARED_LIBRARIES/libart_intermediates/base/allocator.o: relocation R_X86_64_PC32 against protected symbol `_ZN3art18g_malloc_allocatorE' can not be used when making a shared object
/usr/bin/x86_64-linux-gnu-ld: final link failed: Bad value
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
------------------------------
Thanks
Click to expand...
Click to collapse
Try to use GCC 4.9 or if you already using it try update to GCC 5

Categories

Resources