How to Build Custom Cyanogenmod Rom



Build Custom Cyanogenmod Rom? So are you ready to take on Rom Development? That’s okay if you’re not, because I’ll help walk you through it. In this tutorial, I’m going to show you how to build your own Cyanogenmod Rom right from source. This sounds a lot more complicated than it actually is though. However, keep in mind that you will need a lot of patience when doing this. For this tutorial, I’m going to assume that you have Linux up and running and you’re familiar with basic Linux and Android operations.

Depending on your computer and internet speeds this could take anywhere from 5 hours (no less than that) to 5 days to complete. You’re going to be downloading over 15 GB in source code. In addition, your computer hardware will determine how fast your compiling process will take.  I have a Core i7 3770k along with 16GB of ram and it took 45min-1 hour. So just be aware that this isn’t a ten minute process. One final note, I compiled this tutorial with the help of several references found here, here and here; so if you don’t like the way I do things feel free to pull information from any of those other guides.

What You Will Need:

  • An already built CyanogenMod Zip for your device (Doesn’t matter if it’s a nightly or stable).
  • A Computer running Linux or OSX (Virtualbox is acceptable too).
  • At least 35GB of free space on your Hard Drive
  • Patience!

Step 1: Setting up Bashrc

To make life easier, let’s add bin as a path.  In a terminal window type in

sudo gedit ~/.bashrc

 At the very end of the file add the following:

export PATH=${PATH}:~/bin

In just a little bit we’re going to be creating a bin directory, so it’s helpful to do it now.

bashrc

Hit save once your done and close it.  Now in terminal type in

~/.bashrc

This will re-load your bashrc. (Rebooting would do the same thing, but that’s no fun).

Step 2: Preparing Your Build Environment

Alright, there are multiple things you’re going to need to install before you can start cooking.  Simply copy and paste this into terminal.  (This was taken straight from the Cyanogen wiki page)

sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jre openjdk-6-jdk pngcrush schedtool libxml2 libxml2-utils xsltproc

And if you’re running a 64 bit System, paste this into terminal as well:

g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib

Step 3:Directories

Alright, time to make some directories. In your home folder, let’s create a directory called bin. That will hold the repo stuff.  For the actual source files let’s create a directory called CM10.2(You don’t have to call it cm10.2, you can name it to whatever you want, just note that I’m always going to refer to it as cm10.2 in this tutorial).  You can create these directories easily by typing the following in terminal:

mkdir -p ~/bin

mkdir -p ~/CM10.2

 Step 4: Installing Repo

Now let’s download the repo file and change its permissions so that we can execute it.  In terminal type in:

curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo <br />
chmod a+x ~/bin/repo

repo

Step 5: Iniinitialize CM Source and Downloading the Source Code

Now it’s time to initialize the source code to download.  In terminal change to your CM10.2 directory.  So type:

cd ~/CM10.2

Now we need to decide what version of cyanogenmod we want to get.  I’m going to go with 10.2 since I know there is source available for my device, but you can choose whichever build you like.  So type in:

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

Just a quick note, if this is your first time using repo you might be prompted to type in your email address and name. Finally, when you’re ready type in:

repo sync

This will begin long process of downloading over 15GB of source code.  This will take anywhere between 4 hours to 4 days depending on your internet speed.  Get that coffee ready!

repo sync

Note: If repo gets stuck or freezes during the download, just hit control + z to stop it, and type “repo sync” again.

Step 6: Prebuilt Apps

Congratulations! You made it through one of the longest steps! You’re halfway there. Now let’s get the prebuilt apps.  In terminal type in the following:

cd ~/cm10.2/vendor/cm

./get-prebuilts

Cool. No Confirmation will appear so you’ll just have to trust it happened.

Step 7: Device Specific Code

Now it’s time to prepare the device specific code. In terminal type the following:

cd ~/cm10.2

source build/envsetup.sh

breakfast m7spr (After breakfast you’re typing in your device’s name.  Look it up if you’re not sure. I’m using a sprint htc one, so it’s m7spr)

The device specific code will download.

m7spr

Step 8: Extract Proprietary Blobs

In order to get the device specific files, you’re going to need to have an already built CyanogenMod rom for your device.  Now this process could be accomplished through the actual device but I’m going to show your through the zip (it’s easier and less of a hassle).  Make a new folder called original in your home folder, and extract the zip to that folder.

mkdir -p ~/original

Then in terminal type in the following commands:

cd ~/cm10.2/device/htc/m7spr

./extract-files.sh ~/original

Of course replace m7spr and cm10.2 with the appropriate device and zip you used.

extract

Great! You’re almost done.  According to the CyanongenMod wiki we can also turn on cache building to speed up subsequent builds after this one.  Type in:

export USE_CCACHE=1

 Step 9: Starting the Build

Now the moment you have been waiting for. It’s time to start building your CM Rom. Type in the following:

croot

brunch m7spr

Again, replace m7spr with your device.  If you get any errors, here are some helpful tips taken right from wiki.cyanogenmod.org:

If the build doesn’t start, try lunch and choose your device from the menu. If that doesn’t work, try breakfast and choose from the menu. The command make m7att should then work. A second, bonus tip! If you get a command not found error for croot or brunch or lunch, be sure you’ve done the “. build/envsetup.sh”command in this Terminal session from the ~/cm10.2 directory

Step 10: That’s it!

Hopefully your build completed without errors. If you have any errors refer to here if you have any trouble. Now the last thing to do is grab your newly built cyanogenmod zip.  Simply go into the out/target/product/m7spr folder and you should see your cyanogenmod zip.  From here you can flash it in recovery on your phone.  Hope you enjoyed and have fun! 

out