[GUIDE] How to build your own ROM from CM7 source

Discussion in 'Steel Droid' started by chevycam94, Feb 1, 2012.

?

Did you find this guide helpful?

  1. Very much!

    0 vote(s)
    0.0%
  2. Somewhat

    0 vote(s)
    0.0%
  3. Not at all

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    UPDATE: June 26, 2014

    This guide was working up until a couple months ago. I am no longer able to get the build to work on ANY copy of Linux Mint (if its a new setup). Existing, and already updated copies of Mint 12 will still build, but NEW setups will not. The repositories for Linux Mint 12 (last known version that could build Gingerbread) are all broken.

    I would suggest you use Ubuntu 12.04 LTS, link
    HERE. This is currently the only setup I know of that it works on today, even with a new setup. Most of the commands in here are still correct. Some will be missing, some will no longer be needed. I will have to remake the whole guide, but that will take a long time, as I dont have a lot of free time right now. Please bare with me while I get this all straightened out!







    This is a guide I will be writing to help those interested in building their own ROMs from CyanogenMod source. This tutorial will assume that the default build will be with Gingerbread. Commands are similar for Froyo, for those that still wish to build on that platform. I will try to be as detailed as possible, without confusing those that are new to the source-building side of things. This will be updated as I get more info from other devs, or as I come across tweaks and other things that many of you might find helpful.

    This is being adapted from SnkBitten's guide. I will be changing it quite a bit, but just so everyone is aware, this is the guide I used to get started, and it was the best guide ever. Im just updating the commands, and filenames to whats current, so as to keep everyone from getting a headache!


    I want to add that this guide has been updated to save YOU a lot of pain and suffering when trying to sync/build gingerbread. I spent quite a few sleepless nights and a lot of swearing, trying to figure out why I couldnt build gingerbread on my current Linux Mint 15 install.


    Installing Linux Mint 13

    I had been using Ubuntu 10.10 for the longest time, and when I was recommended to Linux Mint by another user, I installed it out of curiousity, and was very pleased with the new layout, look, and options. I would suggest that you install this version. You will be more than satisfied with it. I will be using Mint 15 as my chief OS when building for Jellybean, but when it comes to Gingerbread, I hate to say it, but you have to backdate a bit, and I found Linux Mint 12 to do the trick, and will be referenced in my examples. I have confirmed Linux Mint 13 to work as well.

    You can obtain Linux Mint 13 here:
    Linux Mint 13 (Olivia)

    Be sure to download the appropriate 32 or 64 bit version, depending on your computers capabilities. Make sure you download the full featured standard version, as it will contain just about everything you need after the initial install.

    RECOMMENDED
    I would suggest that you do NOT install "inside" Windows. Create a new partition to install Linux into (seperate from Windows). This will speed up file access a bit, and keep the two systems from messing with each other. When installed this way, you will be using the Linux GRUB bootloader to choose between Windows and Linux on startup. If you setup this way, if one system goes down, the other is still bootable with a small bootloader change, so it could save your butt!

    Also, I have allotted 210GB to my Linux system partition. I'm starting to fill that up pretty quick, but I would make sure that your system partition size for Linux is no less than 150GB, just to be on the safe side. Source takes up quite a bit, and you might want to make backup copies of your source folders, so you dont butch your work, and lose EVERYTHING!




    Installing the Android SDK


    Start by download the latest SDK for Linux from here:
    Android SDK | Android Developers
    and just save it to the default "Downloads" directory

    Current version: r22.6.4

    Once it's downloaded, open a new terminal and type:

    Code:
    cd ~
    mkdir android
    tar -zxvf ~/Downloads/android-sdk_r22.6.2-linux.tgz
    mv android-sdk-linux ~/android/sdk
    Next we need to include ~/android/sdk/tools and a couple other paths in our system path, so from the terminal type:

    Code:
    sudo gedit .bashrc
    and add the following to the bottom of the document that opens:

    and save and exit.

    We need to add a device rule to allow our computer and ADB to communicate with our phone.
    In the terminal type:

    Code:
    sudo gedit /etc/udev/rules.d/51-android.rules
    and then copy the following in to the file, save and exit.


    Now we need to install all the dependencies needed to do the builds.
    I added in PNGCrush, SchedTool, and OptiPNG as the CM build environment needs them.
    Depending on which OS you have installed, chooose 32 or 64 bit.
    in the terminal:

    (for 32 bit)

    Code:
    sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev build-essential zip curl libncurses5-dev zlib1g-dev libxml2-utils pngcrush schedtool optipng ccache
    (for 64 bit)

    Code:
    sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind lib32readline-gplv2-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32z-dev libxml2-utils pngcrush schedtool optipng ccache


    Getting the source

    Next up REPO (and GIT) is installed.
    in terminal...

    Code:
    cd ~
    mkdir bin
    Close all existing Terminal windows and open up a new one.
    In the new terminal:

    Code:
    curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo
    Next we will initialize an empty folder with a specific branch that you want to build for.
    In this case, we are using a folder called /system/. I personally have several different
    folders, gingerbread, themed, and ics.
    The /android/ folder is where all your source will be, divided into different folders if you wish.
    Here is what my layout looks like, so you get an idea (yeah, I have some custom icons):

    [​IMG]

    Code:
    cd ~
    cd android
    mkdir system
    cd ~/android/system
    repo init -u git://github.com/SteelDroid/platform_manifest.git -b gingerbread
    You will get asked to enter your Name and Email Address. Answer yes or no and eventually
    you will get repo initialized... if you were successful. Now you are going to pull the actual source.
    In the same terminal window (should be at "~/android/system/" if your following this guide), type:

    Code:
    repo sync
    This will take quite a while, depending on your connection. To give you an idea, this is how much
    space my stock gingerbread branch takes up. Since this guide was last written, I have reduced
    the size down to 1/3 of what it originally took up!

    10,313 files
    3.3 GB


    This is just the hidden repo folder where all the data is pulled to first. A copy of that data is then
    put visibly into your /system/ directory where you will actually do your work. DONT do anything to
    the hidden repo folder!

    So, after the sync, and the right files are copied over to your main directory, you will end up with a
    total of just over 7.1GB.

    Next we will need to verify the GIT tags..
    In terminal, type:

    Code:
    gpg --import
    Nothing will appear to be happening, thats ok. Paste the following into the terminal window and then press
    CTRL+D (TWICE) to save. This will return you back to the terminal command prompt.

    Now you have to get a "device setup" for each phone you want to build for. In this example, I will use sholes (the Droid 1).

    The device setup for most phones is already included in the CyanogenMod source that you spend all that time downloading. However, since support for the Droid 1 was dropped by CyanogenMod a while back, I will give you a link to a standard device setup for it. This is actually a copy of my device setup in my source that I actively build with. I will also give you a link to the vendor setup folder I have, in case you have issues getting the proprietary files yourself.

    Normally, in order to get the files needed for your vendor setup, you will have to execute some files in the device folder, which will create a new folder in "vendor" with the appropriate phone name, and will contain your proprietary files, which will be extracted. Thats next.

    Sholes device setup:
    HERE

    Sholes vendor setup:
    HERE

    If your going to pull your own proprietary files from a phone you have in your hand, you first, have to enable ADB. Generally that option is under Settings - Applications - Development

    Check USB Debugging

    Plug in your phone to your computer with the USB cable, and in terminal, type:

    Code:
    adb devices
    If everything is working, you should see something similar to this:

    If your device can NOT be detected, then you will see this:

    If you dont see your device listed, make sure you followed the step a bit above this where you had to add lines to 51-android.rules.

    To pull the proprietary files, you will need to execute setup-makefiles.sh in your device setup folder. To do that, go into your device setup folder, right click in an open area in the folder, and click "Open in Terminal". Now type:

    Code:
    . setup-makefiles.sh
    There is a space between the period and the word "setup", in case some of you get confused.

    Once that is done, stay in the same terminal, and type:

    Code:
    . extract-files.sh
    Now here, you may get a couple errors about some files not being found. Thats ok, its not perfect. Just write down which files it told you it couldn't find, if any, and manually extract them from a stock ROM (FRG83G preferred for sholes), and put the files in /vendor/motorola/sholes/proprietary/

    Thats it for the device setup!

    If you decided to download the zips I provided earlier, here is what you do with them.

    The sholes-device-setup.zip contents should be extracted to device/motorola/
    The sholes-vendor-setup.zip contents should be extracted to vendor/motorola/



    Downloading SDK Components


    Ok, this part is REQUIRED to build. Im going to recommend that you download all the components for all API levels, just to save yourself some headache if you decide you want to build for something higher later on. To do this, go to:

    /home/noah/android/sdk/tools/

    and double-click on "android", and select "Run in Terminal"

    What opens up will be the Android SDK Manager, pictured below. The screenshot shows your what components you will want to download. I only left the API 15 level open, so you know which components in each API level you need to download at the minimum. Under Tools you will of course need Android SDK Platform-tools, and for each API level, you will want the SDK Platform and Google API's. There is an Extras section not pictured, at the bottom of the list. It contains the Google USB Drivers. For Linux, you dont need them, as it will say not compatible anyway.

    For Gingerbread, the only API level you need to download is API 10 (Android 2.3.3)



    [​IMG]

    Allow everything to download and install, and your done with that part. You can exit the SDK Manager.


    OK, now that the hard part is out of the way, we can make a test build! Lets get right to it!


    Building Source

    OK, assuming you dont have a terminal window open yet, navigate to your system director for your source, which would be something like "~/android/system/", and right-click and select "Open in Terminal". Then you can proceed to type in the following (build command for sholes (Droid 1)) to start the build process!

    Code:
    . build/envsetup.sh && time brunch sholes
    When the build is finished, if successful, you will see something similar to:

    [​IMG]
    1 person likes this.
  2. Durandgir
    Offline

    Durandgir New Member

    Joined:
    Dec 6, 2011
    Messages:
    438
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Douglas, MA
    Now that i've finally have gotten my computer up and school work is out of the way I am going to try this. Thank you Chevy! I appreciate all you do for this community :D
  3. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    Your very welcome. This should really help a lot of people get started with developing. I will try to keep this guide as updated and current as possible, as I remember to do so. lol
  4. Durandgir
    Offline

    Durandgir New Member

    Joined:
    Dec 6, 2011
    Messages:
    438
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Douglas, MA
    You went into much greater detail than any of the past guides I looked at. There are some commands that I never saw. You use Mint right? I tried mint and the fan moved at top speed constantly so I went back to 11.10 for Ubuntu so there should not be any real difference between building on them if i'm correct?
  5. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    No huge difference, but interaction with the desktop is much easier on Mint, and the terminal seems to cooperate much better. I have a laptop, and I never have a fan speed issue. My fan only ramps up when the processor is under heavy load, and down to almost nothing when idle. It doesnt seem to have the manual CPU control "widget" that Ubuntu has, but I really dont think it needs one.
  6. Durandgir
    Offline

    Durandgir New Member

    Joined:
    Dec 6, 2011
    Messages:
    438
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Douglas, MA
    Yeah I do not really know why I had the fan issue but my guess is it's just my laptop. But yeah i'm not a fan of ubuntu's desktop but I have gotten used to it. so i'm following this guide and after I installed the dependecies I got this message brendan
    @brendan-Inspiron-1545:~$ sudo apt-get install sun-java7-jdkReading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package sun-java7-jdk
    brendan@brendan-Inspiron-1545:~$ sudo update-alternatives --config java
    There is only one alternative in link group java: /usr/lib/jvm/java-6-openjdk/jre/bin/java
    Nothing to configure.
    brendan@brendan-Inspiron-1545:~$ sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind lib32readline5-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev pngcrush schedtool
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Note, selecting 'libsdl1.2-dev' instead of 'libsdl-dev'
    Note, selecting 'lib32z1-dev' instead of 'lib32z-dev'
    Package lib32readline5-dev is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    However the following packages replace it:
    lib32readline-gplv2-dev


    E: Package 'lib32readline5-dev' has no installation candidate
    E: Package 'lib32readline5-dev' has no installation candidate

    is that normal? or is something wrong?
  7. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    First issue is that there is no Java 7 JDK. Its only at version 6 right now.

    Second, where it says that it cant install lib32readline5-dev, is because "lib32readline-gplv2-dev" is the new version of the package. Just swap out that package for the new one, and try again. OP has been updated to refelect the change. I overlooked that one, thanks for pointing that out.
  8. Durandgir
    Offline

    Durandgir New Member

    Joined:
    Dec 6, 2011
    Messages:
    438
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Douglas, MA
    Alright thank you Chevy :D
  9. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    Let me know if you run into any more issues.
  10. Durandgir
    Offline

    Durandgir New Member

    Joined:
    Dec 6, 2011
    Messages:
    438
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Douglas, MA
    Now I am running into a new one.

    brendan@brendan-Inspiron-1545:~$ sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind lib32readline-gplv2-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev pngcrush schedtool
    [sudo] password for brendan:
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Note, selecting 'libsdl1.2-dev' instead of 'libsdl-dev'
    Note, selecting 'lib32z1-dev' instead of 'lib32z-dev'
    Package lib32readline5-dev is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    However the following packages replace it:
    lib32readline-gplv2-dev


    E: Package 'lib32readline5-dev' has no installation candidate

    Sorry for all the issues :/
  11. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    Use this line:

    You had lib32readline-dev still in there...
  12. Durandgir
    Offline

    Durandgir New Member

    Joined:
    Dec 6, 2011
    Messages:
    438
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Douglas, MA
    Wow do I feel stupid now...thank you!

    so I got everything all up and running only to get this error

    Checking build tools versions...
    ************************************************************
    You are attempting to build with the incorrect version
    of javac.

    Your version is: /bin/bash: javac: command not found.
    The correct version is: 1.6.

    Please follow the machine setup instructions at
    http://source.android.com/download
    ************************************************************
    build/core/main.mk:134: *** stop. Stop.

    I for the life of me can not figure it out, and even googled around too no avail
  13. OsiMood
    Offline

    OsiMood New Member

    Joined:
    Feb 7, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    thanks for the post but I have a problem here, this guide is perfect when you want to compile for a phone that is supported but how do you do this for an phone that is not in the list ? and how do you determine the mandatory files ?
  14. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    OK, I know this one, but I will have to log back into my Linux install to show you what to change. It was a simple fix.

    You will have to get a device setup from a developer who has put one together for the device you want to build for. Included in that device setup will also be the extract-file.sh script needed to pull the necessary proprietary files from the device.
  15. Durandgir
    Offline

    Durandgir New Member

    Joined:
    Dec 6, 2011
    Messages:
    438
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Douglas, MA
  16. OsiMood
    Offline

    OsiMood New Member

    Joined:
    Feb 7, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Who you know anybody who could help me on that ?
    This is the first time I am trying to build CM and it seems my phone does not have a lot of love...
  17. ma700c
    Offline

    ma700c New Member

    Joined:
    Sep 21, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Slightly off topic, but have you ever successfully compiled the WiFi driver for the Droid-1? I have successfully rebuilt the Android framework and the kernel, but have not been able to recompile tiwlan_drv.ko and have it load successfully. The closest I have come is being able to do a clean build and then load the module using "insmod". But in that case as soon as I turn on WiFi, the whole system crashes. I have followed a variety of tutorials for building this, but they all seem to be oriented for one of TI's development boards.

    If you have a suggested source code link and any pointers for creating a useable WiFi driver, I would really appreciate it.

    Thanks in advance.
  18. chevycam94
    Offline

    chevycam94 Steel Droid ROM Developer Developer

    Joined:
    May 12, 2010
    Messages:
    1,375
    Likes Received:
    17
    Trophy Points:
    38
    Location:
    Central Ohio
    Thats another thing I have never touched on. I might look up how that works, just so I can cover more areas.
  19. ma700c
    Offline

    ma700c New Member

    Joined:
    Sep 21, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Great, and I'll keep following your posts on this. I've been able to successfully rebuild the module for the Broadcom bcm4329 and the Atheros AR6003, but this TI driver seems to have so many variations. I assume it is dependent on other modules (such as sdio drivers), looking at what gets loaded, I can't tell.

    Thanks again
  20. metalspring
    Offline

    metalspring New Member

    Joined:
    Jan 9, 2011
    Messages:
    2,228
    Likes Received:
    24
    Trophy Points:
    0
    Location:
    hermitage, pa
    hey chevy, mind if i add a link to this thread in my tweaks thread, giving you proper credit of course?
Search tags for this page

build cm7

,

build cm7 from source

,
build cm7 rom from source
,

building cm7

,
cm7 build
,
cm7 source code
,

compile cm7

,

compile cm7 from source

,
guide build cm7
,
how build rom android from sources linux mint
,

how to build cm7

,

how to build cm7 from source

,
how to build custom rom from source
,

how to compile cm7

,
how to make cm7