Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE CM10] How to build your own CyanogenMod 10 ROM from sources for LG P990 O2x

OP Raum1807

3rd November 2012, 06:58 PM   |  #1  
Raum1807's Avatar
OP Senior Member
Thanks Meter: 706
 
241 posts
Join Date:Joined: Jul 2012
Make your 'own' ROM today!

Revision History:
V1.5 2013.01.07 Update to newest Java 6 version: Java SE Development Kit 6 Update 38
V1.4 2012.11.20 ParanoidAndroid ROM building guide added, minor changes
V1.3 2012.11.10 New FAQ, Updates Java section, WIFI fix
V1.2 2012.11.05 Sync part updated
V1.1 2012.11.04 Typos fixed
V1.0 2012.11.03 Initial release

Thank you note: Thank you Ricardo Cerqueira for your work on the LG P990. Without you none of this would be possible. Thank you ethansp for your feedback and your input regarding the sync matter. Thank you TrymHansen and Ferrum Master for your input in respect of the JAVA topic. And thank you p.valenta for your contribution to the WIFI build fix.

Overview

0. Preparation
I. Installation of the required packages
II. Installing JAVA
III. The sources
IV. Building the ROM
V. Rebuilding with newest sources
VI. FAQ
VII. Building ParanoidAndroid ROM


0. Preparation

Things you need for building:

A computer
An internet connection
An open mind
Time
Patience


First of all you need a running up-to-date Ubuntu/Linux system. I am using Ubuntu 12.10 64-bit.

Use the terminal to make the steps. A terminal window can be opened by pressing Ctrl+Alt+T. Every single command for the terminal is marked with a $ sign. Just paste every command (without the $ sign) to your terminal window and there shouldn't be any problem.

IMPORTANT: INSTALL EVERYTHING AS A NORMAL USER. DON'T INSTALL AS ROOT!


I. Installation of the required packages (Ubuntu 12.10 64-bit)

Install packages:

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-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils schedtool pngcrush xsltproc zlib1g-dev:i386
Set the links:

Code:
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
II. Installing JAVA

You need a Java Development Kit for building CM10. Recommended is the SUN JDK 6. As of writing the most recent version is SUN JDK 6 Update 38.

1. Download the jdk-6u38-linux-i586.bin from the Oracle/Sun Java Download Area. If you are on 64-bit Ubuntu as I am, you should grab jdk-6u38-linux-x64.bin.

2. Make the bin file executable:

Code:
$ chmod +x jdk-6u38-linux-x64.bin
3. Extract the bin file:

Code:
$ ./jdk-6u38-linux-x64.bin
4. Move the extracted folder to this this location:

Code:
$ sudo mv jdk1.6.0_38 /usr/lib/jvm/./jdk-6u38-linux-x64.bin
5. Install the new Java source in system:

Code:
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-6u38-linux-x64.bin/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-6u38-linux-x64.bin/bin/java 1
$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk-6u38-linux-x64.bin/bin/javaws 1
$ sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk-6u38-linux-x64.bin/bin/javadoc 1
$ sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk-6u38-linux-x64.bin/bin/javah 1
$ sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk-6u38-linux-x64.bin/bin/javap 1
$ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-6u38-linux-x64.bin/bin/jar 1
6. Select the default Java version for your system:

Code:
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javaws
$ sudo update-alternatives --config javadoc
$ sudo update-alternatives --config javah
$ sudo update-alternatives --config javap
$ sudo update-alternatives --config jar
7. Check Java version:

Code:
$ java -version
8. Verify the symlinks. Javac, Java, Javaws, Javadoc, Javah, Javap and Jar should all point to the new Java location and version:

Code:
$ ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar
III. The sources

Install repo:

Repo is a tool that makes it quite easy to download and maintain the sources of Cyanogenmod.

Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ cd ~/bin
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Create working directory:
Code:
$ mkdir ~/cm10
$ cd ~/cm10
Initialize Repo:
Code:
$ repo init -u git://github.com/CyanogenMod/android.git -b jellybean
and enter your credentials.

Download the sources:
Code:
$ repo sync
Wait until it's finished (takes a lot of time!)

If the process hangs use Ctrl+C to break out of it and resume the download with another
Code:
$ repo sync
Tip from ethansp: If you are running into a lot of syncing errors the reason might be that the 'repo sync' command is establishing four threads automatically. This might be too much. So try to change the command to run with one thread only by using
Code:
$ repo sync -j1
Initialize the environment

Code:
$ . build/envsetup.sh
Obtain the proprietary files:

Create a file with the name local_manifest.xml in the .repo directory. To see this directory, you have to press Ctrl-H in your file manager.

Create it with
Code:
gedit ~/cm10/.repo/local_manifest.xml
Paste the following lines to the editor
Code:
<manifest>
<project name="CyanogenMod/android_device_lge_p990" path="device/lge/p990" remote="github" revision="jellybean"/>
<project name="CyanogenMod/android_device_lge_star-common" path="device/lge/star-common" remote="github" revision="jellybean"/>
<project name="CyanogenMod/lge-kernel-star" path="kernel/lge/star" remote="github" revision="jellybean"/>
<project path="vendor/lge" name="TheMuppets/proprietary_vendor_lge.git" remote="github" revision="jellybean"/>
</manifest>
Save the file.
Run
Code:
$ repo sync
again to get the files needed.

Download the necessary prebuilts from cyanogenmod by running
Code:
$ ~/cm10/vendor/cm/get-prebuilts
And you are done!


IV. Building the ROM

Now build it:
Code:
$ brunch p990
And building process starts. Now have patience. Building takes around half an hour on fast systems and a lot more on older and slower machines.

When everything worked as it should you will find your new ROM-image in ~/cm10/out/target/product/p990

It is called cm-10-DATE-UNOFFICIAL-p990-zip. You can flash it via CWM as usual.

If you are having trouble with the WIFI not working with your newly flashed ROM, check the FAQ section C below for the solution.


V. Rebuilding with newest sources

Whenever you like to update your sources and build a new version you have to run these four simple commands:

Code:
$ cd ~/cm10
$ repo sync
$ . build/envsetup.sh
$ brunch p990
Building takes less time than it took for creating it the first build because it's only rebuilding new parts and using old parts that haven't changed.

Happy building!




VI. FAQ



A. How to tell how long it takes to build the ROM?

First, it depends on your hardware, second, whether it is your first build or a daily rebuild. To get a first number, you can use the “time” command and add the “brunch” command to it.
E.g.
Code:
time brunch p990
So the system will tell you how long it took to build the ROM. Then you know next time if it will be a short or long coffee break while waiting for your build to finish.


B. Is there a way to speed up the building process?


Actually, there are a lot of ways to speed up the process. Here are some of them:

1. Hardware:

When you build the first time it takes half an hour on fast machines and up to many hours on slower machines. What counts most is raw CPU power. Multi-core computers with a lot of fast RAM are recommended. The more cores the better. Memory-wise a setup with more than 8GB with aggressive but of course also stable timings is also adding to the building speed. A fast HDD or even SSD doesn't hurt either. When resourceful, you can use a system with multiple SSDs and gain more speed than single storage systems. But in most cases the CPU will be the biggest bottleneck. Check with tools, e.g. System Monitor in Ubuntu – and watch the resources tab to find out your bottleneck.

2. System-Software:

If you are using virtual machine software then try to optimize it. Look for “virtualization support” in the BIOS. Give it as much CPU power and memory as you can from your host system. Whenever it is possible it is recommended that you install the system directly, as the virtualization solution usually comes with a performance drop compared to a system installed and booted from directly.

3. The building software:

a. Out Directory
You can use a separate output directory for your builds, e.g. on a different hard drive with a fast file system.

Append
Code:
export OUT_DIR_COMMON_BASE=<path-to-your-out-directory>
to your .bashrc file.

b. Caching
You can setup Ccache, a system that acts as a compiler cache for all the parts of the building that are written in C. This is excellent if you rebuild often. But keep in mind that building the first time takes even longer when you have Ccache activated than building without it. So for first tests it is fine to build without Ccache enabled.

To enable Ccache add
Code:
export USE_CCACHE=1
to your .bashrc file
Optional: If you like to set the path, where the Ccache will be stored on your own, you have to add another line to the .bashrc
export CCACHE_DIR=<path-to-your-cache-directory>


Now run this command once to initialize the Ccache

Code:
prebuilts/misc/linux-x86/ccache/ccache -M 15G
C. I built the ROM successfully. I flashed it too, but the WiFi is not working anymore. What can I do?

The efforts of the CyanogenMod devs can be considered work in progress. And so it happens that features get broken while trying to fix others...

If you suffer from this then take the file 'wireless.ko'. You find the file below as an attachment. Push or copy it to '/system/lib/modules' and overwrite the file with the same name there. Change the rights to 644 or rw- r-- r-- It's the same as read/write by owner, read by group and read by other.

Without reboot, you can switch on the WiFi now. And you should be back in the game. Thanks to p.valenta for confirmation that it is working.


D. I checked the free space of the system partition. There isn't any. What can I do?

Without changing the size of the system partition not so much. But you can squeeze out a few MBs by removing some files from the created ROM image:

E.g. all the videos in /system/media/video can be deleted.
You can erase the /system/media/bootanimation.zip if you want.
Check /system/media/audio/, there you can delete some ringtones you are not using.

And if you know what you are doing, you can even get rid of some .apk files from '/system/app'.

For example LiveWallpapers.apk, VisualizationWallpapers.apk, CMWallpapers.apk, MagicSmokeWallpapers.apk, HoloSpiralWallpaper.apk are expendable.


E. I don't want to use Sun's/Oracle's Java Development Kit. Can I use another one instead?

Yes, you can. But using Sun's version is recommended by Google and CyanogenMod for building ROMs. So consider yourself warned. You can use the OpenJDK 6 that you will find already on your system if you installed the necessary packages as shown above. What you finally need to do is checking which Java version is active.

Code:
$ ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar
Select the default Java version for your system:

Code:
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javaws
$ sudo update-alternatives --config javadoc
$ sudo update-alternatives --config javah
$ sudo update-alternatives --config javap
$ sudo update-alternatives --config jar
Each time choose the OpenJDK6 variant.

Verify the symlinks: Javac, Java, Javaws, Javadoc, Javah, Javap and Jar should all point to the new Java location:

Code:
$ ls -la /etc/alternatives/java* && ls -la /etc/alternatives/jar

When everything you see says 'OpenJDK6' then you can build your ROM with the usual commands.



VII. Build your own ParanoidAndroid ROM based on CM10 for LG P990

IMPORTANT! THIS IS A FOLLOW-UP GUIDE THAT REQUIRES A WORKING BUILDING ENVIRONMENT.

Preparation

You need a tested and fully working building environment (Ubuntu 12.04/12.10, Java 6, etc.). If you do not have one already, please follow this guide throughly first and build a normal CM10 ROM from sources as a test. If everything works as it should, then you can proceed with the following lines.

ParanoidAndroid Environment

Let's start.

Use the terminal to make the steps. A terminal window can be opened by pressing Ctrl+Alt+T. Every single command for the terminal is marked with a $ sign. Just paste every command (without the $ sign) to your terminal window and there shouldn't be any problem.

Create a directory named 'paranoid' in your home folder

Code:
$ mkdir ~/paranoid
Initialize the Repo in your newly created directory:

Code:
$ cd ~/paranoid
$ repo init -u git://github.com/ParanoidAndroid/android.git -b jellybean
Before downloading the files you need to edit a file. One line leads to sync errors and has to be deleted from the file. Edit 'default.xml' in /paranoid/.repo/manifests/

(Hint if you can't see the .repo directory: it's hidden, so to make it visible press Ctrl+H) or use this line

Code:
$ gedit ~/paranoid/.repo/manifests/default.xml
Search (Ctrl+F) for 'ParanoidPreferences' and remove the whole line. Save and close the 'default.xml' file.

We need to add some LGE (P990) specific repositories as well. You can either copy the 'local_manifest.xml' file (it's the same!) from your cm10-build-environment or create a new file in /paranoid/.repo/

To create a new file use

Code:
$ gedit ~/paranoid/.repo/local_manifest.xml
Insert the following lines

Code:
<manifest>
<project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="jellybean"/>
<project name="CyanogenMod/android_device_lge_p990" path="device/lge/p990" remote="github" revision="jellybean"/>
<project name="CyanogenMod/android_device_lge_star-common" path="device/lge/star-common" remote="github" revision="jellybean"/>
<project name="CyanogenMod/lge-kernel-star" path="kernel/lge/star" remote="github" revision="jellybean"/>
<project name="TheMuppets/proprietary_vendor_lge" path="vendor/lge" remote="github" revision="jellybean"/>
</manifest>
Save it.

Sync the repositories (takes time!)

Code:
$ repo sync
Take a looong coffee break.

A few files

After the successful sync process go to 'paranoid/vendor/pa/products/'.

Create a new file with the name 'pa_p990.mk'

Code:
$ gedit ~/paranoid/vendor/pa/products/pa_p990.mk
Insert these lines:
(lines changed, xhdpi to hdpi, thanks rugglez)

Code:
# Check for target product
ifeq (pa_p990,$(TARGET_PRODUCT))
 
# Define PA bootanimation size
PARANOID_BOOTANIMATION_NAME := HDPI
 
# OVERLAY_TARGET adds overlay asset source
OVERLAY_TARGET := pa_hdpi
 
# include ParanoidAndroid common configuration
include vendor/pa/config/pa_common.mk
 
# Inherit CM device configuration
$(call inherit-product, device/lge/p990/cm.mk)
 
PRODUCT_NAME := pa_p990
 
GET_VENDOR_PROPS := $(shell vendor/pa/tools/getvendorprops.py $(PRODUCT_NAME))
 
endif
Save it.


Open 'AndroidProducts.mk' in 'paranoid/vendor/pa/products/' with

Code:
$ gedit ~/paranoid/vendor/pa/products/AndroidProducts.mk
and add these lines to then end of the file:
Code:
ifeq (pa_p990,$(TARGET_PRODUCT))
    PRODUCT_MAKEFILES += $(LOCAL_DIR)/pa_p990.mk
endif
Save it.

Create a file called 'p990.proprietaries' in 'paranoid/vendor/pa/vendorprops/'

Code:
$ gedit ~/paranoid/vendor/pa/vendorprops/p990.proprietaries
Code:
[
    {
        "account":      "TheMuppets",
        "repository":   "proprietary_vendor_lge",
        "target_path":  "vendor/lge",
        "revision":     "jellybean"
    }
]
Save it.

Open 'vendorsetup.sh' in 'paranoid/vendor/pa/'

Code:
$ gedit ~/paranoid/vendor/pa/vendorsetup.sh
Add this line

Code:
add_lunch_combo pa_p990-userdebug
Save it.

Get CM Prebuilts

Now go to

Code:
$ ~/paranoid/vendor/cm/get-prebuilts

Building ParanoidAndroid

Ready to go! Build your ROM now with

Code:
$ cd ~/paranoid
$ ./rom-build.sh p990
The compiling takes around the same amount of time as when building CM10. Half an hour minimum, up to a few hours on slower systems. You will find your CWM flashable zip in 'paranoid/out/target/product/p990/'. It is called 'pa_p990-version-date-time.zip'

Rebuilding

Everytime you want to rebuild or build a new version, just change to the directory, resync the sources and start building:

Code:
$ cd ~/paranoid
$ repo sync
$ ./rom-build.sh p990
If you haven't enlarged your system partition yet, you have to delete some files or the ROM probably won't fit.

Deletable files


/system/media/: delete bootanimation.zip, saves 9.4 MB
/system/media/video/: delete all files, saves 6.4 MB
/system/media/audio/ringtones/: keep one or two, delete the rest, saves up to ~8 MB

You can even delete some system apps (.apk) from '/system/app/' like LiveWallpapers.apk, VisualizationWallpapers.apk, CMWallpapers.apk, MagicSmokeWallpapers.apk, HoloSpiralWallpaper.apk
Attached Files
File Type: zip wireless.ko.zip - [Click for QR Code] (92.1 KB, 142 views)
Last edited by Raum1807; 7th January 2013 at 04:06 PM. Reason: Additions
The Following 70 Users Say Thank You to Raum1807 For This Useful Post: [ View ]
3rd November 2012, 07:37 PM   |  #2  
tetrahedonism's Avatar
Senior Member
Thanks Meter: 37
 
194 posts
Join Date:Joined: Sep 2011
More
I would personally love it if people included instructions for other distros. Not everything uses apt-get. That's kind of just me being nitpicky, but I've compiled CM9 on Archlinux with substituting a few things.

Also, what happened to the month of letting RC shine?
3rd November 2012, 07:45 PM   |  #3  
owain94's Avatar
Recognized Developer / Contributor
Flag The Hague
Thanks Meter: 6,061
 
3,535 posts
Join Date:Joined: Sep 2010
More
Quote:
Originally Posted by tetrahedonism

I would personally love it if people included instructions for other distros. Not everything uses apt-get. That's kind of just me being nitpicky, but I've compiled CM9 on Archlinux with substituting a few things.

Also, what happened to the month of letting RC shine?

Google their advice is to use ubuntu if you want to use a distros if your own choices you are probably advanced enough to change the instructions to your needs

And about Ricardo his month it is only a tut to compile it yourself you don't have to share it

Sent from my Galaxy Nexus using XDA Premium HD app
The Following 9 Users Say Thank You to owain94 For This Useful Post: [ View ]
3rd November 2012, 08:37 PM   |  #4  
tetrahedonism's Avatar
Senior Member
Thanks Meter: 37
 
194 posts
Join Date:Joined: Sep 2011
More
Quote:
Originally Posted by owain94

Google their advice is to use ubuntu if you want to use a distros if your own choices you are probably advanced enough to change the instructions to your needs

And about Ricardo his month it is only a tut to compile it yourself you don't have to share it

Sent from my Galaxy Nexus using XDA Premium HD app

I guess I could always post my own adapted instructions! Maybe some day. Ahah.
The Following 2 Users Say Thank You to tetrahedonism For This Useful Post: [ View ]
3rd November 2012, 09:06 PM   |  #5  
Ryukenden's Avatar
Senior Member
Thanks Meter: 174
 
369 posts
Join Date:Joined: Jan 2011
More
As funny as it may seem to u, instructions to compile CM10 on different distro than Ubuntu would be highly appreciated. Not everyone uses Ubuntu (I do actually), so u may help someone trying to set it up on their distro...

Just my 2 cents....
3rd November 2012, 09:46 PM   |  #6  
SuperSkill's Avatar
Senior Member
Flag Kristiansand
Thanks Meter: 1,157
 
1,671 posts
Join Date:Joined: Jun 2011
More
Quote:
Originally Posted by tetrahedonism

I guess I could always post my own adapted instructions! Maybe some day. Ahah.

I think you should, and hey, please don't tempt us, share your things

Thanks for the tread as well raum1807
3rd November 2012, 11:40 PM   |  #7  
Rayman96's Avatar
Senior Member
Flag Warsaw
Thanks Meter: 282
 
1,017 posts
Join Date:Joined: Jun 2009
Donate to Me
More
Great guide. This will probably let me make my own rom and share it on xda
The Following User Says Thank You to Rayman96 For This Useful Post: [ View ]
3rd November 2012, 11:49 PM   |  #8  
slebit's Avatar
Senior Member
Thanks Meter: 715
 
1,967 posts
Join Date:Joined: Dec 2010
More
Is it possible to compile on 32 bits system?

Sent from my LG-P990 using Tapatalk 2
4th November 2012, 01:12 AM   |  #9  
HerrKuk's Avatar
Senior Member
Flag [jœtəˈbɔrj] Göteborg
Thanks Meter: 212
 
593 posts
Join Date:Joined: Aug 2010
Donate to Me
More
Quote:
Originally Posted by slebit

Is it possible to compile on 32 bits system?

Sent from my LG-P990 using Tapatalk 2

No, 64 bits only

Sent from my LG-P990 using xda premium
The Following User Says Thank You to HerrKuk For This Useful Post: [ View ]
4th November 2012, 01:24 AM   |  #10  
Litderose's Avatar
Senior Member
Flag Paris
Thanks Meter: 206
 
382 posts
Join Date:Joined: Jun 2007
More
Quote:
Originally Posted by HerrKuk

No, 64 bits only

Sent from my LG-P990 using xda premium

You mean it's impossible to compile on Ubuntu 12.04 32-bit ?

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes