Post Reply

[HOWTO] Build CM10.1 for N7000, Nexus 4 and 7, Note II and Note II LTE

OP chasmodo

22nd January 2013, 09:02 PM   |  #1  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
First of all, why would you want to do it when there are Nightlies to be dowloaded and flashed?

Let me quote Rec Dev fattire here:


Quote:
Originally Posted by fattire

Off the top of my head...

  • You never, ever have to wait for a nightly
  • You can add or remove as-yet uncommitted features with ease.
  • You learn how Android works under the hood
  • You learn how to use Linux
  • You'll learn how to use git
  • You may, even accidentally, pick up a little C, Java, C++, and learn about the build system.
  • You can personalize Android-- make your own tweaks, modules, graphics, add or remove projects etc. In other words, you have control over every aspect of your device's functionality. Your build is custom to you.
  • You can audit the code for potential security issues such as back doors or trojans (as opposed to just trusting a random person who posts a build). Since CM10 source is open, you can examine every commit, and there are many eyes looking at the code. (does not apply to proprietary blobs, but these are pulled from your device, so you have and are using them already)
  • You can contribute features/fixes back upstream
  • You can start ports to other as-yet-unsupported devices (start by copying folders from similar devices to devices/manufacturer/model)
  • You come to really understand that Android phones and tablets are full-fledged general-purpose computers just like laptops and desktops.
  • AAAAND....you get huge bragging rights

The extent to which you delve into the above is entirely up to you. The walkthrough is just an introduction to that world. Some people will build once and never do it again... but others will start to tinker and make changes to their own build and want to share them with others, and soon some will start making contributions back to official CM10 upstream... or port to new devices... and by fixing bugs and all this... everyone benefits.

Plus...
  • It's fun.

Last edited by chasmodo; 2nd February 2013 at 03:33 PM.
The Following 80 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:02 PM   |  #2  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Hardware Requirements
You'll need a computer configuration that is not too shabby to pull this off; also you'll need a decent Interweb connection to download all that is needed.

Here are some hardware examples:

Utacka

Ahalford

Anti

Me

In other words, you need to have a box capable of doing some crunching. The better the PC, the faster the compile and vice-versa.


As for the Internet connection, you have to pull about 13 Gb of tiny files in the first CM10.1 sync, and additional 2-3 Gbs in your second sync.

Trying to do it on a 512Kb/s connection is an exercise in futility.
Last edited by chasmodo; 27th May 2013 at 01:19 PM.
The Following 27 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:03 PM   |  #3  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Setting up the Build Environment
First things first: you need to download and install 64-bit version of Ubuntu 12.04. A 32-bit one won't cut it.
Installed it? Good, let's move on.

Now do a system update; click that little switch icon in the top right hand corner and you'll get a menu. Launch Update Manager and install everything it finds.

Now that your Ubuntu is up to speed you need to download and install some more stuff. Launch the terminal (Ctrl + Alt + T).

Copy the below code and paste it (right-click and paste or Shift + Insert, Ctrl + V doesn't work) in the terminal, hit enter.

Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl pngcrush schedtool g++-multilib lib32z1-dev lib32ncurses5-dev libxml2-utils
If 'lib32ncurses5-dev' fails, delete it from the list, install everything else.

Now you need to add the following repos, again copy/paste each line into the terminal, hit enter. Repeat for each line of the code below.

Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
Code:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
Code:
sudo apt-get update
Now you are going to install Synaptic.

Code:
sudo apt-get install synaptic
Done? Good.

Click the 'Dash Home' button (top left hand corner of your desktop), find and launch Synaptic Package Manager. Search for 'Sun Java6 JDK' and install it will all the dependencies except sun-java6-demo and sun-java6-doc.

Now go to http://developer.android.com/sdk/index.html and download the linux version of the Android SDK. It provides the API libraries and developer tools necessary to build. When your download is done, open it with Archive Manager, extract it somewhere, and move the extracted folder to your Home folder. Rename it to 'SDK' for simplicity.

Now you need to download and install Android SDK Platform Tools. Use file manager to navigate to your SDK sub-folder Tools. Find 'android' and double-click to run it. You'll be asked what you want to download. Choose the 'Platform Tools' and the Android 4.1.2 SDK Level 16 and the Android 4.2 SDK level 17 Dev tools and hit install. Let it download; it might take some time, depending on your download speed.

Now the time is ripe for you to setup your Android repos. Copy/paste the following commands into the terminal, hit enter after each one.

Code:
mkdir -p ~/bin
Code:
mkdir -p ~/cm10.1
Code:
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Code:
chmod a+x ~/bin/repo
Code:
export PATH=~/bin:$PATH
You have to reboot after this for changes to take effect.
Last edited by chasmodo; 28th October 2013 at 12:53 PM.
The Following 27 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:04 PM   |  #4  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Initial Repo, local_manifest
Once reboobed, open the terminal once again and do this:

Code:
cd cm10.1

repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1

repo sync
Your initial sync will take some time. After it is is done, go to your cm10.1/.repo folder (/.repo is hidden, so press Ctrl + H in your file manager for it to show up). Create a
subfolder called local_manifests in /.repo. Then create a blank document called roomservice.xml in /.repo/local_manifests. Copypasta™ the below code into roomservice.xml,
save it, close the document.


Quote:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="TheMuppets/proprietary_vendor_samsung" path="vendor/samsung" remote="github" revision="cm-10.1" />
<project name="CyanogenMod/android_packages_apps_SamsungServiceMode" path="packages/apps/SamsungServiceMode" remote="github" revision="cm-10.1" />
<project name="CyanogenMod/android_device_samsung_n7000" path="device/samsung/n7000" remote="github" revision="cm-10.1" />
<project name="CyanogenMod/android_device_samsung_galaxys2-common" path="device/samsung/galaxys2-common" remote="github" revision="cm-10.1" />
<project name="CyanogenMod/android_kernel_samsung_smdk4210" path="kernel/samsung/smdk4210" remote="github" revision="cm-10.1" />
<project name="CyanogenMod/android_hardware_samsung" path="hardware/samsung" remote="github" revision="cm-10.1" />
</manifest>


NOTE: All in the above posts needs to be done only once, prior to compiling your first build.

For all your subsequent builds you'll have to do just the steps listed in the next posts
.
Last edited by chasmodo; 7th May 2013 at 05:45 PM.
The Following 22 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:04 PM   |  #5  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Start the Build
It's time for you to do another repo sync to pull Samsung device-specific stuff.

Code:
repo sync
This sync is going to be considerably shorter than the first one. After it is done, it's time for you to start the build.


Code:
~/cm10.1/vendor/cm/get-prebuilts

. build/envsetup.sh

export USE_CCACHE=1

prebuilts/misc/linux-x86/ccache/ccache -M 50G

brunch n7000

If everything goes right, you should see this at the end of the compile:







Your cm10.1 rom zip will be in cm10.1/out/target/product/n7000 folder.



This is how it looks when the build gets going:


Last edited by chasmodo; 7th December 2013 at 03:38 PM.
The Following 8 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:04 PM   |  #6  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Subsequent Builds
You'll want to do another build tomorrow once your first one has gone through fine.

There are two ways you can go about it.

#1: do a

Code:
cd cm10.1

repo sync

export USE_CCACHE=1

~/cm10.1/vendor/cm/get-prebuilts

. build/envsetup.sh

brunch n7000
The build system should notice which source files have changed and need rebuilding, and should only build the new stuff. This is what you might want to do when there were no major changes in the merged commits here: http://review.cyanogenmod.org/#/q/status:merged,n,z

However, what I always do and would always recommend

#2:

Code:
cd cm10.1

make clean

repo sync

~/cm10.1/vendor/cm/get-prebuilts

. build/envsetup.sh

brunch n7000
'make clean' command will delete your whole /out folder, and your new build will start from scratch. Instead of 'make clean' you can also use 'make clobber'; the difference between the commands is explained here.


There is a way to completely automate your compiling process la CyanogenMod's Jenkins. You can learn how from AndroidSlave here: http://forum.xda-developers.com/show...php?p=46110939
Last edited by chasmodo; 3rd October 2013 at 07:42 AM.
The Following 11 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:06 PM   |  #7  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Cherry Picking
***Cherry picking from CM Gerrit***

This is one of the perks of compiling CM10.1 yourself. Official nightlies have a lot of features, but there's also a lot of stuff waiting for a review on Gerrit.

You can follow the commits waiting to be reviewed and merged into the main repo here: http://review.cyanogenmod.org/#/q/status:reviewed,n,z

You can cherry-pick anything from the upcoming features and incorporate it into your Rom before the official CM10.1 does the same.

Let's say that you want to have this commit before it becomes merged: http://review.cyanogenmod.org/30878

The commit says:
Code:
Project	CyanogenMod/android_packages_apps_LockClock
It's quite simple to do that. Fire up the Terminal (Ctrl + Alt + T) and navigate to your LockClock folder.

Code:
cd cm10.1/packages/apps/LockClock
In other words you must be in the same folder as stated in 'Project' for cherry-picking to work.

Now minimize the terminal (don't close it) and switch to the Gerrit page in your browser.

http://review.cyanogenmod.org/#/c/30878/

Click on cherry-pick button here.



Then click several times on the little clipboard icon at the end of the cherry-pick URL.



This automagically copies the cherry-pick URL into your clipboard. Now, go back to your terminal, paste the cherry-pick URL in it and hit enter.

That is all: the commit will get pulled and incorporated into your local repo. You are ready to compile a build which will contain the feature you have just cherry-picked.


***Cherry-picking from Github***

http://forum.xda-developers.com/show...&postcount=449
Last edited by chasmodo; 12th June 2013 at 10:12 AM.
The Following 28 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:07 PM   |  #8  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
How to compile CM10.1 for Nexus 4
If you have never built CM10.1 then you need to do everything from post #3 here, and this part


Code:
cd cm10.1

repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1

repo sync
from post #4.


After the initial repo sync is done, now comes the Nexus 4 specific bit. As stated before, go to your cm10.1/.repo folder and create a blank document called local_manifest.xml. Paste the below code into local_manifest.xml, save it, close the document.

If you already have local_manifest.xml with n7000 stuff in it, then just add all the lines beginning with <project name= from below to it, save and exit Gedit.


Quote:

<?xml version="1.0" encoding="UTF-8"?>

<manifest>

<project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/android_device_lge_mako" path="device/lge/mako" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/lge-kernel-mako" path="kernel/lge/mako" remote="github" revision="jellybean" />

</manifest>

Now do the second repo sync to pull Nexus 4 specific stuff.

Code:
repo sync
Do the following after the second sync has gone through.

Code:
~/cm10.1/vendor/cm/get-prebuilts

Now it's time to start the build.


Code:
. build/envsetup.sh

export USE_CCACHE=1

brunch mako
That's it. Wait for the build to get compiled and flash your CM10.1_UNOFFICIAL_mako.zip from cm10.1/out/target/product/mako folder.
Last edited by chasmodo; 2nd February 2013 at 12:41 PM.
The Following 17 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:07 PM   |  #9  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
How to compile CM10.1 for Note II LTE (t0lte)
If you have never built CM10.1 then you need to do everything from post #3 here, and this part


Code:
cd cm10.1

repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1

repo sync
from post #4.


After the initial repo sync is done, now comes the Note II LTE specific bit. As stated before, go to your cm10.1/.repo folder and create a blank document called local_manifest.xml. Paste the below code into local_manifest.xml, save it, close the document.

If you already have local_manifest.xml with n7000 stuff in it, then just add all the lines beginning with <project name= from below to it, save and exit Gedit.


Quote:

<?xml version="1.0" encoding="UTF-8"?>

<manifest>

<project name="TheMuppets/proprietary_vendor_samsung" path="vendor/samsung" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/android_packages_apps_SamsungServiceMode" path="packages/apps/SamsungServiceMode" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/android_device_samsung_smdk4412-common" path="device/samsung/smdk4412-common" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/android_kernel_samsung_smdk4412" path="kernel/samsung/smdk4412" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/android_device_samsung_galaxys2-common" path="device/samsung/galaxys2-common" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/android_device_samsung_t0lte" path="device/samsung/t0lte" remote="github" revision="cm-10.1" />

<project name="CyanogenMod/android_hardware_samsung" path="hardware/samsung" remote="github" revision="cm-10.1" />

</manifest>

Note: you might already have some of the lines in your local_manifest.xml if you have compiled a build for n7000. If that's the case, skip adding the lines you already have.

Now do the second repo sync to pull Note II specific stuff.

Code:
repo sync
Do the following after the second sync has gone through.

Code:
~/cm10.1/vendor/cm/get-prebuilts

Now it's time to start the build.


Code:
. build/envsetup.sh

export USE_CCACHE=1

brunch t0lte
That's it. Wait for the build to get compiled and flash your CM10.1_UNOFFICIAL_mako.zip from cm10.1/out/target/product/t0lte folder.
Last edited by chasmodo; 2nd February 2013 at 03:32 PM.
The Following 4 Users Say Thank You to chasmodo For This Useful Post: [ View ]
22nd January 2013, 09:07 PM   |  #10  
chasmodo's Avatar
OP Senior Member
Flag Novi Sad
Thanks Meter: 40,576
 
12,110 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Reserved
How to set up a build environment in Ubuntu 13.04:

http://forum.xda-developers.com/show....php?t=2224142
Last edited by chasmodo; 27th May 2013 at 05:51 PM.

The Following 2 Users Say Thank You to chasmodo For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
compile cm10.1 for n7000, how-to, tutorial
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Galaxy Note GT-N7000 Android Development by ThreadRank