[HOWTO][STEPBYSTEP] Build Rom From Source - Android

I put this tutorial together in an attempt to create the most complete and easy to follow guide for building a ROM from source. Including steps for adding apps to your build, changing toolchains and more... The entire guide uses a single Linux terminal window from start to finish in an attempt to keep everything as user friendly as possible. Please feel free to PM me suggestions on where changes need be made.
If you find this guide helpful please press the Thanks button on my posts and rate the thread a 5.​
Prerequisites​1. This guide is for 64-bit, 32-bit machines will not work for building newer android versions, Ubuntu 12+ based machine, I run Linux Mint 15. Follow links at end of OP for alternate directions
Windows Users: Setup Ubuntu in Virtualbox Instructions
2. You need to know the location for your device, vendor, and kernel repos. This can be found fairly easily in the forum for your phone. Also take note of your phones codename.
For example the Optimus G is the e970 and its device repo can be found here https://github.com/CyanogenMod/android_device_lge_e970
Note*All terminal commands will be in Code boxes*
Part 1 - Setting Up The Build Environment​
Install Java JDK
Code:
sudo add-apt-repository ppa:webupd8team/java
Code:
sudo apt-get update
Lollipop Roms:
Code:
sudo apt-get install oracle-java7-installer
Kit-Kat Roms:
Code:
sudo apt-get install oracle-java6-installer
Installing required packages
Ubuntu 14 based:
Code:
sudo apt-get install bison g++-multilib git gperf libxml2-utils
Ubuntu 12 based:
Code:
sudo apt-get install git 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 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Set-up ccache This Is Optional
Code:
nano ~/.bashrc
Add these two lines
export USE_CCACHE=1
export CCACHE_DIR=<path-to-your-cache-directory>
Click to expand...
Click to collapse
Save and exit by pressing ctrl+x, selecting Y then enter.
Install ADB & Fastboot This is optional, as you may already have them working. If not, they're a good thing to have.
Code:
sudo add-apt-repository ppa:nilarimogard/webupd8
Code:
sudo apt-get update
Code:
sudo apt-get install android-tools-adb android-tools-fastboot
Setup Repo
Code:
mkdir ~/bin
Code:
PATH=~/bin:$PATH
Code:
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Code:
chmod a+x ~/bin/repo
Create working directory
Code:
mkdir [I][B]working-dir[/B][/I]
(Replace working-dir with whatever you'd like to call it, ie. aokp)
Code:
cd working-dir
Part 2 - Get Source​ROM Source
Choose which custom rom you are going to build and initialize the repo for it
Code:
repo init -u [I][B]chosen-manifest[/B][/I]
(Replace chosen-manifest appropriately from the list below)
AOKP: https://github.com/AOKP/platform_manifest.git -b Branch
Cyanogenmod: https://github.com/CyanogenMod/android.git -b Branch
CarbonDev: https://github.com/CarbonDev/android.git -b Branch
Liquid Smooth: https://github.com/LiquidSmooth/android.git -b Branch
Replace Branch with appropriate branch from github repo ie cm-10.2 or jb3
If unsure which branch click the link above to locate appropriate branch
Click to expand...
Click to collapse
Device Source
Go HERE and follow instructions on obtaining your device specific repos.
Sync the repo
Code:
repo sync
This will take a while as it downloads all the required source
Part 3 - Preparing Source​Before you're ready to build your source needs to be configured to include your device. This preparation varies slightly for different custom Roms.
Go HERE and follow instructions for your ROM choice
Part 4 - Edit Source​This Is Optional​This is where you can make edits to the source before building to suit your needs.
Go HERE and follow the instructions to tweak source
Part 5 - Building ROM​
Code:
. build/envsetup.sh
Code:
lunch
Locate your device on the list and enter appropriate number
Code:
make -j[B][I]# [/I][/B]otapackage
Replace # with the number of cores in your system (Is the number of jobs that will be done at once, more cores means more jobs)
Build Errors​
This can be hard, especially if you're new to programming languages and building. Meet Google your new best friend.
Here is a basic overview to get you started, and if no more at least googling in the right direction.
Finished​When it's done you're rom will be in working-dir/out/target/product/codename/
Enjoy.
I used these sites while making this guide
http://source.android.com/source/initializing.html
http://www.webupd8.org/2012/11/oracle-sun-java-6-installer-available.html
http://www.webupd8.org/2012/08/install-adb-and-fastboot-android-tools.html

Device Source​ As stated in the prerequisites you will need a device specific Device repo, Vendor repo, and Kernel repo. You can find links to them in the threads for your devices. Also take note of your device codename ie Nexus 4 is mako, Optimus G is gee.
There are two options for adding in device specific source, local manifest and git clone.
Local manifest syncs the device repos each time a repo sync is run. This is probably the better choice if you don't make edits and rely on the repo's maintainer for changes.
Git clone is a one time download of a specific repo to the directory indicated and is not affected by repo sync. This is probably the better choice if you make edits to the device source as they won't be over written or cause conflicts when syncing.
The local path for your phone's repos be device/manufacturer/codename, vendor/manufacturer/codename, kernel/manufacturer/codename regardless of method chosen.
Git Clone
Code:
git clone [B][COLOR="DarkOrange"]repo[/COLOR][/B] -b [B][COLOR="Magenta"]branch[/COLOR][/B] [B][COLOR=Lime]destination-path[/COLOR][/B]
here is and example for the vendor repo for the E973 from TeamPlaceHolder
git clone https://github.com/TeamPlaceholder/proprietary_vendor_lge_gee -b cm-10.2 vendor/lge/gee
Click to expand...
Click to collapse
Local Manifest
Code:
mkdir .repo/local_manifests
Code:
touch .repo/local_manifests/local_manifest.xml
Code:
nano .repo/local_manifests/local_manifest.xml
Add these lines replacing path, name and revision according to the repo's you are using.
This example is for E973 using TeamPlaceHolder repos, adding all device/vendor/kernel repos.
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="gh"
fetch="git://github.com/" />
<project path="kernel/lge/gee" name="TeamPlaceholder/android_kernel_lge_gee" remote="gh" revision="cm-10.2-merge" />
<project path="device/lge/geeb" name="TeamPlaceholder/android_device_lge_geeb" remote="gh" revision="cm-10.2" />
<project path="device/lge/gee-common" name="TeamPlaceholder/android_device_lge_gee-common" remote="gh" revision="cm-10.2" />
<project path="vendor/lge/gee" name="TeamPlaceholder/proprietary_vendor_lge_gee" remote="gh" revision="cm-10.2" />
</manifest>
Click to expand...
Click to collapse

Preparing Source​ROM specific setup instructions prior to building. All source should be downloaded already.
Manufacturer and codename MUST be updated to reflect your device.
Cyanogenmod
Add this line to vendor/cm/vendorsetup.sh
cm_device-userdebug
Click to expand...
Click to collapse
device - The codename for your device. ie. mako for the Nexus 4
Code:
touch [COLOR="Purple"]path-to-device-tree[/COLOR]/cm.mk
path-to-device-tree - Example device/lge/mako for the Nexus 4
Code:
nano [COLOR="Purple"]path-to-device-tree[/COLOR]/cm.mk
Add these lines **This example is for the Nexus 4 Mako, change mako references to reflect your device**
## Specify phone tech before including full_phone
$(call inherit-product, vendor/cm/config/gsm.mk)
# Inherit some common CM stuff.
$(call inherit-product, vendor/cm/config/common_full_phone.mk)
# Enhanced NFC
$(call inherit-product, vendor/cm/config/nfc_enhanced.mk)
# Inherit device configuration
$(call inherit-product, device/lge/mako/full_mako.mk)
## Device identifier. This must come after all inclusions
PRODUCT_DEVICE := mako
PRODUCT_NAME := cm_mako
PRODUCT_BRAND := google
PRODUCT_MODEL := Nexus 4
PRODUCT_MANUFACTURER := LGE
# Enable Torch
PRODUCT_PACKAGES += Torch
Click to expand...
Click to collapse
Save and exit by pressing ctrl+x, selecting Y then enter.
Now you're ready to build! Go back to the OP and complete the guide from where you left off.
AOSP
AOSP requires a prebuilt kernel for your device. HERE is a guide for building a kernel if you do not have a prebuilt kernel for your device
The rest coming soon...
Liquid Smooth
Coming soon...
AOKP
Code:
nano vendor/aokp/vendorsetup.sh
Add this line
add_lunch_combo aokp_geeb-userdebug
Click to expand...
Click to collapse
Save and exit by pressing ctrl+x, selecting Y then enter.
Code:
touch vendor/aokp/products/geeb.mk
Code:
nano vendor/aokp/products/geeb.mk
Add these lines
If building for CDMA network change gsm.mk to cdma.mk
# Inherit AOSP device configuration for geeb
$(call inherit-product, device/lge/geeb/full_geeb.mk)
# Inherit AOKP common bits
$(call inherit-product, vendor/aokp/configs/common.mk)
# Inherit GSM common stuff
$(call inherit-product, vendor/aokp/configs/gsm.mk)
# Setup device specific product configuration
PRODUCT_NAME := aokp_geeb
PRODUCT_BRAND := google
PRODUCT_DEVICE := geeb
PRODUCT_MODEL := Optimus G
PRODUCT_MANUFACTURER := LGE
Click to expand...
Click to collapse
Save and exit by pressing ctrl+x, selecting Y then enter.
Code:
nano vendor/aokp/products/AndroidProducts.mk
Add this line
$(LOCAL_DIR)/geeb.mk \
Click to expand...
Click to collapse
Save and exit by pressing ctrl+x, selecting Y then enter.
Now you're ready to build! Go back to the OP and complete the guide from where you left off.
CarbonDev
Coming soon...
Now you're ready to build! Go back to the OP and complete the guide from where you left off.

Edit Source​
If you plan to edit the device/kernel repos for your phone you should either have used git clone to obtain your repos, or created forks of the repos to your own Github account to use in your local manifest. This way you can still do a repo sync to update the source without overwriting your changes or creating conflicts.
That being said these are the items disscused so far:
Adding Prebuilt APK's to Build
Adding Apps Via Source Code
Changing Toolchain
Cherry Picking Commits
Fixing Conflicts From Cherry Picks
Syncing Repo with Upstream Repo
Syncing Your Local Changes to Your Github Repo
Click to expand...
Click to collapse
Adding Prebuilt APK's to Build
Open the device folder for your phone. ie device/lge/geeb
Add these lines to android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := Name
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := .apk
LOCAL_MODULE_CLASS := APPS
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
Click to expand...
Click to collapse
Name - Any name you want to asign to this apk to call for it in the build process
**NOTE** LOCAL_SRC_FILES is the location of the apk file. Above assumes it is in the root of your device folder**
Then edit your device.mk to call for your newly assigned apk
PRODUCT_PACKAGES += \
name
Click to expand...
Click to collapse
If the apk you want to add requires additional files to be added along with it, also add this
PRODUCT_COPY_FILES += \
Path-to-additional-file:Destination-path-in-finished-build
Click to expand...
Click to collapse
Path-to-additional-file - Where the file is located in your device tree that you need to add to your build
Destination-path-in-finished-build - Where in the final rom structure this file needs to be
Here is an example for adding required libs for Terminal Emulator to the geeb device tree:
PRODUCT_COPY_FILES += \
device/lge/geeb/libjackpal-androidterm3.so:system/lib/libjackpal-androidterm3.so \
device/lge/geeb/libjackpal-androidterm4.so:system/lib/libjackpal-androidterm4.so
Click to expand...
Click to collapse
Adding Apps Via Source Code
Adding apps to your build using source code is easier then adding prebuilt apks.
Example given is using Gallery2(I realize this is included with builds by default, just using it as an example)
Copy or clone your app's source code to working-dir/packages/apps in its own folder. ie. aokp/packages/Gallery2
Go into the source code folder for your app and open Android.mk
Look for this line LOCAL_PACKAGE_NAME , This will tell you what the call name for your app is
LOCAL_AAPT_FLAGS := --auto-add-overlay
LOCAL_PACKAGE_NAME := Gallery2
LOCAL_OVERRIDES_PACKAGES := Gallery Gallery3D GalleryNew3D
Click to expand...
Click to collapse
Then open device.mk from your phones device tree and add the call name for the app.
Add these lines:
PRODUCT_PACKAGES += \
Gallery2
Click to expand...
Click to collapse
Changing Toolchain
Download a new prebuilt toolchain that you wish to use
Example: Linaro 4.7 toolchain
Copy unziped prebuilt toolchain folder to working-folder/prebuilt/gcc/linux-x86/arm
Open build/envsetup.sh
Find this block of code:
# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
export ANDROID_EABI_TOOLCHAIN=
local ARCH=$(get_build_var TARGET_ARCH)
case $ARCH in
x86) toolchaindir=x86/i686-linux-android-$targetgccversion/bin
;;
arm) toolchaindir=arm/android-toolchain-eabi/bin
;;
mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin
;;
*)
echo "Can't find toolchain for unknown architecture: $ARCH"
toolchaindir=xxxxxxxxx
;;
esac
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
fi
unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
case $ARCH in
arm)
toolchaindir=arm/android-toolchain-eabi/bin
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
fi
Click to expand...
Click to collapse
Replace bold text with your toolchain folder name
The following group of instructions are for making edits to your own repo. Before using any of the info below PLEASE create your own GitHub account and Fork the repo you'd like to edit. Then clone YOUR forked repo from YOUR github account and make edits to it.
If that didn't make sence then you may want to refrain from using this for the time being.
Cherry Picking Commits
Move to the directory for the git repo you wish to add the commit to. ie kernel/lge/geeb
Code:
cd path-to-git-repo
Add the remote repo that holds the commit - This only needs to be done the first time
Code:
git remote add [COLOR="Red"]name[/COLOR] [COLOR="SeaGreen"]url[/COLOR]
name - a name you choose to identify that remote repo
url - the location of the repo ie. https://github.com/TeamPlaceholder/android_kernel_lge_gee.git
Fetch the repo
Code:
git fetch [COLOR="Red"]name[/COLOR]
Cherry pick commit
Code:
git cherry-pick [COLOR="DarkOrange"]commit-id[/COLOR]
commit-id - An unique id given to every commit. It's a long alphanumeric id shown on the commit page of your repo. ie. cc3581ff8692b517ddda8baad73a5d110568f0da
Fixing Conflicts From Cherry Picks
Somtimes when you cherry pick a commit to your repo you'll have a conflict. This is just saying that it did not see what it expected to see when adding the commit to a certain file. To fix a conflict and commit the cherry pick do as follows:
Determine which file(s) contain conflicts.
Code:
git status
This will show you edits waiting to be commited from the cherry-pick. The files shown in green accepted the changes without conflict, the files listed in red contain conflicts that need to be addressed.
Open the file in red
Code:
gedit [COLOR="DarkOrange"]Path-To-File-In-Red[/COLOR]
Press crtl+f to bring up a find window and search for head. Conflicts will be shown in the file using the following structure
<<<<<Head
<Original Code>
=======
<Code from Cherry-pick>
>>>>>Name Of Cherry Pick Commit
Click to expand...
Click to collapse
Compare the original code to the code from the cherry pick and see if anything needs to be saved. If so, merge what needs to be saved into the code from the cherry pick. Then delete the original code and the <<<< ===== >>>>> lines(everything shown in red above). In the end you should be left only with the code from the cherry pick, plus anything you may have merged to it.
Search again for 'head' to see if there are any further conflicts within that file. If there is use the same method to resolve them, if there is not save and exit the file.
Add the newly edited file to the pending commit
Code:
git add [COLOR="DarkOrange"]Path-To-File-In-Red[/COLOR]
Check for any more files that need to be addressed
Code:
git status
If you still have files in red, repeat the process above for those files.
Once all files from git status are shown in green you are ready to commit the cherry pick.
Code:
git commit
Save and exit the commit log by pressing ctrl+x
Done. That cherry pick is now commited to your repo, you can move on to the next cherry pick you wish to add.
Sync Forked Repo with Upstream(Parent) Repo
If you would like to commit to your forked repo all the commits made upstream since you forked(or previously sync'd)
Add the upstream repo - This only needs to be done the first time
Code:
git remote add [COLOR="Red"]name[/COLOR] [COLOR="SeaGreen"]url[/COLOR]
name - a name you choose to identify that remote repo
url - the location of the repo ie. https://github.com/TeamPlaceholder/android_kernel_lge_gee.git
Fetch the upstream repo
Code:
git fetch [COLOR="Red"]name[/COLOR]
Merge upstream commits
Code:
git merge [COLOR="Red"]name[/COLOR]/[COLOR="DarkOrange"]branch[/COLOR]
branch - The branch from the upstream repo you are syncing up
Syncing Your Local Changes to Your Github Repo
Check to ensure you have everything in order to push your changes
Code:
git status
If there are no conflicts/changes that need to be commited you are ready to push. If everything is good it will simply state your are x number of commits ahead
Push your commits to your GitHub account
Code:
git push
Enter your github user name then password. All your local commits will then be applied to your github repo.
More to Come...

Build Errors
Build Errors​
This is way to broad a subject to cover in a post, but here are some steps to take to help get you building again.
When your build output stops without clearly saying it's finished or directing you to the created zip file, it Failed.
Sometimes it will stop with the error right at the end of the output, but not very often. Most of the time you must look up through the build output in order to locate the actual error. Sometimes they can be buried very far up, depending on the number of jobs being built.
Here is an example of what you are looking for:
hardware/qcom/display-caf/libgralloc/framebuffer.cpp:116:39: error: 'MSMFB_DISPLAY_COMMIT' was not declared in this scope
Click to expand...
Click to collapse
File having the error
Line in the file where the error occurs
Error that has occured
The quickest way to locate the errors in the build output is the search 'ctrl+shfit+F' for ': error:'
Once you have located your error(s), you can begin troubleshooting to get past them. Start by opening the File having the error and going to the Line in the file where the error occurs. Though without programing knowledge you may not make much sense of it, it's always good to start familiarizing yourself with the code. If you're not able to correct the issue this is where google will come in very handy.
Quite often if you search simply for the Error that has occured exactly as it appears, you'll find its an error that has been encountered many times over and solutions are availible within the first couple of results in a google search.
Should all else fail Post a question and see what suggestions come up.
Here are a few common build errors that I have come across and some solutions for them, again this is by no means a one stop for build erros. Google...Google...Then try to post your error and see who can help if your still stuck. The more you fix by yourself the more it feels like YOUR build.
make: *** No rule to make target `Example_File'. Stop.
Click to expand...
Click to collapse
It can't find the file in question. This can be a incorrect path in a makefile, a missing file or a typo.

last one

Finally usefull guide! not only theory. Thank you very much!

Nice job. Just one thing: when using our sources, the cm-10.2-merge is the best kernel branch. Msm-3.10 is our bleeding edge and hopefully will be fully working soon (just got it to build today, so we'll see). The update branch is broken though. Let me know if you want to contribute to our Git so I can add you to the team, or if you have any suggestions on how to make our rom and kernel better.
Sent from my LG-LS970 using xda app-developers app

xboxfanj said:
Nice job. Just one thing: when using our sources, the cm-10.2-merge is the best kernel branch. Msm-3.10 is our bleeding edge and hopefully will be fully working soon (just got it to build today, so we'll see). The update branch is broken though. Let me know if you want to contribute to our Git so I can add you to the team, or if you have any suggestions on how to make our rom and kernel better.
Sent from my LG-LS970 using xda app-developers app
Click to expand...
Click to collapse
Thanks for the info, updated quide to reflect.

i have a cherry mobile burst phone its running ics,i a generic phone a clone i dont know where it came from i mean the build i cant find a source or a build repo , i really want to build a rom for my phone cause it seems ics is not compatible for the phone..it only has 512 ram and 1ghz dualcore processor..it could run smoothly i think with gingerbread but i cant find a tutorial to donwgrade it to gingerbread it seems impossible because of lack of support for the device and it came up with ics..i just dont know what to do any more my computer is linux mint 13 2gb ram 1ghz amd anthlon 2 ,70gb hd..i cant build a rom to this computer..

Changing Toolchain
Download a new prebuilt toolchain that you wish to use
Example: Linaro 4.7 toolchain
Copy unziped prebuilt toolchain folder to working-folder/prebuilt/gcc/linux-x86/arm
Open build/envsetup.sh
Find this block of code:
Quote:
# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
export ANDROID_EABI_TOOLCHAIN=
local ARCH=$(get_build_var TARGET_ARCH)
case $ARCH in
x86) toolchaindir=x86/i686-linux-android-$targetgccversion/bin
;;
arm) toolchaindir=arm/android-toolchain-eabi/bin
;;
mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin
;;
*)
echo "Can't find toolchain for unknown architecture: $ARCH"
toolchaindir=xxxxxxxxx
;;
esac
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
fi
unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
case $ARCH in
arm)
toolchaindir=arm/android-toolchain-eabi/bin
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
fi
Replace bold text with your toolchain folder name
Click to expand...
Click to collapse
Click to expand...
Click to collapse
I did what you said and i keep getting this error
"/arm-eabi-gcc: No such file or directory
make[4]: *** [scripts/mod/empty.o] Error 1
make[3]: *** [scripts/mod] Error 2
make[2]: *** [scripts] Error 2
make[2]: *** Waiting for unfinished jobs...."
Here's what my envsetup.sh looks like
# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
export ANDROID_EABI_TOOLCHAIN=
local ARCH=$(get_build_var TARGET_ARCH)
case $ARCH in
x86) toolchaindir=x86/i686-linux-android-$targetgccversion/bin
;;
arm) toolchaindir=arm/arm-eabi-linaro-4.6.2/bin
;;
mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin
;;
*)
echo "Can't find toolchain for unknown architecture: $ARCH"
toolchaindir=xxxxxxxxx
;;
esac
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
fi
unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
case $ARCH in
arm)
toolchaindir=arm/arm-eabi-linaro-4.6.2/bin
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
fi
Click to expand...
Click to collapse
my linaro folder is called "arm-eabi-linaro-4.6.2" and it is placed under "/prebuilts/gcc/linux-x86/arm/arm-eabi-linaro-4.6.2"
what am i doing wrong?
thanks!

ryukiri said:
I did what you said and i keep getting this error
"/arm-eabi-gcc: No such file or directory
make[4]: *** [scripts/mod/empty.o] Error 1
make[3]: *** [scripts/mod] Error 2
make[2]: *** [scripts] Error 2
make[2]: *** Waiting for unfinished jobs...."
Click to expand...
Click to collapse
Where did you get your linaro toolchain from?
go into your linaro directory/bin do you see arm-eabi**** files?
Sounds like it's only the arm-linux-androideabi*** files in there.
Get the prebuilt toolchains right from Linaro It will take a little looking around to find the 4.6. The prebuilt toolchains for each release are in Components>Android>Toolchain Most of them are 4.7 and 4.8 so like I said, it may take some looking around.
I believe(though not 100%) the arm-eabi are used for the kernel, the arm-linux-androideabi for the rom.
The top line you change in envsetup.sh is for the rom toolchain, second place you change is for the kernel toolchain. You can use two different toolchains here. I use sabermod 4.9 for my rom and linaro 4.7 for the kernel

Haze028 said:
Where did you get your linaro toolchain from?
go into your linaro directory/bin do you see arm-eabi**** files?
Sounds like it's only the arm-linux-androideabi*** files in there.
Get the prebuilt toolchains right from Linaro It will take a little looking around to find the 4.6. The prebuilt toolchains for each release are in Components>Android>Toolchain Most of them are 4.7 and 4.8 so like I said, it may take some looking around.
I believe(though not 100%) the arm-eabi are used for the kernel, the arm-linux-androideabi for the rom.
The top line you change in envsetup.sh is for the rom toolchain, second place you change is for the kernel toolchain. You can use two different toolchains here. I use sabermod 4.9 for my rom and linaro 4.7 for the kernel
Click to expand...
Click to collapse
hmm, i forgot where i got it from, i might have gotten it by following this http://forum.xda-developers.com/showthread.php?t=1988315
Can I use 4.7 or 4.8 though?
Ok so inside my linaro directory/bin, i see many arm-eabi**** files (attached screenshot)
Do you think you can link to me the exact toolchains you used so I can start with something that works and then start trying different ones later?

ryukiri said:
Can I use 4.7 or 4.8 though?
Do you think you can link to me the exact toolchains you used so I can start with something that works and then start trying different ones later?
Click to expand...
Click to collapse
I would stick with 4.7 toolchain. 4.6 is quite old, and 4.8 doesn't seem to play very nice. (i'm probably too noob to get it working)
This is the linaro 4.7 toolchain I use.
Hopefully that'll help ya get going.

Haze028 said:
I would stick with 4.7 toolchain. 4.6 is quite old, and 4.8 doesn't seem to play very nice. (i'm probably too noob to get it working)
This is the linaro 4.7 toolchain I use.
Hopefully that'll help ya get going.
Click to expand...
Click to collapse
alright thanks. Ill test it out and report back later

I got the same error.. D:
"/arm-eabi-gcc: No such file or directory
make[4]: *** [scripts/mod/empty.o] Error 1
make[3]: *** [scripts/mod] Error 2
make[2]: *** [scripts] Error 2
make[2]: *** Waiting for unfinished jobs...."
# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
export ANDROID_EABI_TOOLCHAIN=
local ARCH=$(get_build_var TARGET_ARCH)
case $ARCH in
x86) toolchaindir=x86/i686-linux-android-$targetgccversion/bin
;;
arm) toolchaindir=arm/android-toolchain-eabi/bin
;;
mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin
;;
*)
echo "Can't find toolchain for unknown architecture: $ARCH"
toolchaindir=xxxxxxxxx
;;
esac
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
fi
unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
case $ARCH in
arm)
toolchaindir=arm/android-toolchain-eabi/bin
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
fi
Click to expand...
Click to collapse
EDIT: after some research, i found out that all the files in my bin folder are 32 bit executable files. So i believe i need a 64 bit toolchain. Do you know where I could find one?
EDIT2: I found that for linux they need to install "ia32-libs" to run 32bit executables source. But the thing is, I'm using a mac...
EDIT3: nevermind, i got it to work. thanks anyway

aokp build error
Can you point me in the right direction to fix this error http://pastebin.com/GZmteWUu.

Recon Freak said:
Can you point me in the right direction to fix this error http://pastebin.com/GZmteWUu.
Click to expand...
Click to collapse
http://forum.xda-developers.com/showpost.php?p=47947423&postcount=175
Try this....

CarbonDev
Coming soon...
.
Click to expand...
Click to collapse
Thanks for the guide so far. Is there an eta for Carbon roms as I'm struggling to get my to build. Or AOSP?

Haze, to change tool chains, you can also set TARGET_TOOLS_PREFIX ?= prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8-linaro/bin/arm-linux-androideabi- in boardconfig (sub in the right path obviously).
Sent from my Optimus G using xda app-developers app

Related

Guide on how I build my own CM9 test builts

A follow up on this - http://forum.xda-developers.com/showpost.php?p=28177937&postcount=1768 - in the CM9 FXP thread, have I promised to make a little guide.
Guide how I build CM9 for my Mango.
For the first time you try to build CM9.
Create ~/bin and download repo to that directory. Afterwards set executable bit to make it possible to ”execute”.
Code:
mkdir -p ~/bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now reboot the computer.
Create ~/android/system amd initialize the repository.
Code:
mkdir -p ~/android/system
cd ~/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync
Setup the environmental settings and initialize the Mango build.
Code:
. build/envsetup.sh
brunch mango
Setup the environmental settings and initialize the Mango build.
Code:
git clone git://github.com/TheMuppets/proprietary_vendor_semc.git -b ics ~/android/system/vendor/semc
cd ~/android/system/device/semc/mango/
./setup-makefiles.sh
Download the prebuilts
Code:
~/android/system/vendor/cm/get-prebuilts
Check for new changes
Code:
cd ~/android/system/
repo sync
Setup the environment again and build the ROM (takes long time)
Code:
. build/envsetup.sh
brunch mango
You will now find the build here (change DATE into the date).
~/android/system/out/target/product/mango/cm-9-DATE-UNOFFICIAL-mango.zip
The next times you try to build it, you only need to do the following.
Delete build.prop, if not will build.prop not get generated.
Code:
rm -f ~/android/system/out/target/product/mango/system/build.prop
Syncronise the git repositories.
Code:
cd ~/android/system/
repo sync
Setup the environmental settings.
Code:
. build/envsetup.sh
Configure/build.
Code:
brunch mango
You will now find the build here (change DATE into the date).
~/android/system/out/target/product/mango/cm-9-DATE-UNOFFICIAL-mango.zip
If you are trying to build it on a 32bit system, you should change line 374 in ~/android/system/device/semc/msm7x30-common/releasetools/common.py
from:
Code:
cmd = ["java", "-Xmx2048m", "-jar",
to:
Code:
cmd = ["java", "-Xmx1024m", "-jar",
If you get into any trouble, please let me know, I may have missed something.
EDIT (July 2. 2012): I have made a patch to msm7x30-common, so you do not need to edit the file (with this patch does it automatically check if you run on a 64bit or a 32bit system):
http://code.google.com/p/freexperia/issues/detail?id=527
EDIT (July 6. 2012): If there has been an update on git://github.com/koush/proprietary_vendor_semc.git (like there has been today), shall you do the following (pull the updates):
Code:
cd ~/android/system/vendor/semc
git pull
EDIT (July 8. 2012): Adding the following, just before "</manifest>" in ".repo/local_manifest.xml" and the proprietary files will also get updated, when you make a normal "repo sync". Got this idea after talking to Andreas (so thank you Andreas).
Code:
<project name="TheMuppets/proprietary_vendor_semc" path="vendor/semc" remote="github" revision="ics" />
EDIT (July 11. 2012): Changed the proprietary repository from git://github.com/koush/proprietary_vendor_semc.git to git://github.com/TheMuppets/proprietary_vendor_semc.git
allright, i have already synched the cm9 repo. about 5.8 gbs
can you tell me what folders does it include?
edit:took me a few days to download, just don't want to download again
gandhar said:
allright, i have already synched the cm9 repo. about 5.8 gbs
can you tell me what folders does it include?
Click to expand...
Click to collapse
Are you thinking of the "clean" repo?
My ~/android/system/ consists of the following (remember the hidden directories):
abi
android
bionic
bootable
build
dalvik
development
device
external
frameworks
hardware
kernel
libcore
ndk
out
packages
prebuilt
sdk
system
vendor
.repo
.repoconfig
Makefile
You should be able to move your current directory and "just" sync it, to get it up to date.
hnl_dk said:
Are you thinking of the "clean" repo?
My ~/android/system/ consists of the following (remember the hidden directories):
abi
android
bionic
bootable
build
dalvik
development
device
external
frameworks
hardware
kernel
libcore
ndk
out
packages
prebuilt
sdk
system
vendor
.repo
.repoconfig
Makefile
Click to expand...
Click to collapse
allright, out of these except for kernel, out and .repoconfig i have all the others synced.
will using
Code:
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync
work?
i am missing kernel, out and .repoconfig
gandhar said:
allright, out of these except for kernel, out and .repoconfig i have all the others synced.
will using
Code:
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync
work?
i am missing kernel, out and .repoconfig
Click to expand...
Click to collapse
They are possibly first created when running brunch the first time. So it should be fine.
successfully building, but getting loads of warnings..
is that normal for the first build?
will report if it boots after compile is over.
gandhar said:
successfully building, but getting loads of warnings..
is that normal for the first build?
will report if it boots after compile is over.
Click to expand...
Click to collapse
There are lots of warnings.
Personally I usually remove all that warnings (using the -Werror option, so warnings get treated as errors) in the projects I am working on. But I understand why it can be a big problem with CM9, that is based on many different projects.
Looking forward to hear if you get a successful built.
hnl_dk said:
There are lots of warnings.
Personally I usually remove all that warnings (using the -Werror option, so warnings get treated as errors) in the projects I am working on. But I understand why it can be a big problem with CM9, that is based on many different projects.
Looking forward to hear if you get a successful built.
Click to expand...
Click to collapse
building will take some time...
well, most warnings are 'some variable has been set but not used', is that much significant?
gandhar said:
building will take some time...
well, most warnings are 'some variable has been set but not used', is that much significant?
Click to expand...
Click to collapse
Yes, first build takes a lot of time... the next times it will be a lot faster.
No that is not very significant, but things like that should still get fixed, to to make it easier to find the significant things.
The less warnings the more easy it is to spot what is important. This also goes for things that should get changed when upgrading to a new major version of the toolchain.
succesfull build!
phone:coconut-wt19i
time: 56 mins for the complete build.
cpu: 2.9 ghz - 4 cores
os:ubuntu 12.04 64 bit
backed up the phone.
boots into recovery
errorless install.
gandhar said:
phone:coconut-wt19i
time: 56 mins for the complete build.
cpu: 2.9 ghz - 4 cores
os:ubuntu 12.04 64 bit
backed up the phone.
boots into recovery
errorless install.
Click to expand...
Click to collapse
Super, looking forward to hear if everything is going to run as as should
hnl_dk said:
Super, looking forward to hear if everything is going to run as as should
Click to expand...
Click to collapse
running fine.
but i see some dependencies missing from the libs needed from
http://wiki.cyanogenmod.com/wiki/Template:Build_from_source_(CM9)
downloading them, will build again later..
is that the reason for the warnings?
gandhar said:
running fine.
but i see some dependencies missing from the libs needed from
http://wiki.cyanogenmod.com/wiki/Template:Build_from_source_(CM9)
downloading them, will build again later..
is that the reason for the warnings?
Click to expand...
Click to collapse
looks like a nice guide that is working with most devices, will save that link
No, the warnings are simply that you rarely find "clean" code, where most warnings have been fixed.
You also need to think of all the code from external projects.
You also only get many of the warnings, if you do not compile the code for some specific platforms.
hnl_dk said:
looks like a nice guide that is working with most devices, will save that link
No, the warnings are simply that you rarely find "clean" code, where most warnings have been fixed.
You also need to think of all the code from external projects.
You also only get many of the warnings, if you do not compile the code for some specific platforms.
Click to expand...
Click to collapse
saw that guide after i started checking for dependencies.
1.hey i see two zips in the output,
one cm-9-20120702-UNOFFICIAL-coconut and other cm_coconut-ota-eng.gandhar
the second is bigger.
i used the first one. why is the second one built i wonder?
2.i think of compiling aosp from source too, but the out folder is 11.3 gbs, what about that?
i do not want to end up falling short on space.
3.this is a system related question, how much will it hinder performance if i move the source to a different internal hd from the main one and build from there?
gandhar said:
saw that guide after i started checking for dependencies.
1.hey i see two zips in the output,
one cm-9-20120702-UNOFFICIAL-coconut and other cm_coconut-ota-eng.gandhar
the second is bigger.
i used the first one. why is the second one built i wonder?
Click to expand...
Click to collapse
Try to read the name ;-)
OTA - Over The Air... I guess that it can mbe used tfor OTA updates, like the mobile companies makes.
gandhar said:
2.i think of compiling aosp from source too, but the out folder is 11.3 gbs, what about that?
i do not want to end up falling short on space.
Click to expand...
Click to collapse
You could do a "make clear", but if you have enough space, would I keep it, so you do not need to wait for the already up to date files.
gandhar said:
3.this is a system related question, how much will it hinder performance if i move the source to a different internal hd from the main one and build from there?
Click to expand...
Click to collapse
There will be no problem with performance, as long as you move it to a HDD that is not too slow.
EDIT (July 2. 2012): I have made a patch to msm7x30-common, so you do not need to edit the file (with this patch does it automatically check if you run on a 64bit or a 32bit system):
http://code.google.com/p/freexperia/issues/detail?id=527
i do a repo sync again, at end of it i get errors on changed files. i think its not replacing the old files.
it's red text
error: bootable/recovery/: CyanogenMod/android_bootable_recovery checkout f8fc12e741d566af215407f35cfc52e5c1cc0023
error: build/: CyanogenMod/android_build checkout df7d6893a59e62c15dd20e306d8280b16969097c
error: external/openssl/: CyanogenMod/android_external_openssl checkout d4004ae717232b83ea445f74c881d9ddc24f589d
error: frameworks/base/: CyanogenMod/android_frameworks_base checkout e0a8c35c1572f0f0dbbda4d871d0a919a79cbe3f
error: hardware/samsung/: CyanogenMod/android_hardware_samsung checkout 23280fc439163a1971956167217283c4ae70bce3
error: packages/apps/Camera/: CyanogenMod/android_packages_apps_Camera checkout 644384a979ec9bd6b237e9031d5afbf592d3056b
error: packages/apps/Settings/: CyanogenMod/android_packages_apps_Settings checkout a946d9a905d460fa9d6c153e031285b566f8d223
error: system/core/: CyanogenMod/android_system_core checkout 389a2fa1d7e4bb8b6be411f272de2e8c92817964
gandhar said:
i do a repo sync again, at end of it i get errors on changed files. i think its not replacing the old files.
it's red text
error: bootable/recovery/: CyanogenMod/android_bootable_recovery checkout f8fc12e741d566af215407f35cfc52e5c1cc0023
error: build/: CyanogenMod/android_build checkout df7d6893a59e62c15dd20e306d8280b16969097c
error: external/openssl/: CyanogenMod/android_external_openssl checkout d4004ae717232b83ea445f74c881d9ddc24f589d
error: frameworks/base/: CyanogenMod/android_frameworks_base checkout e0a8c35c1572f0f0dbbda4d871d0a919a79cbe3f
error: hardware/samsung/: CyanogenMod/android_hardware_samsung checkout 23280fc439163a1971956167217283c4ae70bce3
error: packages/apps/Camera/: CyanogenMod/android_packages_apps_Camera checkout 644384a979ec9bd6b237e9031d5afbf592d3056b
error: packages/apps/Settings/: CyanogenMod/android_packages_apps_Settings checkout a946d9a905d460fa9d6c153e031285b566f8d223
error: system/core/: CyanogenMod/android_system_core checkout 389a2fa1d7e4bb8b6be411f272de2e8c92817964
Click to expand...
Click to collapse
Have not tried that.
You can try to do a "repo forall -c git reset --hard" this "resets" all the repositories (removes all changes, also if something has been corrupted).
hnl_dk said:
Have not tried that.
You can try to do a "repo forall -c git reset --hard" this "resets" all the repositories.
Click to expand...
Click to collapse
will it redownload?

[GUIDE][DEV][DISCONTINUED] How I build my own CM10.1 test builds

This is still unofficial. This thread is intended for devs & advanced users only.
Guide how I build CM10.1 for my smultron.
For the first time you try to build CM10.1
Follow this guide up to "Initialize the CyanogenMod source repository" step (don't execute this step).
http://wiki.cyanogenmod.org/w/Build_for_smultron
Download & install lzop compression tool
Code:
sudo apt-get install lzop
Initialize the CyanogenMod source repository
Enter the following to initialize the repository:
Code:
cd ~/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1
Get the required local manifest
Code:
mkdir -p ~/android/system/.repo/local_manifests
curl https://raw.github.com/LegacyXperia/local_manifests/cm-10.1/semc.xml > ~/android/system/.repo/local_manifests/semc.xml
Download the source code
Code:
repo sync
Download some commits from CyanogenMod gerrit which are not accepted yet
Code:
curl https://raw.github.com/LegacyXperia/local_manifests/cm-10.1/updates.sh > ~/android/system/updates.sh
chmod a+x updates.sh
./updates.sh
Get the prebuilts
Code:
cd ~/android/system/vendor/cm
./get-prebuilts
Setup the environment & prepare the device-specific code.
Code:
cd ~/android/system
. build/envsetup.sh
breakfast smultron
Build the ROM (takes long time)
Code:
brunch smultron
If the build finishes successfully, you will find the build here (change DATE into the date):
~/android/system/out/target/product/smultron/cm-10.1-DATE-UNOFFICIAL-smultron.zip
The next times you want to build, you only need to do the following:
Sync the repositories & make sure you are using the latest local_manifest.
Code:
cd ~/android/system/
curl https://raw.github.com/LegacyXperia/local_manifests/cm-10.1/semc.xml > ~/android/system/.repo/local_manifests/semc.xml
repo sync
Download some commits from CyanogenMod gerrit which are not accepted yet
Code:
curl https://raw.github.com/LegacyXperia/local_manifests/cm-10.1/updates.sh > ~/android/system/updates.sh
chmod a+x updates.sh
./updates.sh
Setup the environment
Code:
. build/envsetup.sh
Build the ROM
Code:
brunch smultron
If the build finishes successfully, you will find the build here (change DATE into the date):
~/android/system/out/target/product/smultron/cm-10.1-DATE-UNOFFICIAL-smultron.zip
Steps to build only the kernel:
Sync the repositories.
Code:
cd ~/android/system/
repo sync
Setup the environment
Code:
. build/envsetup.sh
Build the kernel
Code:
breakfast smultron
make -j4 bootimage
If the build finishes successfully, you will find the boot image here:
~/android/system/out/target/product/smultron/boot.img
Credits: Thanks to hnl_dk for the initial CM9 & CM10 guides.
Build is successful using this guide now. You can build for all xperia 2011 phones by replacing "smultron" with your device's name in the guide.
More info can be found here: https://github.com/LegacyXperia/local_manifests/wiki
Re: [GUIDE][WIP] How I build my own CM10.1 test builds
Wew good guide! :thumbup: hope can get the stable version of the CM10.1with this guide here
Sent from my SK17i using xda premium
After 'repo init' there should be a
Code:
mkdir -p ~/android/system/.repo/local_manifests
Script to apply not yet merged changes:
Code:
#!/bin/sh
android=~/android/system
#http://review.cyanogenmod.org/#/c/32906/
cd ${android}/frameworks/av/
git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_av refs/changes/06/32906/2 && git format-patch -1 --stdout FETCH_HEAD | patch -p1
#http://review.cyanogenmod.org/#/c/28336/
cd ${android}/packages/apps/LegacyCamera/
git fetch http://review.cyanogenmod.org/CyanogenMod/android_packages_apps_LegacyCamera refs/changes/36/28336/1 && git format-patch -1 --stdout FETCH_HEAD | patch -p1
#http://review.cyanogenmod.org/#/c/34989/
cd ${android}/hardware/qcom/audio-caf
git fetch http://review.cyanogenmod.org/CyanogenMod/android_hardware_qcom_audio-caf refs/changes/89/34989/5 && git format-patch -1 --stdout FETCH_HEAD | patch -p1
From http://forum.xda-developers.com/showthread.php?t=1358547
Code:
repo sync -f
May fix error: Exited sync due to fetch errors
hi,
I want to build CM 10.1 for my mango, guide is perfectly explain, just one question :
does i need to add the script part explain by M66B two post above or it's outdated and i just need to follow the first post ?
Thanks
Edit : sorry for the noob question, i have read the reviews and have my answer
kosmo666 said:
hi,
I want to build CM 10.1 for my mango, guide is perfectly explain, just one question :
does i need to add the script part explain by M66B two post above or it's outdated and i just need to follow the first post ?
Thanks
Edit : sorry for the noob question, i have read the reviews and have my answer
Click to expand...
Click to collapse
The scrip parts from above are outdated, we maintain this script now.
How to merge in this nAa 3.4.45 kernel sources? Is it connected with kernel sources?
mastero9017 said:
How to merge in this nAa 3.4.45 kernel sources? Is it connected with kernel sources?
Click to expand...
Click to collapse
If you look at Mike's github (https://github.com/LegacyXperia)
you'll see that he maintains his own branch of the nAa kernel (https://github.com/LegacyXperia/msm7x30-3.4.x-nAa).
They are not the same, but similar (Mike currently has more changes, since nAa hasn't updated anything for two weeks).
-> If you build Mike's sources, you'll also get a 3.4.45 kernel.
What am I doing wrong? Did everything, checked all libs 10 times..
EDIT: It's a KDE error,aghhr. Delete/clean /root/.config directory fixes it
Code:
[email protected]:~/android/system# brunch haida
including vendor/cm/vendorsetup.sh
Trying dependencies-only mode on a non-existing device tree?
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.2
CM_VERSION=10.1-20130603-UNOFFICIAL-haida
TARGET_PRODUCT=cm_haida
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.2.0-41-generic-x86_64-with-Ubuntu-12.04-precise
HOST_BUILD_TYPE=release
BUILD_ID=JDQ39E
OUT_DIR=/root/android/system/out
============================================
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.2
CM_VERSION=10.1-20130603-UNOFFICIAL-haida
TARGET_PRODUCT=cm_haida
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.2.0-41-generic-x86_64-with-Ubuntu-12.04-precise
HOST_BUILD_TYPE=release
BUILD_ID=JDQ39E
OUT_DIR=/root/android/system/out
============================================
make: *** /.config: is a directory. Stop.
Guys,
For your info Windows Host NTFS file system is case insensitive and will break android compilation!!!
Workaround: Create a new virtual hdd with ext3 format and mount it to your ubuntu guest! Sad that ntfs cannot be used.
So, below is for your info if u came across this post. It is useful for sharing folders between Linux guest and Windows host.
IF you are using Virtualbox on a Win7/8 host system,
To use Shared Folder feature and add automount (note, VirtualBox needs to be run as Administrator so that os.symlink works!!!!
In Windows:
1. Go to your VirtualMachine Folder and look for MyVM.vbox,
2. Open with notepad++
3. Look for <ExtraData>
4. Add this inside the <ExtraData></ExtraData>
Code:
<ExtraDataItem name="VBoxInternal2/SharedFoldersEnableSymlinksCreate/android" value="1"/>
where "android" is my shared folder!!! =)
In terminal:
Code:
sudo nano /etc/fstab
Add this line:
Code:
/android /home/myName/android vboxsf rw,uid=1000,gid=1000 0 0
where android is the folder I give when sharing in SharedFolder of the VirtualBox and /home/myName/android is the folder I created in Ubuntu.
Ctrl+O and hit Enter to save. Ctrl+X to quit. and Reboot and you are done.
Also, if you encounter error or Virtualbox/ubuntu hung on repo sync, add -j2 or -j3 to prevent race condition!!!
Code:
repo sync -j3
Syncing work tree error!!!
If you encounter syn error
Code:
Fetching projects: 100% (204/224), done.
Syncing work tree: 90% (204/224) error: manifest required for this command -- please run init
1. Go to "android\system\.repo\"
2. Open "project.list" with notepad or notepad++
3. Go to the line of error. In this case, line 204 as above.
4. E.g. Ling 204 shows: external/wpa_supplicant_6, So, go to the folder "android\system\external\wpa_supplicant_6" and delete ".git" folder
5. Go back to Terminal and "repo sync"
=)
You need the lz4 compression tool from now on to be able to build the kernel. First post is updated with instructions on how to get it.
Code:
sudo apt-get install subversion
cd ~/Downloads
svn checkout -r 91 http://lz4.googlecode.com/svn/trunk/ lz4
cd lz4 && make && cp lz4demo ~/bin/lz4demo
Can any body please tell me,what's the exact size of full cm10.1. Source repo
I had set my laptop to download repo from last 32 hours
And till now more than 8gb data was downloaded ....
And how to know how much data left for download...?
Can anybody give me the exact size of the gits which are to be download so that I can compare that sizes with the files which I had downloaded....?
Sent from my Xperia Mini Pro
Hey @mikeioannina,
Do you have any guide on repo branch? In windows, git gui is easy to do. But I'm not familiar with ubuntu.
How do you branch out the project without error?
I tried in ~/android/system:
Code:
repo start kernel-patch .
it says . project not found. What the hell. Needa branch and test some codes!!! =)
Also, is there a private directory for us to put binary to system/apps or scripts which will not be affected by "repo sync" during compilation?
---------- Post added at 06:42 PM ---------- Previous post was at 06:40 PM ----------
hijagdeep said:
Can any body please tell me,what's the exact size of full cm10.1. Source repo
I had set my laptop to download repo from last 32 hours
And till now more than 8gb data was downloaded ....
And how to know how much data left for download...?
Can anybody give me the exact size of the gits which are to be download so that I can compare that sizes with the files which I had downloaded....?
Sent from my Xperia Mini Pro
Click to expand...
Click to collapse
It's around ~25GB. Maybe less due to compression. ^_^
shenlong85 said:
It's around ~25GB. Maybe less due to compression. ^_^
Click to expand...
Click to collapse
Someone told me that its around 8 gb
Sent from my Xperia Mini Pro
hijagdeep said:
Someone told me that its around 8 gb
Sent from my Xperia Mini Pro
Click to expand...
Click to collapse
If you initiated with the CM10.1 branch, it will be 14Gig, if you initiated with no branch, 25Gig
Langes said:
If you initiated with the CM10.1 branch, it will be 14Gig, if you initiated with no branch, 25Gig
Click to expand...
Click to collapse
I have initiated with this repo command
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1
and also used this local manifests
mkdir -p ~/android/system/.repo/local_manifests
curl https://raw.github.com/LegacyXperia/local_manifests/master/semc.xml > ~/android/system/.repo/local_manifests/semc.xml
and now 25 hours are passed and it downloaded 9.5gb data ..
hijagdeep said:
I have initiated with this repo command
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1
and also used this local manifests
mkdir -p ~/android/system/.repo/local_manifests
curl https://raw.github.com/LegacyXperia/local_manifests/master/semc.xml > ~/android/system/.repo/local_manifests/semc.xml
and now 25 hours are passed and it downloaded 9.5gb data ..
Click to expand...
Click to collapse
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1 is for the whole cm10.1 sources. Be patient. Are you using full blown linux host or just a virtual machine? IF you are using virtual machine, it may be slow and have race condition during repo which results in errors. Try using
Code:
repo sync -j3
For 3 simultaneous thread or j2 depending on the number of core in your processor and whether there is hyperthreading. It'll make it more stable.

[CM] Building for expressltexx (GT-I8730)

There's an easy way to do whatever's discussed below, except for a) getting the SDK, b) syncing the repos, and c) building the ROM; and that way is using this script. But it's still better to do the steps below manually as it gets you acquainted with the terminal - you'll be using it a lot.
Thanks to @klvnhng for the original tutorial for mako
Credits to him.
You will need:
A computer running Ubuntu with at least 2GB memory and around 40-65 GB of free space
If you don't want to install Ubuntu, run it instead in VMWare Player or VirtualBox.
make sure you provide the virtual machine with the amount of recommended disk space or more
give it no less than 3-4GB of RAM
A (preferably fast) internet connection (trust me, you don't want to do this with a 256 or 512 kbps connection)
Familiarity with Android and Linux. Read up at source.android.com.
Setting up the build environment
1. Install JDK
DO NOT USE OPENJDK. Remove it by entering
Code:
sudo apt-get purge openjdk* icedtea* icedtea-6*
Install Oracle Java 6 by typing this into a terminal:
Code:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
Android SDK requires the x86 compatibility packages, ia32-libs. Install it by entering this:
Code:
sudo apt-get -y install ia32-libs
As an alternative, you can also do this (thanks to @jjchico):
Code:
sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
2. Android SDK
Download it here.
Extract it to a folder of your choice (in this guide, I will refer to it as ~/android/sdk).
Enter these commands into the terminal:
Code:
cd ~/android/sdk/adt-bundle/sdk/tools
./android sdk
Click Install packages. cd to ~/android/sdk/adt-bundle/sdk/platform-tools and type:
Code:
./adb
./fastboot
If you've done everything correctly, you should get a big block of text for both (which list all of the adb/fastboot commands).
3. Install required packages
Copy and paste this command into the terminal:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev \
ia32-libs x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 \
lib32z-dev libgl1-mesa-dev g++-multilib mingw32 \
tofrodos python-markdown libxml2-utils xsltproc readline-common \
libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev \
lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 \
libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev \
libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev
4. Install the repo command
Make directories called bin and android in your home folder, respectively.
Code:
mkdir -p ~/bin
mkdir -p ~/android
Download and setup the repo binary:
Code:
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now add it to your path:
Code:
export PATH="$PATH:~/bin"
And make sure it belongs in your path between subsequent reboots:
Code:
echo "export PATH="$PATH:~/android/sdk:~/bin"" >> ~/.bashrc
source ~/.bashrc
5. Configuring USB
You must configure USB to detect your Android device(s) properly.
Do this in a terminal:
Code:
curl https://raw.githubusercontent.com/aureljared/build-env-init/master/51-android.rules > ~/bin/51-android.rules
chmod a+r ~/bin/51-android.rules
sudo cp -vfp ~/bin/51-android.rules /etc/udev/rules.d/51-android.rules
6. Syncing up
The next step is to initialize the repository and download the source code to your computer.
Type the following lines into the terminal:
Code:
mkdir -p ~/android/cm-11.0
cd ~/android/cm-11.0
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
To download all the necessary device-specific files for our device, do this:
Code:
curl https://raw.githubusercontent.com/aureljared/android-manifests/expresslte-cm-11.0/local_manifest.xml >> .repo/local_manifests/local_manifest.xml
Now run
Code:
repo sync
You have now begun downloading all of the CM source code to your build directory. Depending on your internet speed, this can take from a couple of hours to a few days. If the sync interrupts, don't worry. Simply continue the sync (you don't have to restart completely, only the project you were downloading when the interrupt occured, lol) by entering:
Code:
repo sync
Some tips:
You can interrupt the process by pressing Ctrl + C, it will continue where it left off the next time anyway.
Remember, you need to cd into your build directory (~/android/cm-11.0, if you've been following this guide) for the command to work.
If you want only one project to be synced at a time, run repo sync -j1 instead.
This step takes a long time depending on your internet connection speed (FYI you're downloading ~20 GB of code!)
7. Building CM (yay!)
You must download the necessary pre-built apps:
Code:
~/android/cm-11.0/vendor/cm/get-prebuilts
Now let's build! cd to your build directory and run the following commands in the terminal:
Code:
. build/envsetup.sh
brunch expressltexx
Now, just let your computer do the rest. This step is very demanding for your computer, so you better leave it alone while it builds. Usually this takes an hour or more. Go get some sleep or eat something.
Done? If everything went correctly, cd to ~/android/cm-11.0/out/target/product/expresslte and you should see your newly built ROM entitled:
cm-11.0-20xxxxxx-UNOFFICIAL-expressltexx.zip
Congratulations! You've successfully built CM 11.0!
For re-builds (i.e. when the source code has been updated and you would like to make a new nightly), just do this:
Code:
cd ~/android/cm-11.0
make clobber
repo sync
. build/envsetup.sh
brunch expressltexx
Have fun building!​
I suggest you to modify step 5 inserting before repo sync
Code:
mkdir .repo/local_manifests
cd .repo/local_manifests
wget https://raw.github.com/KINGbabasula/android_device_samsung_expresslte/cm-10.2/local_manifest.xml
cd ..
cd ..
This will download the specific necessary repos with repo sync
Then remove this in step 6
Code:
mkdir files
cd files
git clone https://github.com/KINGbabasula/proprietary_vendor_samsung.git
as it isn't needed
And change make clean with make clobber because with clobber it will rebuild faster
EDIT: And before step 6 you need to replace these 2 files with the 2 in the attachment
Code:
system/core/mkbootimg/bootimg.h
system/core/mkbootimg/mkbootimg.c
KINGbabasula said:
I suggest you to modify step 5 inserting before repo sync
Code:
mkdir .repo/local_manifests
cd .repo/local_manifests
wget https://raw.github.com/KINGbabasula/android_device_samsung_expresslte/cm-10.2/local_manifest.xml
cd ..
cd ..
This will download the specific necessary repos with repo sync
Then remove this in step 6
Code:
mkdir files
cd files
git clone https://github.com/KINGbabasula/proprietary_vendor_samsung.git
as it isn't needed
And change make clean with make clobber because with clobber it will rebuild faster
EDIT: And before step 6 you need to replace these 2 files with the 2 in the attachment
Code:
system/core/mkbootimg/bootimg.h
system/core/mkbootimg/mkbootimg.c
Click to expand...
Click to collapse
Original post updated.
Can you help me with ia32-libs?
It says that it's referred to by a handful of other packages but it has no installation candidates or something. The bottom line is that I can't install it.
I'm using 13.10 x64 on an ASUS K43SJ.
- Intel i5-2410M Quadcore (2.3GHz normal, 2.9GHz Turbo Boost)
- 2GB RAM available to Ubuntu VM
Sent from my International Galaxy Express using Tapatalk 4
aureljared said:
Original post updated.
Can you help me with ia32-libs?
It says that it's referred to by a handful of other packages but it has no installation candidates or something. The bottom line is that I can't install it.
I'm using 13.10 x64 on an ASUS K43SJ.
- Intel i5-2410M Quadcore (2.3GHz normal, 2.9GHz Turbo Boost)
- 2GB RAM available to Ubuntu VM
Sent from my International Galaxy Express using Tapatalk 4
Click to expand...
Click to collapse
You have to apt-get install every missing library one by one
Inviato dal mio GT-I9070 utilizzando Tapatalk
aureljared said:
2. Android SDK
Download it here.
Extract it to a folder of your choice (in this guide, I will refer to it as ~/android/sdk).
Enter these commands into the terminal:
Code:
cd ~/android/sdk/adt-bundle/sdk/tools
./android sdk
Click Install packages. cd to ~/android/sdk/adt-bundle/sdk/platform-tools and type:
Code:
adb
fastboot
Click to expand...
Click to collapse
Shouldn't it be
Code:
./adb
./fastboot
Or have you added the sdk to your path?
I guess the compilation process will need the sdk. How does it find the sdk? Do you need to provide the path anywhere?
Thanks for the great tuto.
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
---------- Post added at 12:08 PM ---------- Previous post was at 11:29 AM ----------
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
jjchico said:
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
---------- Post added at 12:08 PM ---------- Previous post was at 11:29 AM ----------
These are the libs that ia32-libs pulls in that are present in Ubuntu 13.10. This should be equivalent to install ia32-libs in Ubuntu 12.04:
$ sudo apt-get install lsb-release lib32gcc1 libc6-i386 lib32z1 lib32stdc++6 lib32bz2-1.0 lib32ncurses5
Click to expand...
Click to collapse
jjchico said:
Shouldn't it be
Code:
./adb
./fastboot
Or have you added the sdk to your path?
I guess the compilation process will need the sdk. How does it find the sdk? Do you need to provide the path anywhere?
Thanks for the great tuto.
Click to expand...
Click to collapse
Updated original post.
Sent from my GT-I8730 using Tapatalk
Thanks. Just note the missing double quotes in the export PATH.
Enviado desde mi GT-I9000 mediante Tapatalk
jjchico said:
Thanks. Just note the missing double quotes in the export PATH.
Enviado desde mi GT-I9000 mediante Tapatalk
Click to expand...
Click to collapse
Haha lol sorry. I was very sleepy when I updated last night.
Updated post.
My repo sync is finished with 65 out of 401 projects. ia32-libs now okay thanks to you @jjchico.
Sent from my GT-I8730 using Tapatalk
I get this
[email protected]:~/android/cm-10.2$ repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
No command 'repo' found, did you mean:
Command 'repro' from package 'repro' (universe)
Command 'repl' from package 'nmh' (universe)
Command 'repl' from package 'mailutils-mh' (universe)
Command 'rep' from package 'rep' (universe)
repo: command not found
[email protected]:~/android/cm-10.2$
Any ideas? All seemed good before that
Bazzan
Check that repo is in the bin folder in your user main folder.
Check that repo is executable
chmod a+x ~/bin/repo
Enviado desde mi GT-I9000 mediante Tapatalk
"6. Building CM (yay!)"
"In order to make a working build, you have to get the proprietary files (mainly device build files and drivers) for the device."
so how do I get the propriety files and where do I put them? ADB from your phone?
After this you direct us to prebuilt apps so it appears there is a step missing unless I am pulling proprietary files down from KINGbabasula's Github
Bazzan
bazzan said:
"6. Building CM (yay!)"
"In order to make a working build, you have to get the proprietary files (mainly device build files and drivers) for the device."
so how do I get the propriety files and where do I put them? ADB from your phone?
After this you direct us to prebuilt apps so it appears there is a step missing unless I am pulling proprietary files down from KINGbabasula's Github
Bazzan
Click to expand...
Click to collapse
Yeah, the files are located somewhere in KINGbabasula's github. If you want to use ADB then refer to the text file located in android_device_samsung_expresslte.
Or if you want to download the files themselves, do this in a terminal:
Code:
mkdir proprietary
cd proprietary
git clone https://github.com/KINGbabasula/proprietary_vendor_samsung.git
The files will be located in proprietary/proprietary_vendor_samsung/expresslte.
Sent from my GT-I8730 using Tapatalk
Finally got build going. Thanks for the tutorial @aureljared. You were not kidding when you said takes a while. Not too sure where to from here. Welcome suggestions if anyone wants me to try anything
Bazzan
URGENT
Before proceeding to build any more ROMs, let me ask some questions.
What toolchain for building the kernel are you using? Toolchains that might work are arm-eabi-4.4.3 upwards or linaro 4.4.3 upwards.
What is your configuration for the kernel? It is written to a file called ".config" insinde the kernel source.
Have you applied any kind of patch to the code before compiling? If so, what?
Click to expand...
Click to collapse
Thank you for your time. Your answers to the above questions will be highly appreciated and will be of utmost importance. There is also a good chance that we might build a proper kernel with your reports!
:good: :victory:
Sent from my GT-I8730 using Tapatalk
aureljared said:
URGENT
Before proceeding to build any more ROMs, let me ask some questions.
What toolchain for building the kernel are you using? Toolchains that might work are arm-eabi-4.4.3 upwards or linaro 4.4.3 upwards.
What is your configuration for the kernel? It is written to a file called ".config" insinde the kernel source.
Have you applied any kind of patch to the code before compiling? If so, what?
Thank you for your time. Your answers to the above questions will be highly appreciated and will be of utmost importance. There is also a good chance that we might build a proper kernel with your reports!
:good: :victory:
Sent from my GT-I8730 using Tapatalk
Click to expand...
Click to collapse
No toolchain experience at all. Just substituted kernels from elsewhere. Maybe if you are leaning toward Linaro, I should find myself a tutorial for arm-eabi-4.4.3 upwards and give that a go. then we can cover more ground.
Bazzan
bazzan said:
No toolchain experience at all. Just substituted kernels from elsewhere. Maybe if you are leaning toward Linaro, I should find myself a tutorial for arm-eabi-4.4.3 upwards and give that a go. then we can cover more ground.
Bazzan
Click to expand...
Click to collapse
Sure.
I'm not saying that I'm relying on Linaro now, it's just that Linaro is a toolchain developed by a consortium of technology companies including Samsung that aims to build Linux kernels that perform extremely well on mobile devices.
CM 10.2 uses Linaro 12.09, I think.
I tried building with Linaro a couple of days ago but make threw me some errors, the most confusing being something like this
Code:
make [cypress_touchkeys.o] *** Error 2
I don't even know what Cypress is.
Sent from my GT-I8730 using Tapatalk
aureljared said:
Sure.
I'm not saying that I'm relying on Linaro now, it's just that Linaro is a toolchain developed by a consortium of technology companies including Samsung that aims to build Linux kernels that perform extremely well on mobile devices.
CM 10.2 uses Linaro 12.09, I think.
I tried building with Linaro a couple of days ago but make threw me some errors, the most confusing being something like this
Code:
make [cypress_touchkeys.o] *** Error 2
I don't even know what Cypress is.
Sent from my GT-I8730 using Tapatalk
Click to expand...
Click to collapse
Cannot help with Cypress. Some time ago I downloaded a file called GT-I8730_JB_Opensource.zip - not sure where I found it.
It appears to be what is says it is. Within it is a text file called README_Kernel.txt
It has the following
################################################################################
1. How to Build
- get Toolchain
From android git server , codesourcery and etc ..
- arm-eabi-4.4.3
- edit Makefile
edit "CROSS_COMPILE" to right toolchain path(You downloaded).
EX) export CROSS_COMPILE= $(android platform directory you download)/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
Ex) export CROSS_COMPILE=/usr/local/toolchain/arm-eabi-4.4.3/bin/arm-eabi- // check the location of toolchain
$ export ARCH=arm
$ make msm8930_express_defconfig
$ make
2. Output files
- Kernel : arch/arm/boot/zImage
- module : drivers/*/*.ko
3. How to Clean
$ make clean
################################################################################
Way out of my depth but will try sometime next week to give it a go with arm-eabi-4.4.3. Major interview Monday so nothing before then.
Bazzan
bazzan said:
Cannot help with Cypress. Some time ago I downloaded a file called GT-I8730_JB_Opensource.zip - not sure where I found it.
It appears to be what is says it is. Within it is a text file called README_Kernel.txt
It has the following
################################################################################
1. How to Build
- get Toolchain
From android git server , codesourcery and etc ..
- arm-eabi-4.4.3
- edit Makefile
edit "CROSS_COMPILE" to right toolchain path(You downloaded).
EX) export CROSS_COMPILE= $(android platform directory you download)/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
Ex) export CROSS_COMPILE=/usr/local/toolchain/arm-eabi-4.4.3/bin/arm-eabi- // check the location of toolchain
$ export ARCH=arm
$ make msm8930_express_defconfig
$ make
2. Output files
- Kernel : arch/arm/boot/zImage
- module : drivers/*/*.ko
3. How to Clean
$ make clean
################################################################################
Way out of my depth but will try sometime next week to give it a go with arm-eabi-4.4.3. Major interview Monday so nothing before then.
Bazzan
Click to expand...
Click to collapse
That's from Samsung. It contains the kernel source as you already have seen
It's stock 3.4.0 so I don't know if it will work with CM :good:
Sent from my GT-I8730 using Tapatalk
Quote from jt1134:
jt1134 said:
I use the d2 family kernel source.
For stock ROMs and CM10, you can use the source and ramdisk provided by samsung.
For CM10.1 or higher, you'll have to get your hands very dirty. IMO the easiest route would be to port the missing drivers from stock samsung source to the msm8930-common kernel, and modifying it to work with them. This is how I did it for the I437 : http://review.cyanogenmod.org/#/c/47947/ . You may then use the serrano device trees as a template once the kernel is ready.
Click to expand...
Click to collapse
Updated first post with this info.
Sent from my GT-I8730 using Tapatalk

[GUIDE][TOOL] How Build/Compile your own kernel for LG G2

There is still no "how to" specific to the LG G2, so I'll try to share the maximum of my experience (or almost) with ["kernel", "build", "LG G2"] here. I'll show two methods different using CM12 kernel, The method for LG ROMs is very similar, I show some tips for LG ROMs also. The first method is the "manual" and second is the "automatic" using my "tool" called DCC. So come on! For this you will need a computer running Linux (x64) and have knowledge about basic Linux commands. I'm using a laptop (i3-2328M and 4GB of RAM) running Ubuntu 14.10 :good:
Setting Up the Environment
First install the essential tools (common environment for those already working with C/C++):
Code:
sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-7-jdk openjdk-7-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
Check Java and Java Compiler version:
Code:
java -version && javac -version
If the default Java is 1.6.x, Use this command and select java-7-openjdk as default:
Code:
sudo update-alternatives --config java
Click to expand...
Click to collapse
Setting Up the kernel Environment
Code:
mkdir -p ~/android/mykernel && cd ~/android/mykernel && mkdir out
This will create a folder and two subfolder in your home, Within mykernel folder will get all the tools that we will set up. Now we set the toolchain, Particularly I use Linaro 4.9.3, the version optimized for Cortex-A15 by @Christopher83, so I will use it here.
Clone Linaro GCC 4.9.3:
Code:
git clone https://github.com/Christopher83/arm-cortex_a15-linux-gnueabihf-linaro_4.9
Now the required binaries (Common essential binaries to work with msm8974):
Code:
git clone https://github.com/ferreirawax/mkboot_exec ~/android/mykernel/executables
Clone the RAM disk compiled from CM12:
Code:
git clone -b aosp https://github.com/ferreirawax/ramdisk_g2 ~/android/mykernel/ramdisk
For stock Kitkat:
This RAM disk was extracted from my d805 (d805 is a d802 which was released in latin america), then so will work on the d802, d805 and d806 (d806 is a d802 as the d805) If the variant is another you will have to draw your own device using a tool such AIK or search repositories of other developers.
Click to expand...
Click to collapse
Code:
git clone -b lge https://github.com/ferreirawax/ramdisk_g2 ~/android/mykernel/ramdisk
Now finally the source code of the kernel, Here I will use a configured kernel to compile the code without CM12 source, you can use the source code that is in the official repositories of CM12, but you will face some errors and warnings during the build that can be solved using the commits that are in my source and supply of other developers.
Clone kernel source:
Code:
git clone -b cm-12.0 https://github.com/ferreirawax/kernel_lge_msm8974-patched ~/android/mykernel/msm8974
For stock KitKat:
Code:
git clone -b lge-kitkat https://github.com/ferreirawax/kernel_lge_msm8974-patched ~/android/mykernel/msm8974
Apparently not but we already have a complete environment, see the folders in mykernel to have a shadow on it. Now let's the good part of the story. :fingers-crossed:
Click to expand...
Click to collapse
Compiling
Enter in kernel folder:
Code:
cd msm8974
Export Architecture and Toolchain:
Code:
export ARCH=arm
export CROSS_COMPILE=~/android/mykernel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-
For stock KitKat you need export LZ4 path:
Code:
export PATH=$PATH:tools/lz4demo
Select the model of the device you want to compile your pointing due defconfig, If you are using source code directly from the repositories of the CM12, defconfig each supported model is called "cyanogenmod_MODEL_defconfig".
Select model to build (In my case I will compile for d802):
Code:
make d802_defconfig
Now let's clear the specific waste of d802:
Code:
make clean && make mrproper
Select model again to generate new .config:
Code:
make d802_defconfig
Now we start to build:
Code:
make -j4
-j4 is suitable for dual-core processors and -j5 for quad-core.
Depending on the configuration of your PC can take up to 20 minutes. In my laptop the build time is about 10 minutes. If you are using VirtualBox, can take much longer. Upon completion, will generate a zImage and some dtb (Device tree binary) files, The dtb files will be used to create a specific image (dt.img) file containing board informations. Now let's create a RAM disk and then dt.img to later put it all together and result in a final boot.img.
Enter in executables folder:
Code:
cd ~/android/mykernel/executables
Create GNUZip compressed RAM disk:
Code:
./mkbootfs ~/android/mykernel/ramdisk | gzip > ~/android/mykernel/out/ramdisk.gz
Create dt.img:
First copy the dtc file that is in executables folder to /usr/bin
Code:
gksu nautilus
This will open the file manager with root privileges, After click the left mouse button and select the dtc as executable.
You may need to restart, After that create the dt.img with the following command.
Code:
./dtbTool -s 2048 -o ~/android/mykernel/out/dt.img ~/android/mykernel/msm8974/arch/arm/boot/
Finally assemble boot.img file:
Code:
./mkbootimg --kernel ~/android/mykernel/msm8974/arch/arm/boot/zImage --ramdisk ~/android/mykernel/out/ramdisk.gz --cmdline "XXXX" --base 0x00000000 --pagesize 2048 --offset 0x05000000 --tags-addr 0x04800000 --dt ~/android/mykernel/out/dt.img -o ~/android/mykernel/out/boot.img
Replace the XXXX for the following:
console=ttyHSL0,115200,n8 androidboot.hardware=g2 user_debug=31 msm_rtb.filter=0x0 mdss_mdp.panel=1:dsi:0:qcom,mdss_dsi_g2_lgd_cmd androidboot.selinux=permissive
Do not remove the quotes. Replace the panel model (red) for your model. if you are compiling for stock KitKat, remove everything that is green.
Click to expand...
Click to collapse
Now let's add a "signature" in your kernel for the damn locked LG G2 bootloader so you can not be invalidated. If you do not do this procedure, the bootloader of your LG G2 will verify that this kernel has a particular signature, as it does not have your device will be unable to boot. We have two tools for this, Loki is able to fool the bootloader and open_bump (This tool is controversy) is able to add a "valid" signature using illegal means. I'll show how to use both. To this is very simple..
open_bump method:
You need Python to run any Python code, open_bump requires Python 2.x
Code:
git clone https://github.com/CyboLabs/Open_Bump
cd Open_Bump && python open_bump.py ~/android/mykernel/out/boot.img
You will now have an output "boot_bumped.img".
loki_tool method:
First get a copy of the bootloader of your G2, For this you need the adb installed and your G2 properly connected to your PC.
Get bootloader:
Code:
sudo apt-get install android-tools-adb
adb devices && adb shell "su -c dd if=/dev/block/platform/msm_sdcc.1/by-name/aboot of=/sdcard/aboot.img"
adb pull /sdcard/aboot.img
Do not forget the USB debugging enabled
Patch kernel:
Code:
./loki_patch boot aboot.img ~/android/mykernel/out/boot.img ~/android/mykernel/out/loki_boot.img
Will generate an output "loki_boot.img" on mykernel/out folder.
You can install using "my easy installer" (Attached at the end of post):
Download the attachment and extracted, Place your boot.img in the delta folder and
copy all the modules that are in your kernel source for the modules folder:
Code:
find ~/android/mykernel/msm8974/. -name "*.ko" -type f -exec cp {} ~/android/mykernel/installer/system/lib/modules \;
Now zip folder and install on your device. This installer already have panel detection script by @dr87
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Finally now you have your own kernel! Now I will show the second method of how to automatic compile your kernel using my tool.
To rebuild you have to use the following:
Code:
make clean && make mrproper
make MODEL_defconfig
make -j4
Click to expand...
Click to collapse
Some tips
To not export the toolchain path every time you restart the system, Create a Shell executable in /etc/profile.d as follows:
Code:
sudo nano /etc/profile.d/export_gcc.sh
Copy and paste:
export PATH=~/android/mykernel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin:$PATH
Click to expand...
Click to collapse
CTRL + X, Y, ENTER
Now you just use:
Code:
export ARCH=arm
export CROSS_COMPILE=arm-eabi-
Useful guides:
If you are new, you can start learning about git, One of the main tools for working with modifications to your kernel. Below I leave some links with some guides that can help you.
How to use Github
How to cherry-pick a github commit
Click to expand...
Click to collapse
DCC is a tool I developed to simplify my day, DCC is just a simple Python code that can help you save your time! See the features:
Command-line arguments like M$'s DiskPart
Real-time Shell executer
Manage builds for AOSP and LG ROMs
Build for single or ALL variants in same time
Manage the parameters of your kernel
DCC works with embedded open_bump
Manage your favorite toolchain
Easy to configure and use
I'll show how to use DCC is easy
Setup kernel environment:
Code:
reset && cd $HOME
mkdir dev && cd dev
git clone https://github.com/ferreirawax/dcc
cd dcc && find . -name '.gitignore' -delete
git clone https://github.com/ferreirawax/ramdisk_g2_aosp ramdisk/aosp
git clone https://github.com/ferreirawax/kernel_lge_msm8974-patched msm8974/aosp
Build kernel:
Code:
python dcc.py
do boot d802
exit
You know what happens to these magical commands? An immediate flashable zip of your kernel ready to flash. But for that you need to "setup" to your taste, see the page on github.
@ferreirawax this is great i was waiting for something like this so much, tommorow i will try your guide and post the results
EDIT
I followed everything and got stuck here:
[email protected]:~/android/mykernel/msm8974$ make clean && make mrproper
make: /home/simex/android/mykenel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-gcc: Command not found
THANKS for help
EDIT 2
I tried method with DCC and im stuck here:
[email protected]:~/dev/dcc$ python dcc.py
Traceback (most recent call last):
File "dcc.py", line 19, in <module>
from colorama import *
ImportError: No module named colorama
[email protected]:~/dev/dcc$
Sorry if im annoying but i hope someone can help me
Boris31 said:
@ferreirawax this is great i was waiting for something like this so much, tommorow i will try your guide and post the results
EDIT
I followed everything and got stuck here:
[email protected]:~/android/mykernel/msm8974$ make clean && make mrproper
make: /home/simex/android/mykenel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-gcc: Command not found
THANKS for help
EDIT 2
I tried method with DCC and im stuck here:
[email protected]:~/dev/dcc$ python dcc.py
Traceback (most recent call last):
File "dcc.py", line 19, in <module>
from colorama import *
ImportError: No module named colorama
[email protected]:~/dev/dcc$
Sorry if im annoying but i hope someone can help me
Click to expand...
Click to collapse
This error happens when the toolchain path is wrong.
Colorama module need to use DCC (I forgot to mention that)
Code:
sudo pip install colorama
Really exited to see sutch a complete guide for how to make a kernel for our G2
Will try and see if I can manager to compile my first kernel with this guide today..
ferreirawax said:
This error happens when the toolchain path is wrong.
Colorama module need to use DCC (I forgot to mention that)
Code:
sudo pip install colorama
Click to expand...
Click to collapse
ok thanks i got i working
---------- Post added at 10:43 AM ---------- Previous post was at 10:21 AM --------- @ferreirawax you got a typing mistake here thats why method 1 didnt work i finaly figured it out:
Export Architecture and Toolchain:
Code:
export ARCH=arm
export CROSS_COMPILE=~/android/mykenel/arm-cortex_a15-linux-gnueabihf-linaro_4.9/bin/arm-eabi-
It should be myKERNEL and that it works
Now i succesfully build my kernel but im having problems with bump, i cant get past this:
[email protected]:~$ python open_bump.py ~/android/mykernel/out/boot.img
python: can't open file 'open_bump.py': [Errno 2] No such file or directory
but im sure its there i tryed nearly everything but cant get bumped boot.img
Thank you!!!! I have wanted something like this to compile different kernels .
It would have been totally awesome if @dorimanx did a tutorial once where he shared how he makes his (stock) kernels..anyways will this work on a 11 year old PC with 1gb RAM and 1,7 GHz processor?
any help for bumping boot.img ?
Boris31 said:
any help for bumping boot.img ?
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?p=56987541
(OP gave cmd lines too)
6ril1 said:
http://forum.xda-developers.com/showthread.php?p=56987541
(OP gave cmd lines too)
Click to expand...
Click to collapse
Yeah thanks i finally got it
Norside said:
It would have been totally awesome if @dorimanx did a tutorial once where he shared how he makes his (stock) kernels..anyways will this work on a 11 year old PC with 1gb RAM and 1,7 GHz processor?
Click to expand...
Click to collapse
This is willpower
Boris31 said:
Yeah thanks i finally got it
Click to expand...
Click to collapse
Now you have what start modifying your kernel!
ferreirawax said:
Now you have what start modifying your kernel!
Click to expand...
Click to collapse
Yeah finally i'v built a kernel now i need to learn to modify it. Any good guide for that maybe
Boris31 said:
Yeah finally i'v built a kernel now i need to learn to modify it. Any good guide for that maybe
Click to expand...
Click to collapse
For that you need to read a little about git, then see the changes made by other developers and place them in your own kernel.
ferreirawax said:
For that you need to read a little about git, then see the changes made by other developers and place them in your own kernel.
Click to expand...
Click to collapse
Thanks, I'm finally beginning to understand Linux terminal commands.
@ferreirawax
I am aware that the rules prohibit posting simple thanks but I feel duty do it here because it is really nice to find shared topics showing how to fish rather than giving fish.
Big thank you to you so, great initiative !
@ferreirawax
Thanks for taking the time to post this. I would love for more people to try their hand at Custom Kernels! Otherwise you end up with the same kernel, different name.
DTB combiner:
Input directory: '/home/bolt890/dev/dcc/msm8974/aosp/arch/arm/boot/'
Output file: '/home/bolt890/dev/dcc/outputs/dt.img'
Found file: msm8974-v2-2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-v2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
=> Found 0 unique DTB(s)
error: dt.img not found, failed to make target
Keep getting this error
bolt890 said:
DTB combiner:
Input directory: '/home/bolt890/dev/dcc/msm8974/aosp/arch/arm/boot/'
Output file: '/home/bolt890/dev/dcc/outputs/dt.img'
Found file: msm8974-v2-2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-v2-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8974-g2-open_com.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
=> Found 0 unique DTB(s)
error: dt.img not found, failed to make target
Keep getting this error
Click to expand...
Click to collapse
Seem to lack the DTC binary on your system. Download the attachment and follow:
Code:
sudo cp ~/dtc.zip /usr/bin/dtc
Or you can simply remove the extension and copy the file to /usr/bin any other way, may be necessary to a log-in/out for effect. Then compile again.

[GUIDE][COMPLETE] All in one Android Development [NOOB FRIENDLY]

Hi All,
I and @akhilnarang decided to post this guide to help anyone wanting to learn building of Roms and kernels. We will be using Ubuntu 14.04 Trusty Tahr here.
You can find instructions to install it elsewhere, just remember rom building needs 64bit OS, minimum 4GB RAM, and 100GB space on HDD. Kernel can be built on less hardware, but will take long
Make sure you have fast net, as you have to download at least 16GB of ROM sources, or more kernel, only 1GB of sources max.
Be prepared to spend a lot of time downloading, learning, and fixing bugs
More RAM, or faster CPU, or SSD will speed up the process.
From our personal experiences we have found that this is the best, stable, up-to-date version of Ubuntu yet. This has come from my trial and errors, searching all over the web, and bits I picked up from here and there.
We will move Rom building part when we completed this step properly. Step by step we will learn compiling kernel, using Github, Gerrit, Cherry-picking.
At the end of the post I have linked a script by @akhilnarang which if run will automatically install all these programs for lazy people like us haha [emoji14]
If you not interested to do all procedure from below just use the script. Simply it will automatically configure the build environment.
NOTE-------- some of these packages may already be on your machine. Obviously, if you complete a step and you have one of these installed, the machine simply will not do anything. So...it will not hurt anything. Some of the packages are different from Ubuntu 12.04 and 13.04 (use these packages for Ubuntu 14.04 as many of the old ones have obsoleted - these are new replacements).
So if you set up your pc with Ubuntu we are good to go.
All code will be in code boxes like this:
Code:
$
means you have to run that command in the terminal (don't type the $).
All commands with sudo, gksudo, or gksu means it requires root permission.
It will ask for password.
Once you type, then in that terminal session it will not ask you for a few minutes again.
Any time you make changes to .bashrc or .profile file, make sure to run
Code:
$ source ~/.bashrc
$ source ~/.profile
Or exit and open new terminal else the changes will not take place
Setting up build environment:
Installing Java JDK
Note: You need JDK 7 when you willing to compile Lollipop. If you wanna compile KitKat or lower you need JDK 6.
Open terminal (CTRL + ALT + T)
Then execute the following commands in terminal one by one:
Download & install java
Code:
$ sudo apt-get update && sudo apt-get install openjdk-7-jdk openjdk-7-jre
CHECK if java properly installed or not
Code:
$ java -version
If you get output like
Code:
java version "1.7.0_79"
on the first line then all is good
Now JDK is configured!
Note: Only for Ubuntu 14.04 or higher
Installing Required Packages
Open Terminal
Now execute this command:
Note: This will take some time, has to download about 500MB or so of packages
Code:
$ sudo apt-get update && sudo apt-get install git-core python gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-7-jdk pngcrush schedtool \
libxml2 libxml2-utils xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib liblz4-* android-tools-adb android-tools-fastboot ccache
Configuring USB Access
Now we need to set permissions so that our USB ports can detect our android devices [emoji14]
Type in the following commands, it will download a file with the permissions, give it permission to execute, and restart the service.
Code:
$ sudo curl --create-dirs -L -o /etc/udev/rules.d/51-android.rules -O -L https://raw.githubusercontent.com/snowdream/51-android/master/51-android.rules
$ sudo chmod 644 /etc/udev/rules.d/51-android.rules
$ sudo chown root. /etc/udev/rules.d/51-android.rules
$ sudo service udev restart
$ sudo killall adb
ADB & Fastboot are configured
Installing Repo Package
Open terminal and type:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
Configure Git
Open terminal and type:
Code:
$ git config --global user.email ""
$ git config --global user.name ""
Git is configured.
Configure ccache
Open terminal and type:
Code:
$ gksu gedit ~/.bashrc
Enter these lines
Code:
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
Save & close
Open terminal & execute:
Code:
$ source .bashrc
$ ccache -M 50G
I usually use 50 gigs. You can use more if you have more space, or build for many devices
Make a GitHub account using the same email address you used for configuring git
Then follow these
So if you not interested in doing above all steps then simply use this script by my friend @akhilnarang
Open terminal and type:
Code:
$ sudo apt-get install git-core
then do
Code:
$ git clone https://github.com/akhilnarang/scripts.git
$ cd scripts
$ . build-environment-setup.sh
This script will install all required packages
Congrats
YOUR BUILD ENVIROMENT IS NOW SETUP
Now move onto #2nd post for Git and repo tutorial
To be continued
How To Use Git!
Now, to explain about git
Its a version control system, for code, like mercurial or subversion
Most android source code is either at AOSP
Most custom ROMs like CyanogenMod,Radium, host their code over at GitHub
So to start off, make a GitHub Account!
Here, you will find all the various repositories, full of code
All files are stored in repositories
When browsing a repository, you will see a button called fork
This will make a copy of it in your account, so you can edit it, and even submit changes for approval to the parent account
Now, to download the source of a repository onto your computer, we use git clone command
Code:
$ git clone https://github.com/akhilnarang/scripts
So we download the scripts from my github onto your PC, so we can run them
Now, if you added your ssh key as shown in bottom of post #1, then when cloning a repo from your account, while copying the link from bottom right corner, choose ssh link.
If you, when pushing(uploading)local changes, you will not be prompted for username and password, your ssh key will identify you .
After cloning, cd to the directory
Run
Code:
git remote -v
This will show a list of remotes
Default is origin, i.e. the link you have cloned from
Now once we make our changes locally
Code:
$ git add -A
This stages all modified/added/deleted files to be committed
Code:
$ git commit
This opens a text editor for you to write a commit message for your commit
Just give me brief description of your changes or something :v.
Then
Code:
$ git push <remote-name> HEAD:<branch>
If you have cloned, then remote will be origin
Branch can be checked by
Code:
git branch
, and also online from where you cloned
If you used https:// URL then you will be prompted for username and password to authenticate yourself
If git:// URL you can't push, you will need to use a https:// or ssh link
Another way to push can be
Code:
$ git push <link> HEAD:<branch>
Now say you want to make your own git repository of your files
Click on the new repository button on GitHub, give a name
You can do initial commit online, or locally
Follow the instructions it gives you
i.e. if you have all files ready (in a folder)
Code:
$ git init
$ git add -A
$ git commit
$ git push <link> HEAD:<branch>
A VERY important thing to be noted while using version control systems like git, is to preserve authorship of a commit
If someone else has made some changes to a file, and we want them, we should not copy the changes and commit, but should give them authorship either by cherry-picking(will be explained)
Or using this syntax
Code:
$ git commit --author="Author Name <[email protected]>"
Through this git will know the correct authors
Not giving proper authorship is known as kanging, not appreciated here on XDA,(or anywhere else for that matter), and can cause you to be banned :3
Anyway, on to cherry-picking
Go to your repository
Code:
$ git remote add blahblah link-to-url-you-want-commit-from
$ git fetch blahblah branch-commit-is-on
$ git cherry-pick Commit-sha1-hash
If you see a commit on GitHub, or GitLab, or BitBucket, there is a unique(to that repo) SHA for every commit to identify it
Fetch the correct repo as shown above, and paste the commit id
That will fetch the changes
However, if your local source is quite different from the source you cherry-picked from, it will conflict
If so your terminal will display it
then run
Code:
$ git status
Files shown in red color have conflicts
Open them with a text editor like Atom(my favorite), nano, gedit, vim, etc
Look for <<<<<<<
From there, the content till ======
is the original content
=======
till >>>>>>> *insert commit message here* is the new stuff
So check the commit, figure out what's wrong, fix it, save.
Then
Code:
$ git add -A
$ git commit
If no conflicts it will commit on its own and you just need to
Code:
$ git push
as explained earlier :v
Running
Code:
$ git log
will show you a list of commits , authors, and SHA
If for some reason you wanna remove some commit, use
Code:
$ git revert commit-SHA
Just like cherry-picks, it may have conflicts
Anyway, this is just a small guide to get started off
You can easily found out more by searching, and experimenting
I will add more stuff here soon
Enjoy with this much till then
Building CyanogenMod for those device which officially supported​If our build environment setted up successfully and after we learnt some Git and repo thing now we will concentrete on rom building
Now we have to Initialize Repo. We will try to build CyanogenMod.
Initialize the repo:
Code:
Code:
$ mkdir cm
$ cd cm
$ repo init -u git://github.com/CyanogenMod/android.git -b cm-13.0
$ repo sync -f --no-clone-bundle
For people who have already done a repo init:
Code:
$ cd cm
$ repo sync -f --no-clone-bundle
When prompted, enter your real name and email address.
Continue onto adding a device
~How To Add A Device To The List~
Find the github for your device you wish to add. (We will give Android One Devices(sprout4&sprout8) as an example
Navigate back to your home directory for building:
Code:
$ cd ~/cm
$ source build/envsetup.sh
Or
$ . build/envsetup.sh
That sets up your environment for building
Get your list of devices:
Code:
$ brunch
Choose your device from the list, till will fetch tree and dependencies if needed, sometimes vendor tree will need to be added manually (In case of CyanogenMod, rest all ROMs keep in dependencies)
Build will start,enjoy!
For users who like understanding>
Code:
. build/envsetup.sh
runs a shell script, which adds various environment variables,etc, and some commands.
Calling "brunch" actually runs the command
Code:
breakfast [email protected] && mka bacon
(for CM)
[email protected] in shell script means all the parameters that have been passed, so if you passed brunch sprout, it would pass sprout
breakfast calls lunch, which selects the device, prepares the environment for building for it, fetches dependencies with the help of roomservice python script
"mka bacon"
This calls GNU make, and passes bacon as a parameters, to be "made"
mka is used instead of make, as it automatically uses all available threads of your CPU
If you have a quad core Intel, or octa core AMD, you could run make -j8 bacon
This is just the gist of it, reading through the envsetup.sh would make it clearer
If successful, you will get a zip in out/target/product/device
If not, check post #6
Most likely, you will find a solution there.
If not, please ask us in the thread, we would be happy to assist you
To be continued
Kernel Compilation
As many of you'll already know, kernel of an operating system
Android devices use a modified version of the linux kernel
Firstly, most important thing to note, in that the Linux Kernel is licensed under the GNU GPL (General Public License), which can be found here
Basically, you must always keep your work on the kernel open-source, and display the link to it when publishing your work on XDA Threads, etc
In order to do this, make sure you fork, or push the kernel source you're working on to your GitHub account so that you can push the changes you're making
Make sure you give proper authorship, as explained in post #2
If unable to, give credits to author in commit message, but don't kang please [emoji14]
Please try to have at least a basic knowledge of C, so that you can fix errors
Else, use Google before asking in thread, there's a huge chance someone has already gotten and solved it :v
So now, getting to work
I will give an example using Android One Device (sprout4&&sprout8)
The kernel source be found here(branch android-mediatek-lollipop-mr1 for 5.1,or something, not sure, check), and also here, branch cm-12.1 for 5.1 ROMs
So fork it to your GitHub account, or clone from AOSP and push to your git
I'd recommend the one from CM git, as it usually has small bugs fixed compared to stock
In my device's case, a whole lotta broken stuff is fixed, so I would take from cm
So start off, by installing all dependencies as shown in 1st post
Code:
$ git clone https://github.com/akhilnarang/android_kernel_mediatek_sprout -b cm-12.1 sprout-kernel
Replace the link with your own, ssh if you wish, as explained in #2
You must specify -b cm-12.1,as the default is cm-11.0, and you will end up will KitKat source!
The last parameter is optional, it saves it in that directory, in this case sprout-kernel
Now, all kernel source's have a file called a defconfig, or default configuration, that is device-specific
You will find it in arch/*your devices architecture*/configs
Your device may be arm, arm64, x86
Make sure you remember the name of the defconfig, you can rename it too [emoji14]
If you would like to give your kernel a name, simplest way would be to look for the CONFIG_LOCALVERSION in the defconfig
Make it something like
Code:
CONFIG_LOCALVERSION="-Your-Kernel-Name"
Anyway, so now you need a toolchain
For starting off, we will use GCC 4.8 from Google
For ARM devices
Code:
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/
For aarch64/arm64
Code:
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.8/
For x86 I'm not sure, go have a look here
Now remember where you saved it
Now open the file called "Makefile" in the root of kernel source
Look for a line that has ARCH?=
that dosen't start with a # (lines starting with # are comments)
And make it
Code:
ARCH ?= arm
or
Code:
ARCH ?= arm64
And look for CROSS_COMPILE ?=
make it
Code:
CROSS_COMPILE ?= path/to/downloaded/toolchain/bin/arm-eabi-
for arm devices
Code:
CROSS_COMPILE ?= path/to/downloaded/toolchain/bin/aarch64-android-linux-
for arm64 devices
This may differ on Custom toolchains, etc, you can find out about that by viewing the commits of different kernels, and going through various threads
I'm only gonna explain how to compile the kernel, not how to add stuff (at least for now)
If you wish now, you can refer to #2, and commit and push these changes [emoji14]
Now run
Code:
$ make cyanogenmod_sprout_defconfig
That's what my defconfig is called, yours maybe called something else [emoji14]
And now finally to start the build
First, check how many cores/threads your CPU has
A quad core Intel, an octa core AMD, will have 8
So if you have one, run
Code:
$ make -j8
This will compile the code on all 8 threads parallely
However this makes debugging errors harder
If you have an error, just run
Code:
$ make
to reduce output and identify error
Anyway, the process generate a zImage in arch/arm/boot/zImage
or arch/arm64/boot/zImage
This is a binary file
If you check the zip of your favorite custom kernel, you will find one too
In most cases, you can simply replace it with this, update the updater-script, and flash
Most of these zips use anykernel format, meaning it utilizes ramdisk from existing kernel, so if you find such a zip for your device, you're good to go
Else unpack your boot.img and add this add the file boot.img-zImage, repack, flash
If you don't understand any of these terms [emoji14], please google about them first, and then if you are unable to find out ask here please
Enjoy
More stuff will be added soon
Uses of Local_manifests​
Now we will learn what is Manifest. Its used for syncing source from Github,Bitbucket. Its driven via XML. Basically XML is a markup language. We can modify Rom's default.xml but it can cause of conflicts next time. So never think of editing default.xml
Now you can say how we sync our desired repo without modifying default manifest? There is a option called local manifests. By local manifests we can sync our desired repository. You can add,remove any project from default manifest without modifying default.xml
So now we will learn using local manifests-----
Open terminal and type
Code:
cd your source directory name/.repo
e.g: cd cm/.repo
Now create a new directory called local_manifests
Then type
Code:
cd local_manifests
Now type
Code:
nano localmanifest.xml
Now add whatever you want and save it via "ctrl+X"
Adding or Removing repo
Open localmanifest.xml then
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remove-project name="CyanogenMod/android_frameworks_base" />
<project path="frameworks/base" name="Anik1199/android_frameworks_base" remote="github" revision="cm-13.0"/>
This will remove project from CyanogenMod and sync from Anik1199's git.
When adding a new project that replaces an existing project, you should always remove that project before defining the replacement.
You can simply add a new project to the source code, such as when you want to add your own app to the build.
Note that when adding new projects, there are at least three parts defined:
• remote -- the name of the remote. this can be one that was defined in either the default manifest or local_manifest.xml.
• name -- the name of the git project-- for github it has the format account_name/project_name.
• path -- where the git repository should go in your local copy of the source code.
• revision -- (optional) which branch or tag to use in the repository. If this attribute is omitted, repo sync will use the revision specified by the <default ... /> tag in the default manifest.
After creating .repo/local_manifests.xml, you should be able to repo sync and the source code will be updated accordingly
In many Manifest.xml you ll find many stuff not needed by our device. Also there are files needed and that is not present in the default.xml.
Adding Projects to local_manifest.xml
So, to add projects to your local_manifest.xml for your device refer the following format that explains the same.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project path=" directory in work tree" name="name of the repository in remote" remote="name of remote defined earlier" revision="branch of the repository" />
</manifest>
If you have any doubt? See my localmanifest.xml
Device Example Used Here : Android One (Sprout)
Code:
<manifest>
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!--Devices-->
<project path="device/google/sprout4" name="CyanogenMod/android_device_google_sprout4" remote="github" revision="cm-13.0" />
<!--Devices commons-->
<project path="device/google/sprout-common" name="CyanogenMod/android_device_google_sprout-common" remote="github" revision="cm-13.0" />
<!--Kernels-->
<project path="kernel/mediatek/sprout" name="CyanogenMod/android_kernel_mediatek_sprout" remote="github" revision="cm-13.0" />
<!--Vendors-->
<project path="vendor/google" name="TheMuppets/proprietary_vendor_google" remote="github" revision="cm-13.0" />
</manifest>
This will download your device Identity needed for Rom Building
Making CM Device Tree Compatible With Your Rom For Compiling​
We learnt how to initialize build environment,learnt some git,how to use local_manifest and learnt how to build CyanogenMod. Now we will learn how to compatiable CyanogenMod device tree for other Rom. We used Android One aka sprout as a reference. Now we will try to build another CyanogenMod based Rom for sprout.
I am using Team-Radium Rom as reference. So we can start......
There are 3 files in CM Tree Which Should Be Modified.
They are,
1) cm.mk
2) cm.dependencies
3) vendorsetup.sh
We have to edit this 3 files for building Team-Radium
1) Rename cm.mk to radium.mk
As You can see That WE HAVE JUST REPLACED CM WITH Radium
Now you all must be thinking why did we rename cm.mk to radium.mk
A Simple Answer is we go to the vendor folder and check the name and replace it.
So now you must be wondering about the product name ...as in the above image only the "cm" changes to "Radium" with the same logic of the vendor name
In this case we see that Radium is the vendor ...so we rename the cm.mk to radium.mk
this same rule applies to the content inside the radium.mk too ... we first make sure that the files are available in that location .
2) Now we have to move second file "cm.dependencies"
This file will be simply renamed by Vendor Name ...
In This Case "Radium" ....so we rename it to "radium.dependencies"
3) The Last And The Final Change Required Is In The "vendorsetup.sh"
Open vendorsetup.sh and rename cm as radium and save.
Thats it!! So simple i think
Happy building
Good luck!!! :good:
Last one in case
Will soon add some common bugs and their fixes
If repo sync gives error like cannot overwrite work tree
then
Code:
$ repo sync --force-sync
For those with slow net
You can download highly compressed sources by @regalstreak and some others from here!
Unless its a one time build, i'd recommend getting the one with .repo folder, else you won't be able to easily update the source to the latest version!
Thanks guys like @OwnDroid @westcripp @##W4TCH0UT## @varun.chitre15 @CaptivateKing and many others who have inspired me about Android
Reserved
Anik_khan and akhilnarang ( My Encyclopedia of Development), love u guys. Keep doing awesome work
This is a nice guide... I think most of the people in India do not have high speed internet or continuous electricity for repo sync
This puts limitations on using own PCs for ROM building. I have seen lots of people who are using rented servers for this purpose. These servers are located somewhere in Europe or USA and one can access them (or VMs on them) remotely. These servers have internet speeds in GBs so the repo sync does not take more than 30 minutes...
I've recently started learning about ROM building and I've started with Google Cloud. Google have 2 months free service (so interested guys can start the ROM building right away without thinking about the time required for downloading 15-20 GBs )
@Anik_khan may be you can think of adding this as a tip in the OP...
@akhilnarang thanks for helping me and be ready... I'll be coming with lots of questions
Great work guys.
This will help a lot of newbies.
Add use of build scripts maybe.
P.S : Sometime I forget actual commands because of too much use of build scripts
corphish said:
Add use of build scripts maybe.
P.S : Sometime I forget actual commands because of too much use of build scripts
Click to expand...
Click to collapse
I was planning too, the guide is gonna be improved over the next few days
Sent from my A0001 using Tapatalk
a small correction in installing java procedure, you need jdk 7 to build lollipop, you mentioned as jdk7 and higher but you can't build with jdk8. awesome guide so far, regards from me.
Sent from my XT1033 using Tapatalk
Great Post , Thanks my two most favorite Brother .
I am searching for this awesome post , and you give the way with a easy way .
Awesome written . Really easily to understand.
Thanks man thanks
Thanks guys..finally got a 'noob friendly guide'..
Sent from my HM 1SW using XDA Free mobile app
OMG!! It's awesome and damn noob friendly!! It's the best guide I have ever seen!!
Thanks to you @Anik_khan & @akhilnarang
Keep your awesome work guys!!
Anik_khan said:
There are 3 files in CM Tree Which Should Be Modified.
They are,
1) cm.mk
2) cm.dependencies
3) vendorsetup.sh
Click to expand...
Click to collapse
Just add this point as a note :-
Some ROMs extensively need device dependencies in their vendor source, be sure that u add it before building (if necessary)
Sent from my A0001 using Tapatalk
Its really a nice guide, but i need your help as am stuck on how to add a device to aosp/CM source, whenever i tried to add a device, I follows all instructions but it always give me an error
Which would you like? [aosp_arm-eng] 7
build/core/product_config.mk:222: *** Can not locate config makefile for product "ha_i9500". Stop.
** Don't have a product spec for: 'ha_i9500'
** Do you have the right repo manifest?
Frostyagent said:
Its really a nice guide, but i need your help as am stuck on how to add a device to aosp/CM source, whenever i tried to add a device, I follows all instructions but it always give me an error
Which would you like? [aosp_arm-eng] 7
build/core/product_config.mk:222: *** Can not locate config makefile for product "ha_i9500". Stop.
** Don't have a product spec for: 'ha_i9500'
** Do you have the right repo manifest?
Click to expand...
Click to collapse
Rename cm.mk to ha_i9500.mk
Sent from my A0001 using Tapatalk
ujwal.p said:
Rename cm.mk to ha_i9500.mk
I have done it but still no luck and error continues to display, I want to know what am i doing wrong, I was trying all the night but bad luck
Click to expand...
Click to collapse

Categories

Resources