[GUIDE][Step-by-Step] Build ROM from source

What is your favorite custom ROM?

  • CyanogenMod

    Votes: 507 49.0%
  • AOKP

    Votes: 45 4.3%
  • Paranoid Android

    Votes: 138 13.3%
  • PAC

    Votes: 64 6.2%
  • Omni

    Votes: 49 4.7%
  • Other

    Votes: 232 22.4%

  • Total voters
    1,035
Search This thread

madphone

Senior Member
Apr 21, 2011
1,277
1,224
Samsung Galaxy S23 Ultra
one simple question: if i want to update my cm rom and repo sync - what is the best and fastest way to build it AND having the new built-date in settings? if i rebuild the rom the same way compiling it the very first time i end up with the old date in settings/info. Is the only way to "make clean" and will this take ages again to compile?
 

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
one simple question: if i want to update my cm rom and repo sync - what is the best and fastest way to build it AND having the new built-date in settings? if i rebuild the rom the same way compiling it the very first time i end up with the old date in settings/info. Is the only way to "make clean" and will this take ages again to compile?

do cmka, it does make clean and make using CM's optimized make, only takes a few seconds to make clean and builds a bit faster that vanilla make IMHO, if you're using ccache then a new build won't take too long.
 
  • Like
Reactions: madphone

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
So apparently gcc is looking for a cm-10.2 folder for kernel prebuilts (I'm building CM 11.0). How do I change this?

Code:
/home/ron/android/cm-10.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin/arm-eabi-gcc: No such file or directory
  GEN     /home/ron/out/cm-11.0/target/product/geeb/obj/KERNEL_OBJ/Makefile
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  Using /home/ron/android/cm-11.0/kernel/lge/geeb as source for kernel
  CC      scripts/mod/empty.o
/home/ron/android/cm-10.2/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin/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[1]: *** [sub-make] Error 2
make[1]: Leaving directory `/home/ron/android/cm-11.0/kernel/lge/geeb'
make: *** [TARGET_KERNEL_BINARIES] Error 2
make: *** Waiting for unfinished jobs....

I've grepped for "cm-10.2" but came up empty.
 

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
Hey everyone: CyanogenMod 11.0 M1 – Nexus Edition

WTF? I still haven't got a build to go through :( Close though :)

Has anyone else gotten this error?

Code:
/home/ron/android/cm-11.0/out/host/linux-x86/obj/SHARED_LIBRARIES/libgccdemangle_intermediates/cp-demangle.o: file not recognized: File truncated
collect2: ld returned 1 exit status
make: *** [/home/ron/android/cm-11.0/out/host/linux-x86/obj/lib/libgccdemangle.so] Error 1
make: *** Waiting for unfinished jobs....

NM previous build was interrupted by a circuit breaker tripping... old wiring in the house. If this finishes I'll have the equivalent of the M1 build for LGOG, with a couple of added goodies for our hardware. I'll let you guys know soon. Had to wipe my ccache so it may take a little longer.
 
Last edited:

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
So my machine is hung at

Code:
Install: /home/ron/android/cm-11.0/out/target/product/geeb/system/app/Email.apk

while building CM 11. One core is pegged and the HDD is going crazy. RAM is maxed (2 GB) and swap is at 2 GB usage. Has anyone else seen this, and wtf?
 

cdub50

Senior Member
Jul 21, 2007
467
204
So my machine is hung at

Code:
Install: /home/ron/android/cm-11.0/out/target/product/geeb/system/app/Email.apk

while building CM 11. One core is pegged and the HDD is going crazy. RAM is maxed (2 GB) and swap is at 2 GB usage. Has anyone else seen this, and wtf?

Yeah that is normal I allocate 4 gigs of memory to my build VM and 20 GB of swap. If you have already created a swap partition you can use gparted to create a new swap partition that's what I did had originally made swap 4 gb, but was running out of memory and swap so I increased it to 20 GB. Poor mans memory ftw.
 

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
My build finished, but the ota it created is named cm_geeb-ota-88b17e8c3e.zip and it won't boot. ADB won't grab a logcat and it just hangs at the google screen. adb -d logcat>mylogfile.txt sits there waiting for device. I can reboot to bootloader/recovery fine
Can anyone tell me where it's going wrong?
 

brothaedhung

Senior Member
Nov 30, 2011
551
857
Seattle-ish
Google Pixel 7
My build finished, but the ota it created is named cm_geeb-ota-88b17e8c3e.zip and it won't boot. ADB won't grab a logcat and it just hangs at the google screen. adb -d logcat>mylogfile.txt sits there waiting for device. I can reboot to bootloader/recovery fine
Can anyone tell me where it's going wrong?

With some builds there are 2 zip files in your output directory. You should flash the one with "unofficial" in the filename if there is one, not the one with "OTA".
 

spaceman860

Senior Member
Jan 11, 2012
2,642
3,278
What's the difference between the OTA and the unofficial zips that are made?

Sent from my NEXUS 5
 

Haze028

Senior Member
Jun 29, 2011
435
615
What's the difference between the OTA and the unofficial zips that are made?

Sent from my NEXUS 5

With some builds there are 2 zip files in your output directory. You should flash the one with "unofficial" in the filename if there is one, not the one with "OTA".

I'm not sure of the actual difference between the two, but you should still be able to boot with the ota zip. If you 'make otapackage' I'm not sure that it gives you a second zip file, may only be the ota one, which should still work(that's how i made/posted most of my roms, just renamed the zip)

As for the rom not booting above, try 1. using 'make -j# bacon' instead of 'otapackage' if you aren't already. that should give you the 'unofficial' zip
2. check the repo you are using for kernel/ try a new one. None booting rom ususally, is a kernel issue
 

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
I'm not sure of the actual difference between the two, but you should still be able to boot with the ota zip. If you 'make otapackage' I'm not sure that it gives you a second zip file, may only be the ota one, which should still work(that's how i made/posted most of my roms, just renamed the zip)

As for the rom not booting above, try 1. using 'make -j# bacon' instead of 'otapackage' if you aren't already. that should give you the 'unofficial' zip
2. check the repo you are using for kernel/ try a new one. None booting rom ususally, is a kernel issue

Thanks guys, I've got a booting ROM now but the video drivers don't work. The CM logo on the boot screen is yellow, then I get a black screen although vibration works. I think I might be missing the adreno drivers (I forked chad's kernel_msm). I've flashed a few alternate kernels and the display keeps blanking after the yellow boot animation except with houstonn's adreno kernel, which boots, but hangs at Starting apps. (after rebuilding dalvik) . Help?

I'm using chad's kernel_msm, haze's device, device-common and vendor
 
Last edited:

Haze028

Senior Member
Jun 29, 2011
435
615
Thanks guys, I've got a booting ROM now but the video drivers don't work. The CM logo on the boot screen is yellow, then I get a black screen although vibration works. I think I might be missing the adreno drivers (I forked chad's kernel_msm). I've flashed a few alternate kernels and the display keeps blanking after the yellow boot animation except with houstonn's adreno kernel, which boots, but hangs at Starting apps. (after rebuilding dalvik) . Help?

I'm using chad's kernel_msm, haze's device, device-common and vendor

Have you tried building with houstonn adreno kernel, instead of flashing it after.

also you can try the kernel on my github. It's chads kernel but from a while back, seems to have all things working well.

Also, switch over to chad's vendor repo. I havn't updated the vendor repo on my github since i forked it, and i beleive it is due
 

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
Have you tried building with houstonn adreno kernel, instead of flashing it after.

also you can try the kernel on my github. It's chads kernel but from a while back, seems to have all things working well.

Also, switch over to chad's vendor repo. I havn't updated the vendor repo on my github since i forked it, and i beleive it is due

I've got a booting ROM at this point, but wifi is broken. I'm trying chad's vendor repo next
 

madphone

Senior Member
Apr 21, 2011
1,277
1,224
Samsung Galaxy S23 Ultra
Is anyone here building omni-roms at the moment? Every ROM i build has prebloems vith google voice search. whenever i try to use the mic for any kind of search it gets stuck on "initializing". Any ideas what went wrong. My last build was from yesterday (android 4.2.2). No errors while compiling.
 

ronasimi

Senior Member
Sep 28, 2011
501
235
Ontario
github.com
All of a sudden, as of today 12/16/2013 my CM 11.0 builds are failing at installing modules. No errors are listed. WTF?

Last line of output:

Code:
mdpath=`find /home/ron/android/cm-11.0/out/target/product/geeb/system/lib/modules -type f -name modules.order`; if [ "$mdpath" != "" ];then mpath=`dirname $mdpath`; rm -rf $mpath; fi

it looks like it might be an error in the build script, can anyone help?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 111
    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 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 gee and its repos can be found here https://github.com/TeamPlaceholder

    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
    Code:
    sudo apt-get install oracle-java6-installer

    Installing required packages
    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>
    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 http://commondatastorage.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

    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 :p 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
    57
    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.
    Note: The local path for your phone's repos should be device/manufacturer/codename, vendor/manufacturer/codename, kernel/manufacturer/codename regardless of method chosen.

    Git Clone
    Git clone is a one time download of a specific repo to the directory indicated and is not affected when a repo sync is run. 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.
    This method is used AFTER the inital rom source sync. Preform a repo sync before cloning repos
    Code:
    git clone [B][COLOR=DarkOrange]repo[/COLOR][/B] -b [B][COLOR=Red]branch[/COLOR][/B] [B][COLOR=Lime]destination-path[/COLOR][/B]
    here is and example for the vendor repo for the E973 from TeamPlaceHolder

    Local Manifest
    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. Be wary making edits locally to the repos you list as a repo sync may overwrite your changes.
    This method is used BEFORE the initial rom sync. This gets your device source during the first repo sync
    Code:
    mkdir .repo/local_manifests
    Code:
    touch .repo/local_manifests/local_manifest.xml
    Code:
    nano .repo/local_manifests/local_manifest.xml

    Add these lines:
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>
    <remote name="name-for-remote" fetch="remote-url" />
    <project path="destination-folder-path" name="repo-location" remote="name-for-remote" revision="branch" />
    </manifest>
    name-for-remote - Any name you want to give to identify the url where your repos are stored
    remote-url - The url for the remote location your repos are stored
    destination-folder-path - Where do you want this repo stored locally
    repo-location - Where on the remote url is your repo stored
    branch - The branch of the remote repo you are using
    **You will need a project line for each repo you wish to add to the source. **

    Here is an example 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-update" />
    <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>
    30
    Preparing Source

    Preparing Source
    ROM specific setup instructions prior to building. All source should be downloaded already.
    All ROM setup is fairly similar,
    1. You must add your device to the ROM's vendor repo(vendor/cm or vendor/aokp) This process is slightly different per rom. Look at how other devices are added in the vendor repo and emulate those.
    2. A ROM specific makefile, again look at how other devices are added.
    3. If building AOSP based ROMs, a pre-built kernel is generally required. Look here for instructions on how to compile a kernel separately.

    Here are examples of how to set up AOKP or Carbon to build. Device used in example is Optimus G.
    Manufacturer and codename MUST be updated to reflect your device.
    AOKP
    Code:
    nano vendor/aokp/vendorsetup.sh
    Add this line
    add_lunch_combo aokp_geeb-userdebug
    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
    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 \
    Save and exit by pressing ctrl+x, selecting Y then enter.
    CarbonDev
    Code:
    nano vendor/carbon/vendorsetup.sh
    Add this line
    add_lunch_combo carbon_geeb-userdebug


    Once your device has been added you're ready to build! Go back to the OP and complete the guide from where you left off.
    5
    good stuff haze :)
    2
    What bout building ROMs based on LG source? I'd rather see more LG based ROMs because the camera quality is higher, and a lot of AOSP/AOKP ROMs feel more or less the same.

    Seriously ? Find me LG source to build a rom and I'll make you one.

    @moderator.
    Btw, This post and the previous should be removed, that thread locked to prevent post like these and pinned. thanks.