[LG Optimus 2x] XXMrHyde:
Building CM9 from Sources for O2X

This Guide is a Step by Step Guide to Build CM9 from official CM9 Sources.

It based on:

aMpeX`s [TUTORIAL] The Step-By-Step guide to build Cyanogenmod7 for the LG Optimus 2X

loganmc10`s [GUIDE] Building CM9 for G2X

I only change to P990, respectively CM9 and add the fix for working Baseband

You need:

- a installed Linux, (I use Ubuntu 11.10, 64 Bit)

- a fast PC or Notebook is recommended

- a fast internet-connections is recommended, (you have to download several GBs)

There are 10 Steps, (8 for building, and 2 optionals ):

1. Installing Build-Packages

2. Install and setup Android-SDK

3. Update path

4. Create directories

5. Install repository and download CM9 Sources

6. Fix for non working camera

6a. Fix the known issues

7. Compiling Unofficial CM9 Build

8. Fix unknown Baseband

9. Extended building

10. Optional changes

Some infos before start:

- read the whole Guide carefully, (possibly you have to read it a few times, untill you understand all steps)

- if you do it exactly as explained, there should be no problems, and the result is a working Unofficial CM9-Build

- don`t login to Linux as root

- if you get problems, feel free to PM me, if you can`t post in Dev-Forum

lets start,

1. Installing Build-Packages

install this for 32 bit and 64 bit:

Terminal:

type:

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

NOTE:

this will install Open-JDK instead of Sun-JDK,

(Sun-JDK isn`t longer official available for Ubuntu)

this will result in an error message at the beginning of compiling,

just ignore it, compiling will working fine.

If you want to install Sun-JDK instead of Open-JDK,

the user tonyp has made a tutorial.

use this line instead of above one

Terminal:

type:

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

than go to this tutorial

for me the tutorial above doesn`t work (Ubuntu 11.10 64 Bit)

this is working for me:

open terminal:

sudo add-apt-repository ppa:ferramroberto/java

sudo apt-get update

sudo apt-get install sun-java6-jdk sun-java6-plugin

sudo update-alternatives --config java

(note: you have to press the tab button to be able to press ok, after the last command ;) )

install this for 64 bit also:

Terminal:

type:

sudo apt-get install g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-4.4-multilib g++-4.4-multilib

2. Install and setup Android-SDK

Download newest Android-SDK from here (Linux (i386) )

Extract the Zip-Package to a directory of your choice

Terminal:

navigate to the tools-folder of Android-SDK and type:

./android

this will launch the AVD-Manager

check repository, select newest repository, and click install packages

3. Update path

go to your Home-Directory, and press CTRL + H to show hidden files,

open .bashrc

and add this:

export PATH="/home/<yourusername>/<path to the android SDK >/platform-tools/:${PATH}"
export PATH="/home/<yourusername>/bin/:${PATH}"

now you have to log out and in again for the changes take effect.

now check if changes are working,

Terminal:

type:

adb devices

you should see something like this:

4. Create directories

Terminal:

type:

mkdir -p ~/bin

mkdir -p ~/android/system

5. Install repository and download CM9 Sources

Install repository

Terminal:

type:

curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

chmod a+x ~/bin/repo

cd ~/android/system/

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

enter name, email adress, and choose if you want colors or not

Download CM9 Sources:

Terminal:

type:

cd ~/android/system/

repo sync

depending on your internet connection speed this can take several hours

press CTRL + H

go to :

/android/system/.repo/

create:

local_manifest.xml

paste into local_manifest.xml:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project path="device/lge/p990" name="CyanogenMod/android_device_lge_p990" />
<project path="device/lge/star-common" name="CyanogenMod/android_device_lge_star-common" />
<project path="vendor/lge" name="Owain94/proprietary_vendor_lge.git" remote="github" />
</manifest>

Terminal:

type:

cd ~/android/system/

repo sync

6. Fix for non working camera

download this zip-package MediaFire SolidFiles.

(I don`t make this patch, and don`t know who had made it, if you made it PM me and I`ll give credit for your work)

Extract the Zip-Package to a directory of your choice.

Terminal:

type:

cd ~/android/system

patch -p1 <

NOTE: after "<" there has to be a "blank space" (press spacebar)

now drop the first ...diff file from extracted package into terminal, the path will be automatically added,

run the created command,

the same procedure for the other 4 files

6a. Fix the known issues

for broken building:

open:

device/lge/p990/BoardConfig.mk

delete line:

BOARD_TOUCH_RECOVERY := true

For mobile data fix:

place this file to android/system/system/core/init/ (overwrite excisting file),

7. Compiling Unofficial CM9 Build

Terminal:

type:

~/android/system/vendor/cm/get-prebuilts

cd ~/android/system/

. build/envsetup.sh

brunch p990

depending on your PC or Notebooks specs compiling will take from 30 minutes to several hours

you can find your Rom-Zip-Package at:

8. Fix unknown Baseband

open your Rom-Zip-Package and extract /system/build.prop

(don`t close Archivmanager)

open build.prop:

delete line:

(thanks to owain94 for deleting line info)

find line:

replace this line with:

save build.prop

drop modded build.prop into Archivemanager (/system, overwrite existing file)

Now your Unofficial CM9 Build is ready to install

------------------------------------------------------------------------------------------------------------------------------------------------------------

9. Extended building:

I decided to make a optional 9. Step to have a better building experience

(all tipps by owain94, thanks)

This Step is a replacement for Step 7!

Terminal:

type:

cd ~/android/system && clear && cd vendor/cm && ./get-prebuilts && cd ../../ && clear && . build/envsetup.sh && brunch p990 2> warn.log

this command downloads the cm-prebuilds,

sets up the build environment,

start the building,

exports all warnings and errors to a text file

and cleans the Terminal.

open another Terminal

type:

cd ~/android/system && clear && tail -f warn.log

this command cleans the terminal,

shows the warnings and errors in this second Terminal,

and keep the focus on it,

first terminal only shows the building process,

so it`s much easier to catch problems while compiling.

If you have connected two screens to your PC or Notebook,

you can also place second Terminal on second screen.

you can find your Rom-Zip-Package also at:

10. Optional changes:

Fix for working torch and torch power-widget:

"activate" torch and power-widget:

open:

/android/system/packages/apps/Torch/res/values/config.xml

add or change to:

<bool name="useCameraInterface">true</bool>

open:

/android/system/packages/apps/Settings/res/values

add or change to:

<bool name="has_led_flash">true</bool>

add Torch.apk to the package:

open:

/android/system/device/lge/star-common/star.mk

change:

## LGE stuffs
PRODUCT_PACKAGES += \
LGEServices \
bridgeutil \
libbridges \
libbridge \
libbridge_jni \
secureclockd \
libsecureclock \
screencap \
hwprops \
com.android.future.usb.accessory

to:

## LGE stuffs
PRODUCT_PACKAGES += \
LGEServices \
bridgeutil \
libbridges \
libbridge \
libbridge_jni \
secureclockd \
libsecureclock \
screencap \
hwprops \
com.android.future.usb.accessory \
Torch

Credits:

aMpeX, loganmc10, pastime1971, owain94, tonyp, temasek