[LG Optimus 2x] Raum1807:
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:

$ 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:

$ 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:

$ chmod +x jdk-6u38-linux-x64.bin

3. Extract the bin file:

$ ./jdk-6u38-linux-x64.bin

4. Move the extracted folder to this this location:

$ sudo mv jdk1.6.0_38 /usr/lib/jvm/./jdk-6u38-linux-x64.bin

5. Install the new Java source in system:

$ 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:

$ 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:

$ java -version

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

$ 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.

$ 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:

$ mkdir ~/cm10
$ cd ~/cm10

Initialize Repo:

$ repo init -u git://github.com/CyanogenMod/android.git -b jellybean

and enter your credentials.

Download the sources:

$ 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

$ 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

$ repo sync -j1

Initialize the environment

$ . 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

gedit ~/cm10/.repo/local_manifest.xml

Paste the following lines to the editor

<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

$ repo sync

again to get the files needed.

Download the necessary prebuilts from cyanogenmod by running

$ ~/cm10/vendor/cm/get-prebuilts

And you are done!

IV. Building the ROM

Now build it:

$ 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:

$ 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.

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

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

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

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.

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

Select the default Java version for your system:

$ 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:

$ 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

$ mkdir ~/paranoid

Initialize the Repo in your newly created directory:

$ 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

$ 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

$ gedit ~/paranoid/.repo/local_manifest.xml

Insert the following lines

<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!)

$ 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'

$ gedit ~/paranoid/vendor/pa/products/pa_p990.mk

Insert these lines:

(lines changed, xhdpi to hdpi, thanks rugglez)

# 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

$ gedit ~/paranoid/vendor/pa/products/AndroidProducts.mk

and add these lines to then end of the file:

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/'

$ gedit ~/paranoid/vendor/pa/vendorprops/p990.proprietaries

[
{
"account": "TheMuppets",
"repository": "proprietary_vendor_lge",
"target_path": "vendor/lge",
"revision": "jellybean"
}
]

Save it.

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

$ gedit ~/paranoid/vendor/pa/vendorsetup.sh

Add this line

add_lunch_combo pa_p990-userdebug

Save it.

Get CM Prebuilts

Now go to

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

Building ParanoidAndroid

Ready to go! Build your ROM now with

$ 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:

$ 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