[Guide How-To] ProJect Developer ROM Building steps, tricks and tips for SX2011

Search This thread
R

rebelos

Guest
Project Developer IV

Welcome

This is a guide for all those who want to build for their Xperia 2011 Devices but do not neccesasarily have the knowledge or experience.


This is an unofficial guide for the building of custom ROMs and other mods for the Xperia 2011 Devices. This is a work in progress, with additions being made as often as possible. This thread has already grown with the help of the devs established in this forum. BMP777 began this project a year ago when I was using a Samsung GS II Skyrocket. BMP777 started another alike thread called PR II in the LGOG forum a while back as well. I have since moved on to a ONE, but both threads remain to this day. The point is this: everyone who uses this site has a desire for modding, customizing, and/or otherwise altering their device. Unfortunately, many have no idea how to go about doing these things for themselves. As such, there is a lot of dissatisfaction among developers about receiving constant demands, suggestions, and requests for updates. This thread is meant to give those who want to step up and build for themselves the means to do so. It is an ever-changing thread, with all assistance welcomed.

READ ME:

On one hand, it should go without saying that if you have no knowledge and/or experience with building, java, C++, and various other tools, you probably shouldn't begin here. At the same time, it is possible to learn to build, provided you can read, follow directions, and aren't too lazy to RESEARCH.

OH YEAH, and you better have patience. This isn't easy. It will be work. The quickest way to get flamed is to show yourself to be lazy. If you think that with a couple clicks, you can have your own flashy ROM, forget it. But, if you do want to learn, this is a good place to get started. I have no ego about this; I started the same way and just want to help everyone learn to build their own ROM. But, everyone will struggle to get to a successful point, and lazy, unmotivated people just irritate those who have had to learn from scratch too. Tutorials will be posted for any new thing learned and built as time and space allow. ALL ARE WELCOME AND ALL QUESTIONS ARE TOO. But, seriously, if it's a really ridiculous one, I/we reserve the right to screw with you about it.

ALWAYS REMEMBER:

Just_Google_It_by_doctor_a.gif



Thread Disclaimer:
The instructions and extras posted here are to be used at your own risk. I am working hard to provide good, workable tutorials that will make successful building much easier. Nevertheless, I am not responsible if you lose your files, brick your device, or inadvertently cause a nuclear war. If you are seeking absolute perfection, RUN NOW WHILE YOU STILL CAN!!


Thread Navigation :

# 2 > Setting Up Build enviorment
# 3 > Building instructions & How To Build Using Linaro 4.8 Toolchain
# 4 > Necessary Fixes for Xperia 2011 Line UP
# 5 > Kernel building and CCACHE
# 6 > reserved for future




XDA:DevDB Information
Project Developer, a Tool/Utility for the Sony Ericsson Xperia Arc

Contributors
officiallysonyrebel, car vs driver , BMP777, Mikeioannina and My buddys vishal_android_freak , saki3d , besttt and YOU

Version Information
Status: Testing

Created 2013-11-29
Last Updated 2013-12-03
 
R

rebelos

Guest
Build Enviorment Set up :

This is a combination of the steps offered in the threads 'Compile JB on Ubuntu' and TeamChopsticks CyanogenMod.

Special thanks to dastin1015 and TeamChopsticks.

Tip: Allocate at least 75 gigs of space for the building of ONE ROM. If you install ccache, you will want 90. A complete build directory can use as much as 100 gigs, so make sure you have plenty of room. One of the ways to fail out a build is too use all of your partition before acquiring all the necessary files.

Here are the steps from those 2 tutorials in correct order:

0.1 ))
Install Gedit

Code:
# gedit
sudo apt-get install gedit


1) You need the following:

-JDK 6 if you wish to build Jellybean.


Code:
[COLOR="Black"]$ sudo apt-get oracle-java7-installer
-Python 2.4 -- 2.7, which you can download from python.org.[/COLOR]

Or:


Code:
[COLOR="black"]$ sudo apt-get install python
-Git 1.7 or newer. You can find it at git-scm.com.[/COLOR]

Or:


Code:
[COLOR="black"]$ sudo apt-get install git-core[/COLOR]

-Android SDK:

Download the SDK here: http://developer.android.com/sdk/index.html
Extract the SDK and place it in your home directory.
I renamed my SDK to android-sdk to make it easier to navigate to – this tutorial assumes you've done that as well.
Go to your home folder, press Ctrl+H to show hidden files, and open up your .bashrc file.
Add these lines at the bottom of the file:



Code:
[COLOR="black"]# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
export PATH=${PATH}:~/bin[/COLOR]


Find your .profile file and add this at the bottom of the file:



Code:
[COLOR="black"]PATH="$HOME/android-sdk/tools:$HOME/android-sdk/platform-tools:$PATH"
You have now successfully installed the Android SDK.[/COLOR]

To check for updates issue this into your terminal:

Code:
[COLOR="black"]$ android[/COLOR]


2) Install required packages. 64-bit (recommended)



Code:
[COLOR="black"]$ sudo apt-get install git-core gnupg flex bison gperf build-essential 
  zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs 
  x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev 
  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown 
  libxml2-utils lzop schedtool[/COLOR]


On newer versions of Ubuntu such as 11.10 you may need to do the following:


Code:
[COLOR="black"]$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so[/COLOR]


Code:
[COLOR="black"]$ 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 xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so[/COLOR]


3) Configure your USB.



Code:
[COLOR="black"]$ gksudo gedit /etc/udev/rules.d/51-android.rules[/COLOR]


Inside of this blank text file insert:


Code:
[COLOR="black"]#Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666"

#ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666"

#Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666"

#Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666"

#Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091E", MODE="0666"

#Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666"

#HTC
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666"

#Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666"

#K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666"

#KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666"

#Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666"

#Lenevo
SUBSYSTEM=="usb", ATTR{idVendor}=="17EF", MODE="0666"

#LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"

#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666"

#NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666"

#Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666"

#Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666"

#OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666"

#Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10A9", MODE="0666"

#Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666"

#PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666"

#Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666"

#SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666"

#Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"

#Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666"

#Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666"

#Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666"

#ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19D2", MODE="0666"[/COLOR]


4) Save the file and close it and then issue this command:


Code:
[COLOR="black"]$ sudo chmod a+r /etc/udev/rules.d/51-android.rules[/COLOR]


5) Install the repo:


Code:
[COLOR="black"]$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo[/COLOR]


Create your work directory:

Code:
[COLOR="black"]mkdir ~/"your directory name here"     For example: mkdir ~/cm10
cd ~/cm10[/COLOR]


Setup local manifest:

Code:
[COLOR="Black"]mkdir .repo/local_manifests
touch .repo/local_manifests/semc.xml
gedit .repo/local_manifests/semc.xml[/COLOR]
 
Last edited:
R

rebelos

Guest
Necessary Files for Xperia 2011 :

Tip :For Building any Rom for Xperia 2011 devices u need these specific device files

1 . first is "semc.xml"
2. second is "patches"

you can find correct SEMC.xml here : [thanks to @mikeioannina for maintaining our device Sources

===================================================================================
===================================================================================
For KitKat 4.4.x

* Patch #1 Fix semc camera preview
Code:
git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_av refs/changes/82/54582/1 && git cherry-pick FETCH_HEAD

* Patch #2 Allow devices to disable fence sync
Code:
git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native refs/changes/94/52994/3 && git cherry-pick FETCH_HEAD

* Patch #3 Backwards compatibility with old EGL
Code:
git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native refs/changes/57/54257/4 && git cherry-pick FETCH_HEAD

* Patch #4 Bring back support for mHeap-based screenshots

Code:
git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native refs/changes/62/53162/5 && git cherry-pick FETCH_HEAD

*Patch No. 5 # SoftapControllerTI: update parameters for setSoftap
Code:
git fetch http://review.cyanogenmod.org/CyanogenMod/android_system_netd refs/changes/05/55805/1 && git cherry-pick FETCH_HEAD









====================== DO NOT USE IT - I M WARNING or u will get ERRORS ==========================
Aditonal Patch #5 Use AOSP version of wpa_supplicant_lib
Code:
git fetch http://review.cyanogenmod.org/CyanogenMod/android_hardware_ti_wlan refs/changes/89/54289/2 && git cherry-pick FETCH_HEAD


====================================================
 
Last edited:
R

rebelos

Guest
Building Instructions : For CyanogenMod :: AOKP :: Carbon roms :: Beanstalk

Unofficial

26dca__cyanogenmod-10.2.jpg
thanks mikeioannia for initial CM guide :)



To get started with Android/CyanogenMod, you'll need to get familiar with Git and Repo.

To initialize your local repository using the CyanogenMod trees, use a command like this:

first create folder named " cm "
Code:
mkdir cm

enter into cm
Code:
cd ~/cm

For CM - 11.0 kitkat 4.4.x
Code:
[COLOR="black"]repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0[/COLOR]

Then to sync up:

Code:
[COLOR="black"]repo sync[/COLOR]

Please see the CyanogenMod Wiki for building instructions.

For more information on this Github Organization and how it is structured, please read the wiki article.

Create and edit semc.xml in .repo:

Code:
[COLOR="black"]gedit .repo/local_manifests/semc.xml[/COLOR]

Add this to the semc.xml:

For CM 11.0 KitKat 4.4.x

copy paste semc.xml for kikat 4.4 from here : https://raw.github.com/LegacyXperia/local_manifests/cm-11.0/semc.xml

then
Code:
[COLOR="Black"]repo sync[/COLOR]

For 4.4 apply patches from 4.4

1.
Code:
cd ~/cm/frameworks/av
-> copy paste patch #1 press enter

2.
Code:
cd ~/cm/frameworks/native
-> copy paste patch #2 press enter
-> copy paste patch #3 press enter
-> copy paste patch #4 press enter

3.
Code:
cd ~/cm/system/netd
-> copy paste patch #5 press enter

Code:
[COLOR="black"]. build/envsetup.sh (notice the period and space)
vendor/cm/get-prebuilts
[/COLOR]

then

Code:
brunch <device>






Special thanks to scott.hart.bti for his hard work -

From terminal
1. type
Code:
[COLOR="black"]cd[/COLOR]
.
This will bring you to your root folder.

2. type
Code:
[COLOR="black"]mkdir beanstalk[/COLOR]
.
This will create a folder named beanstalk.

3. type
Code:
[COLOR="black"]cd beanstalk[/COLOR]
.
This will take you to the beanstalk directory created from previous step

4. type
Code:
[COLOR="black"]repo init -u git://github.com/scotthartbti/android.git -b kk44[/COLOR]
.
This will setup the folders to be synced.

5. For Beanstalk KitKat 4.4.x

copy paste semc.xml for kikat 4.4 from here : https://raw.github.com/LegacyXperia/local_manifests/cm-11.0/semc.xml

then
Code:
[COLOR="Black"]repo sync[/COLOR]

apply patches for 4.4

1.
Code:
cd ~/beanstalk/frameworks/av
-> copy paste patch #1 press enter

2.
Code:
cd ~/beanstalk/frameworks/native
-> copy paste patch #2 press enter
-> copy paste patch #3 press enter
-> copy paste patch #4 press enter

2.
Code:
cd ~/beanstalk/system/netd
-> copy paste patch #5 press enter


9. Outside of terminal, navigate to beanstalk/vendor/cm. Double click on the get-prebuilts file and select run in terminal. This will fetch necessary files needed to build and place them where they need to be.

10. Type
Code:
[COLOR="Black"]. build/envsetup.sh && brunch <device>[/COLOR]

11. Previous step will start building beanstalk for your device. The process takes anywhere from 1 - 3 hours depending on your computer.

12. Once completed, it will say package complete and you will have a beanstalk named zip file in your out folder.


Unofficial

AOKP.jpg


Special thanks to spleef and ktempleman for laying this out

This set of instructions is unverified. If you build successfully or have build issues, please post here so we can confirm or fix what isn't working




First:

Code:
[COLOR="Black"]mkdir aokp[/COLOR]

then

Code:
[COLOR="black"]cd aokp[/COLOR]

then

Code:
[COLOR="black"]repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat[/COLOR]

after it does its thing

Code:
[COLOR="black"]mkdir .repo/local_manifests
touch .repo/local_manifests/semc.xml
gedit .repo/local_manifests/semc.xml[/COLOR]

copy paste semc.xml for kikat 4.4 from here : https://raw.github.com/LegacyXperia/local_manifests/cm-11.0/semc.xml

save and exit then


Code:
[COLOR="black"]repo sync[/COLOR]

after everything syncs

apply patches for 4.4

1.
Code:
cd ~/aokp/frameworks/av
-> copy paste patch #1 press enter

2.
Code:
cd ~/aokp/frameworks/native
-> copy paste patch #2 press enter
-> copy paste patch #3 press enter
-> copy paste patch #4 press enter

2.
Code:
cd ~/aokp/system/netd
-> copy paste patch #5 press enter


Code:
[COLOR="black"]gedit vendor/aokp/vendorsetup.sh[/COLOR]

and add this to the bottom:

Code:
[COLOR="black"]add_lunch_combo aokp_device-userdebug[/COLOR]

save and exit.. then


Code:
[COLOR="black"]. build/envsetup.sh[/COLOR]

Code:
[COLOR="black"]brunch device[/COLOR]




For more on AOKP building, try here: http://aokp.co/learn/so-you-want-to-build-aokp-jb-ubuntu-1204

And Here: https://github.com/AOKP


Unofficial

XzinYIT.png




Getting Started

To get started with the Carbon-Dev sources, you'll need to get familiar with Git and Repo.

Create the Directories

You will need to set up some directories in your build environment.

To create them run:

Code:
[COLOR="black"]mkdir -p ~/carbon[/COLOR]

Install the Repository

You may need to reboot for these changes to take effect. Now enter the following to initialize the repository:

Code:
[COLOR="black"]cd ~/carbon[/COLOR]

Repositories:

Before you continue --> run this in the terminal

Code:
[COLOR="black"]repo init -u https://github.com/CarbonDev/android.git -b kk[/COLOR]

after it does its thing

Code:
[COLOR="black"]mkdir .repo/local_manifests
touch .repo/local_manifests/semc.xml
gedit .repo/local_manifests/semc.xml[/COLOR]

copy paste semc.xml for kikat 4.4 from here : https://raw.github.com/LegacyXperia/local_manifests/cm-11.0/semc.xml

save and exit then


Code:
[COLOR="black"]repo sync[/COLOR]

after everything syncs

apply patches for 4.4

1.
Code:
cd ~/carbon/frameworks/av
-> copy paste patch #1 press enter

2.
Code:
cd ~/carbon/frameworks/native
-> copy paste patch #2 press enter
-> copy paste patch #3 press enter
-> copy paste patch #4 press enter

3.
Code:
cd ~/carbon/system/netd
-> copy paste patch #5 press enter


Code:
[COLOR="black"]gedit vendor/carbon/vendorsetup.sh[/COLOR]

and add this to the bottom:

Code:
[COLOR="black"]add_lunch_combo carbon_device-userdebug[/COLOR]

save and exit.. then


Code:
[COLOR="black"]. build/envsetup.sh[/COLOR]

Code:
[COLOR="black"]brunch device[/COLOR]




txri.png


To get started with AORP, you'll need to get familiar with Git and Repo.

To initialize your local repository using the AORP trees, use a command like this:

first create folder named " AORP "
Code:
mkdir AORP

enter into AORP
Code:
cd ~/AORP

For kitkat 4.4.x
Code:
[COLOR="black"]repo init -u git://github.com/AORP/android.git -b kk[/COLOR]

Then to sync up:

Code:
[COLOR="black"]repo sync[/COLOR]

Please see the CyanogenMod Wiki for building instructions.

For more information on this Github Organization and how it is structured, please read the wiki article.

Create and edit semc.xml in .repo:

Code:
[COLOR="black"]gedit .repo/local_manifests/semc.xml[/COLOR]

Add this to the semc.xml:

For CM 11.0 KitKat 4.4.x

copy paste semc.xml for kikat 4.4 from here : https://raw.github.com/LegacyXperia/local_manifests/cm-11.0/semc.xml

then
Code:
[COLOR="Black"]repo sync[/COLOR]

For 4.4 apply patches from 4.4

1.
Code:
cd ~/AORP/frameworks/av
-> copy paste patch #1 press enter

2.
Code:
cd ~/AORP/frameworks/native
-> copy paste patch #2 press enter
-> copy paste patch #3 press enter
-> copy paste patch #4 press enter

3.
Code:
cd ~/AORP/system/netd
-> copy paste patch #5 press enter

Code:
[COLOR="black"]. build/envsetup.sh (notice the period and space)
vendor/cm/get-prebuilts
[/COLOR]

then

Code:
brunch <device>





Next Tutorial is Strictly Not for beginners





Building with Linaro 4.8 toolchain

Checkout these toolchains customised for arm v7 and scorpion Cpu here http://xdaforums.com/showthread.php?t=2098133
thanks @Christopher83

Go into Terminal and navigate to the root folder of your source tree, then:

Code:
[COLOR="Black"]prebuilts/gcc/linux-x86/arm/[/COLOR]

Run:

Code:
[COLOR="black"]wget http://releases.linaro.org/13.06/components/toolchain/gcc-linaro/4.8/gcc-linaro-4.8-2013.06.tar.bz2[/COLOR]

Run:

Code:
[COLOR="black"]bunzip2 *.tar.bz2[/COLOR]

Run:

Code:
[COLOR="black"]tar -xvf *.tar[/COLOR]

Using your file manager, navigate to the root folder of your source tree again.

Navigate To "/build", in your root folder.

Run:

Code:
[COLOR="black"]gksudo gedit envsetup.sh[/COLOR]

change the line in bold, to look exactly like this one:

Code:
[COLOR="black"]case $ARCH in
        x86) toolchaindir=x86/i686-linux-android-4.6/bin
            ;;
        [B]arm) toolchaindir=arm/gcc-linaro-4.8-2013.06[/B]  [COLOR="Red"]<--------[/COLOR]
            ;;
        mips) toolchaindir=mips/mipsel-linux-android-4.6/bin
            ;;
        *)
            echo "Can't find toolchain for unknown architecture: $ARCH"
            toolchaindir=xxxxxxxxx
            ;;
esac
[/COLOR]

Exit out and open new. Initialize and build. That's it! Makes you wonder why you never did it before, right?

Not so fast. You may have build issues, you may not. I had a few lengthy sets of errors in gsm calltracker and another .java file that was solved by using Meld and making it look exactly like a successful build's file. More as I learn.......


Thanks to infected_ for this tut; his post can be found here: [/COLOR]

http://xdaforums.com/showpost.php?p=42976693&postcount=12









This is a work in progress. Many more pieces of information will be added and this is meant to be an ever-changing thread. If you see something that is outdated or incorrect, please let me know ASAP, so I can make the correction. Also, make sure that any info offered can be and has been confirmed as functional.










Thanks to:

CyanogenMod
scott.hart.bti
Team Carbon
david279
MallardDuck
ktempleton
AdhvanIt
matthew0776
spleef
M4570D0N
car vs driver
mikeioannina
BMP777
 
Last edited:
R

rebelos

Guest
Kernel Building and Ccache

Building your first kernel
(this is non-device-specific; tweaks will be required to produce an M7SPR kernel)
:


This is a set of steps to get you building your first kernel. Special thanks to thewadegeek for putting this tutorial together. His thread can be found here: http://xdaforums.com/showthread.php?t=1748297


Step 1. Build Environment

A. Install Ubuntu 12.04(Not holding your hand here, if you can't do this you shouldn't be messing with kernels)

B. Required packages: git-core, gnupg, flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev, build-essential, zip, curl, libncurses5-dev, zlib1g-dev, ia32-libs, lib32z1-dev, lib32ncurses5-dev, gcc-multilib, g++-multilib, and Adb.

C. Open a terminal

D. Type
Code:
[COLOR="black"]mkdir android[/COLOR]

E. Type
Code:
[COLOR="black"]cd android[/COLOR]

G.Type
Code:
[COLOR="black"]mkdir kernel[/COLOR]


Step 2. Your Source

A. Open your Terminal Prompt

B. Type
Code:
[COLOR="black"]cd android/kernel[/COLOR]

C. Type
Code:
[COLOR="black"]git clone git://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains[/COLOR]

D. Now comes the tricky part, you need to have some-type of source for your kernel. Check the following two sites for your device as appropriate. Once you have it download it is extracted/cloned into a folder in your kernel directory.

http://developer.sonymobile.com/wpor...ads/opensource

Step 3. Modifications

This is the part people are curious about, they want to make modifications to the kernel to make it "special". Start all these from the root directory of your kernel source.

Mod 1. Applying a patch

A. Download the patch you wish to apply, in this case this one should work.

B. Save that file as "kernelPatch" in your kernel directory.

C. Open a Terminal

D. Move into the root directory of the kernel you wish to patch.

E. Type
Code:
[COLOR="black"]patch -p1 < ../kernelPatch[/COLOR]


Mod 2. Adding a Governor Alone

A. Open "drivers/cpufreq/Kconfig"

B. Add the following lines in appropriate spot amongst the other govenor's

Code:
[COLOR="Black"]config CPU_FREQ_DEFAULT_GOV_SMARTASS
            bool "smartass"
            select CPU_FREQ_GOV_SMARTASS
            select CPU_FREQ_GOV_PERFORMANCE
            help
              Use the CPUFreq governor 'smartass' as default.
[/COLOR]

Code:
[COLOR="Black"]config CPU_FREQ_GOV_SMARTASS
           tristate "'smartass' cpufreq governor"
           depends on CPU_FREQ
           help
             smartass' - a "smart" optimized governor!
             If in doubt, say N.[/COLOR]

C. Open "drivers/cpufreq/Makefile"

D. Add the following line in the appropriate spot.

Code:
[COLOR="Black"] obj-$(CONFIG_CPU_FREQ_GOV_SMARTASS)     += cpufreq_smartass.o[/COLOR]

E. Create a file called "drivers/cpufreq/cpufreq_smartass.c"

F. Put the following code in that file.

http://pastebin.com/f0Bk9kVZ

G. open "include/linux/cpufreq.h"

H. Under the "Cpufreq Default" section add

Code:
[COLOR="Black"]#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_SMARTASS)
extern struct cpufreq_governor cpufreq_gov_smartass;
#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_smartass)[/COLOR]

Ok there is a governor added, do the exact same steps for any other one's you would like to add.


Step 4. Getting a Config file

Option A. Pulling a config file from a kernel.

A. Hook up a device that is using a kernel similar to one you are using as your base.

B. Open a terminal

C. Change to your root kernel directory

D. Type
Code:
[COLOR="black"]adb pull /proc/config.gz[/COLOR]

E. Type
Code:
[COLOR="black"]gunzip config.gz[/COLOR]

F. Type
Code:
[COLOR="black"]mv config arch/arm/configs/<your_config_name>_defconfig[/COLOR]


Option B. Using the manufacturers config.

Unfortunately as stated above, not all kernels support the "/proc/config.gz" method. You can typically find a manufacturer's configuration file in "arch/arm/configs". I believe the one for my HTC Flyer was called "flyer_hc_defconfig", so look for a layout similar to that one. Also read the README to get a better idea of how to modify it. I would personally make a copy of it called "<your_config_name>_defconfig" and use that as my base.

Step 5. Building

Time to start the real "build" section of this tutorial.

Part A. Pre-build Steps

A. Open terminal and change to the root of your kernel directory

B. Type
Code:
[COLOR="black"]export ARCH=arm[/COLOR]

C. Type
Code:
[COLOR="black"]export CROSS_COMPILE=~/android/kernel/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-[/COLOR]

Part B. The First Build

A. Type
Code:
[COLOR="black"]make <your_config_name>_defconfig[/COLOR]

B. Type
Code:
[COLOR="black"]make menuconfig[/COLOR]
and make the required changes to use any modules you added or similar changes.

C. Type
Code:
[COLOR="black"]make -j<maximum number of jobs>[/COLOR]

Part C. Re-Builds

A. Type
Code:
[COLOR="black"]make clean[/COLOR]

B. Type
Code:
[COLOR="black"]make oldconfig[/COLOR]

C. Type
Code:
[COLOR="black"]make -j<maximum number of jobs>[/COLOR]

Part D. Building Modules

You have two options:

A. Type
Code:
[COLOR="black"]make modules[/COLOR]

B. Type
Code:
[COLOR="black"]make path/to/your/module.ko[/COLOR]

The above steps explained:

Part A.(These steps are required every time you close your terminal and re-open it to build again.)

A. Ok shouldn’t need to explain this.

B. This command sets your target architecture.

C. Defines the path to the toolchain we are going to use to compile our kernel. You can change this to point towards whatever toolchain you have downloaded or feel like using, the way it is currently configured it will use the Linaro toolchain that we downloaded above.

Part B.(These only need to be run the first time you build a kernel.)

A. Load's your configuration file from earlier.

B. Open up a menu to configure your kernel. It will use the config file you loaded in the previous step as a base.

C. Viola start the build. I typically allow 1 job per core, so on my quad core machine I put "make -j4". Just raising that number will not make your build faster, your processor needs to be able to support the number of jobs you are assigning it.

Part C. (Use the command's when you are building any-time outside of the first)

A. This command gets rid of any old/outdated binaries or modules you compiled before, and let's start fresh. I like to run it every I build unless my changes are really small and localized.

B. A very awesome command, it parses through what has changed and only prompts you about new options.

C. See the explanation for the above "Part C.".

Part D.(Use these for just building kernel modules.)

A. This will re-build all modules.

B. Will rebuild just the module you need. Very useful when you need to rebuild a WiFi module.


Step 6. Now what

Ok we have now started our build and we are waiting for it to finish, so there are two possible outcomes:

Outcome A. Build Succeeds

W00t!! You have a kernel built by your self from source. There are a couple things you need in-order to use this kernel on your device any ".ko" modules and the zImage binary. If you pay attention to the output of your compiler then you will see the location of those objects. However the following commands will make your life a bit easier(Thanks Recognized Developer Hacre):

A. Open a terminal

B. Change to your root kernel directory

C. Type
Code:
[COLOR="black"]mkdir ../<your_kernel>_output[/COLOR]

D. Type
Code:
[COLOR="black"]cp arch/arm/boot/zImage ../<your_kernel>_output/zImage[/COLOR]

E. Type
Code:
[COLOR="black"]find . -name "*.ko" -exec cp {} ../<your_kernel>_output \;[/COLOR]

The above steps explained:

A-C. Self-Explanatory

D. Move our kernel binary into our output folder

E. This handy bit of magic finds all ".ko" modules and also copies them into your output file.

You will also need to assemble a kernel image containing a initramfs for your device, along with the kernel binary and such. That however is beyond the scope of this tutorial. To get started though try searching the following phrases.

Code:
[COLOR="Black"]building android kernel image
xda build kernel image
xda unpack boot.img[/COLOR]

Outcome B. Build Fails

Oh dear. It failed. Well guess what...this is going to happen..a LOT. Get used to it, and get used to googling and experimenting with different solutions. The following are some tips that will help you with debugging your issues.

Running a "Clean" build

A. Backup your config file - Type
Code:
[COLOR="black"]cp .config ../backupConfig[/COLOR]

B. Re-run the build process using just your defconfig from earlier.

Limiting Output(Thanks Hacre.)

A. Another good tip is to run "make -j1" to get the error, as it will limit the amount of text you need to scroll through.[/COLOR]
[/CENTER]






Tutorial for CM-11.0 custom kernel coming Soon


CCACHE

Here is a brief tutorial on the installation of Ccache, which can shorten build times drastically :

If you have room on your build system you can speed
your builds up considerably by using ccache. ccache is a compiler
cache. It speeds up re-compilation of C/C++ code by caching
previous compiles and detecting when the same compile is
being done again.

Install it with apt-get:
Code:
[COLOR="Black"]sudo apt-get install ccache[/COLOR]

Set environment vars for Android use:
(I put these exports in my .bashrc)

Code:
[COLOR="Black"]export USE_CCACHE=1
export NDK_CCACHE=ccache[/COLOR]

Set a cache size of 10G for optimal results:

Code:
[COLOR="black"]ccache -M 10G[/COLOR]

Check the status of your cache with the command:

Code:
[COLOR="black"]ccache -s [/COLOR]

Returns:

Code:
[COLOR="black"]
cache directory                 /home/jocala/.ccache
cache hit                         106673
cache miss                         18379
called for link                     3758
preprocessor error                     5
not a C/C++ file                    4425
unsupported compiler option          678
no input file                       4565
files in cache                     36758
cache size                           3.2 Gbytes
max cache size                      10.0 Gbytes[/COLOR]
[/QUOTE]
 
Last edited:
R

rebelos

Guest
Really Useful things :)


Here are some relevant topics/tutorials/sites:

Download | Ubuntu - www.ubuntu.com/download

Official Ubuntu Documentation: Help for all versions. - https://help.ubuntu.com/

How To Windows Dual Boot: - https://help.ubuntu.com/community/WindowsDualBoot

How To Use The Terminal: Commandline stuff. - https://help.ubuntu.com/community/UsingTheTerminal/

[HOW TO] Beginners Guide to Android ROM Development - http://xdaforums.com/showthread.php?t=1272270 (courtesy of isidromxz)

[Tutorial] Compile JB on Ubuntu - http://xdaforums.com/showthread.php?t=1762641 (courtesy of dastin1015)

[CM10] [PPA] Cyanogenmod Compiler v0.6 - http://xdaforums.com/showthread.php?t=1789190 (courtesy of lithid-cm)

[Wiki] How to: Gerrit - http://wiki.cyanogenmod.com/wiki/Howto:_Gerrit

[Wiki] How to: Git - http://wiki.cyanogenmod.com/wiki/Howto:_Git

[Wiki] How to: Connect to device with SSH - http://wiki.cyanogenmod.com/wiki/Howto:_Connect_to_Device_with_SSH

Here is an easy-to-use page on common Linux commands: - http://www.pixelbeat.org/cmdline.html

Linux Newbie Guide : - http://www.unixguide.net/linux/linuxshortcuts.shtml

Also, Team Chopsticks has a good page with some useful tips as well, located here:

http://www.teamchopsticks.org/p/contributing.html (thanks to bdusmc for the tip)

Here is a link to LIFEHACKER's command line tutorials. Very good stuff!! : http://lifehacker.com/5743814/become-a-command-line-ninja-with-these-time+saving-shortcuts

CyanogenMod git : - https://github.com/CyanogenMod

LegacyXperia git : - https://github.com/LegacyXperia

Original Beanstalk thread : - http://xdaforums.com/showthread.php?t=2091900

Beanstalk git : - https://github.com/scotthartbti?tab=repositories

The Muppets git : - https://github.com/TheMuppets


[/FONT]
[/CENTER]
 
Last edited:

vishal_android freak

Inactive Recognized Developer / Contributor
Dec 30, 2012
1,898
5,638
Mumbai
I want you to lock this thread once you have reserved all the posts needed before anyone posts.. We can open it once all tuts are ready :)

Regards,
vishal_android freak
 

SquallATF

Member
Nov 25, 2011
32
45
Building with Linaro 4.8 toolchain


Go into Terminal and navigate to the root folder of your source tree, then:

Code:
[COLOR="Black"]prebuilts/gcc/linux-x86/arm/[/COLOR]

Run:

Code:
[COLOR="black"]wget http://releases.linaro.org/13.06/components/toolchain/gcc-linaro/4.8/gcc-linaro-4.8-2013.06.tar.bz2[/COLOR]

Run:

Code:
[COLOR="black"]bunzip2 *.tar.bz2[/COLOR]

Run:

Code:
[COLOR="black"]tar -xvf *.tar[/COLOR]

Using your file manager, navigate to the root folder of your source tree again.

Navigate To "/build", in your root folder.

Run:

Code:
[COLOR="black"]gksudo gedit envsetup.sh[/COLOR]

change the line in bold, to look exactly like this one:

Code:
[COLOR="black"]case $ARCH in
        x86) toolchaindir=x86/i686-linux-android-4.6/bin
            ;;
        [B]arm) toolchaindir=arm/gcc-linaro-4.8-2013.06[/B]  [COLOR="Red"]<--------[/COLOR]
            ;;
        mips) toolchaindir=mips/mipsel-linux-android-4.6/bin
            ;;
        *)
            echo "Can't find toolchain for unknown architecture: $ARCH"
            toolchaindir=xxxxxxxxx
            ;;
esac
[/COLOR]

Exit out and open new. Initialize and build. That's it! Makes you wonder why you never did it before, right?

Not so fast. You may have build issues, you may not. I had a few lengthy sets of errors in gsm calltracker and another .java file that was solved by using Meld and making it look exactly like a successful build's file. More as I learn.......


Thanks to infected_ for this tut; his post can be found here: [/COLOR]

http://xdaforums.com/showpost.php?p=42976693&postcount=12
Building with Linaro 4.8 toolchain doesn't work, gcc-linaro-4.8-2013.06.tar.bz2 is source file, I also tried the following file
Code:
http://releases.linaro.org/13.06/components/android/toolchain/4.8/android-toolchain-eabi-4.8-2013.06-x86.tar.bz2
and modified envsetup.sh but still doesn't work.
 
R

rebelos

Guest
Building with Linaro 4.8 toolchain doesn't work, gcc-linaro-4.8-2013.06.tar.bz2 is source file, I also tried the following file
Code:
http://releases.linaro.org/13.06/components/android/toolchain/4.8/android-toolchain-eabi-4.8-2013.06-x86.tar.bz2
and modified envsetup.sh but still doesn't work.

what error u are getting ..? and have u done everything correctly .?
 

Druboo666

Senior Member

skull47

Senior Member
Aug 28, 2012
213
161
Chennai
OnePlus 6T
AWSM...!!!

AWSM job OP.....its a dream come true thread for any n00b..was looking for something like this specifically for our SX2011 devices...will try out building roms using this guide...thank u vry much OP:good::laugh::D:highfive:
 

Antoniokodo

Senior Member
Aug 27, 2013
64
29
Good post, for first I can turn into a bit of development instead of modding\cook. I will do something after my Arc turn into EOL!

Cheers

Enviado desde mi HUAWEI Y300-0100 mediante Tapatalk
 

ronii ahmad

Senior Member
Jun 4, 2013
233
229
Malang
Building with Linaro 4.8 toolchain doesn't work, gcc-linaro-4.8-2013.06.tar.bz2 is source file, I also tried the following file
Code:
http://releases.linaro.org/13.06/components/android/toolchain/4.8/android-toolchain-eabi-4.8-2013.06-x86.tar.bz2
and modified envsetup.sh but still doesn't work.

nice tutor bro...
 
R

rebelos

Guest
Patches updated to Latest :D .. :good: updated build instructions "SlimKat" and "AORP" tutorial SOON
 

3andala

Senior Member
Mar 24, 2011
1,229
1,439
Patches updated to Latest :D .. :good: updated build instructions "SlimKat" and "AORP" tutorial SOON
i PM u bro :)
try to patch PAC
one more thing while try to use patch 2/3/4 get error
but if u applied just patch 2 its patched without error
Any help?
eslam@eslam-3andala:~/pac/system$ cd ~/pac/system/frameworks/native
eslam@eslam-3andala:~/pac/system/frameworks/native$ git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native refs/changes/57/54257/4 && git cherry-pick FETCH_HEAD
From http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native
* branch refs/changes/57/54257/4 -> FETCH_HEAD
error: could not apply 1af87c2... DisplayDevice: Backwards compatibility with old EGL
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
eslam@eslam-3andala:~/pac/system/frameworks/native$ git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native refs/changes/62/53162/5 && git cherry-pick FETCH_HEAD
From http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native
* branch refs/changes/62/53162/5 -> FETCH_HEAD
error: 'cherry-pick' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: cherry-pick failed
eslam@eslam-3andala:~/pac/system/frameworks/native$ git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native refs/changes/94/52994/3 && git cherry-pick FETCH_HEAD
From http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native
* branch refs/changes/94/52994/3 -> FETCH_HEAD
error: 'cherry-pick' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: cherry-pick failed
 
R

rebelos

Guest
i PM u bro :)
try to patch PAC
one more thing while try to use patch 2/3/4 get error
but if u applied just patch 2 its patched without error
Any help?

there are some conflicts with patches and PAC sources u need to resolve these conflicts

first apply patch when it shows error

type
Code:
git commit -a

and got to pathced files

and fined these symabols

Code:
 >>>>>> or  ======
delete it..!!

it is easy method

and in someplaces u need to see which code should be kept and which should be deleted but these lines
Code:
 >>>>>> or  ======
should be deleted ..

best of luck!
keep devloping
 

Top Liked Posts