Guide to compiling (covers cm7)

Search This thread

sykopompos

Recognized Developer
Jun 26, 2008
15,322
29,134
flithydelphia
This guide is geared to people that are new to ubuntu but would like to start playing with the internals of their android device and maybe even make themselves a rom,


disclaimer: if you break your equipment well that just plain sucks

If you are new to linux or wanna learn more about ubuntu, here is a link to the ubuntu 10.10 wiki and is full of great info
http://ubuntuguide.org/wiki/Ubuntu:Maverick

So you got yourself a nice copy of Ubuntu 9.10/10.04/10.10 and you have every intention of building a rom for yourself or maybe you just wanna learn the inside workings of android, well there are a few extra steps for getting it set up in 9.10/10.04. Gonna try to make this an easy transition since most of you are coming from a windows based machine. Make sure that you have at least a 30 gb partition set up to follow along with this guide, more is better but I know some don't have the hard drive space to spare.


So let's get our hands dirty

First we need to set up java and get a few programs, but first we need to open up our software settings, this is achieved by going up to our MENU BAR, going to SYSTEM and then then ADMINISTRATION. We will then go into SOFTWARE SOURCES. On 9.10/10.04, the repository for java 5 was removed so we need to add 9.04's repository. So let's go to our second tab marked “other software” and click ADD. A small box will open up asking us to add a apt line. So we have two software lines to add individually.

(on 10.10 software sources is inside update manager, clicking settings gets you into it)
Screenshot.png



deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse


then

deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

Screenshot-1.png

Screenshot-2.png


Now, make sure that both are checked to be used in software sources and close the window. It should ask to update your sources, allow it to (insert screenshot)


Some people have problems with internal wireless cards so this might be a fix for you which was an issue for me and thankfully Garok89 had the answer. This fix works on Broadcom based cards only (including Dell wireless cards).


For the wireless card (plug in via ethernet of course)



Open up a terminal and type


sudo apt-get install bcmwl-kernel-source bcmwl-modaliases


Reboot and then enable via System>Administration>Hardware Drivers

and see if it now says that you have proprietary drivers now


gingerbread is 64 bit only
http://groups.google.com/group/android-building/browse_thread/thread/852d63ab6124c87e?pli=1


Let's open up a pretty little terminal and let's get some debs (debs are Linux distribution specific packages like we have apks in android). After entering this command it will ask you to input the "[sudo] Password for xxxxx", this is the password you use to logon. (When you type your password you will not see anything, this is for security purposes)



sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk gitg qt3-dev-tools libqt3-mt-dev eclipse valgrind


NOTE: If we want to build with a x64-bit system we must also do the following


sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev sun-java6-jdk gitg qt3-dev-tools libqt3-mt-dev eclipse valgrind pngcrush wput


Screenshot-3.png


It is quite a lot but it will download quickly depending on your internet connection, but almost all are needed, and yes, I did put in both java 5 and 6 because for some reason it helps having both installed side by side.

Screenshot-4.png

Screenshot-5.png



(don't forget to run update manager again and get your system up to date)




well while we are here we midas well set up our tool for downloading the source



REPO

Repo is a tool that makes it easier to work with Git in the context of Android. It is a almost the same as Git and we will go into the differences at a later time


we are gonna make sure that we are in our right directory so



cd ~



~ means home/user dir, so in my case it would be /home/sykopompos/ but using ~ allows us to simplify our use.



Mkdir bin



export PATH=${PATH}:~/bin



by typing echo $PATH we can see the all of what is in our path



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

to get the repo script


Screenshot-6.png



then we give it executable permissions so we can run it as a program



chmod a+x ~/bin/repo


Screenshot-7.png




Now we have repo set up we can move on to other things. Let's get going with setting up the android sdk. Let's go to the sdk's page in our web browser

http://developer.android.com/sdk/index.html

and select the newest linux version and download. When it is finished downloading open it up and extract it to your home/user folder and rename it to androidsdk for guide following ease purposes


Screenshot-8.png



next let's set up eclipse



open up eclipse, it will be in your menu bar under programming. just let it save to the workspaces folder that it defaults to and open up the help tab up on the top bar and go down to install new software

and add this line into the open text bar and type this



http://dl-ssl.google.com/android/eclipse/


Screenshot-9.png



now click add and in the box down below you will see it says developer tools. Click on the little check box and hit next. You should see android development tools hit next and follow the prompts and wait for it to download and install. You will have to agree to the terms to download, You will get a warning about unsigned content, just say yes. Once it is done click to restart Eclipse then go up to the window tab and go down to preferences, in the new window that pops up, go to android and add in where your android sdk is. Just hit ok and not apply or it will complain.


Screenshot-10.png




close out of that window than go down to in the window tab again and go into android sdk and avd manager. Go down to available packages and click on the little check box again. Download all available packages (you can prob get away without downloading anything pre 1.5/cupcake. Let that download and exit out


Screenshot-12.png




testsigning



go up to places on your desktop menu bar and go into your home folder. Press Ctrl and h together on your keyboard to show hidden folders. Anything marked with a . in front of it is hidden, we are looking for a folder name .gnome2, go into it and look for nautilus-scripts. Once inside this folder, right click on a empty space and select create document and then empty file and name it sign. Open up that empty document and copy and paste this script from dumbfaq on xda


Screenshot-14.png

Screenshot-15.png


#!/bin/bash

# Update the Loc var to where YOU stored the testsign.jar file !



SUCCESS=

Loc=~/androidsdk/tools/



for arg

do

TMP=$(ls $arg | sed 's/\(.*\)\..*/\1/')

EXT=${arg##*.}



java -classpath "$Loc"testsign.jar testsign "$arg" "$arg"-signed 2> /tmp/signTmp

SUCCESS=$?

if [ $SUCCESS -eq 1 ]

then

zenity --info --title "Sign APK" --text "signing FAILED! \n`cat /tmp/signTmp`"

exit 1

fi



mv $TMP.$EXT-signed $TMP-signed.$EXT

done



zenity --info --title "Sign APK" --text "signing completed!"



save and exit out and right click on our new script and select properties. select thru the tabs and look for a check box that says allow executing as a program. click on it and now we have a pretty little script that we can just right click on a update.zip file and sign with our test keys for flashing. but first we need to download the testsign java file and add it to our androidsdk/tools folder http://rapidshare.com/files/257189327/testsign.jar do not extract this just add it to the tools folder.


Screenshot-16.png


Last but not least, we need to set up adb



Open up a terminal (you might still have the previous one open, you can use that just make sure you are at ~/) and type



gedit .bashrc


Screenshot-17.png



paste this in the top

#AndroidDev PATH
export PATH=${PATH}:~/androidsdk/tools
export PATH=${PATH}:~/androidsdk/platform-tools


save and exit


Screenshot-18.png



we will check what our phone's vendor id is, this is helpfull to see if our phone is on the list, with all the growing numbers of new manufacturs producing android it is hard know every vendor's id so type


lsusb


while your phone is connected to see our vendor id and you will see something like this, if you have a device not listed please send me the vendor id at sykopompos@gmail.com so i can update in for others


Bus 002 Device 004: ID 0bb4:0c91 High Tech Computer Corp. (example is G2)
Screenshot-19.png


In this case the Vendor Id is “18d1″ and the Product ID is “4e12″. Please keep in mind that the Vendor ID for HTC changed from “0bb4″ to “18d1″. The older HTC phones like the G1 have a Vendor ID of “0bb4″.



in most cases as seen below we only need the vendor id and with a new device you can just c+p the line and replace the vendor id

so now we can make our rules file for connecting for adb so

sudo gedit /etc/udev/rules.d/51-android.rules

Screenshot-20.png


paste

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev"

save and exit

Screenshot-21.png


reboot your computer to have the new changes take effect otherwise adb will not be in your $PATH

let's check to make sure our device is seen by adb by typing

adb devices

it should give you info back that you are connected if you are not or it doesn't read the vendor id than it might be a little bit more complicated, note adb will not read if you have usb mass storage mounted, also need usb debugging on in settings/apllications/development on your phone

Screenshot-22.png




Now we have a complete android development environment, aren't you proud of yourself. You are well on your way to making your own custom rom


it is a wise idea to have a backup of a system dump for stock apps and to get a feel for the way android is set up and also to pull any needed files from that are easily viewed on your computer at least as refefence connect your phone in adb in the terminal type


cd ~/

mkdir stock

cd stock

adb pull /system/ ~/stock/


this will make a system dump of your systems folder of your device, a wise idea would be to make a zipped versions of it and put it someplace secure
 
Last edited:

sykopompos

Recognized Developer
Jun 26, 2008
15,322
29,134
flithydelphia
Compiling cyanogenmod 7 source

Now we work on actually pulling sources and compiling source code. Since Cyanogenmod 7 is the most popular we will work with this (as of writing 1/15/11, cm7 source does not have a Rc1 yet so non official builds after the bacon script has the KANG attached to them)

So let’s pull cm7, open a terminal and type these commands

(you can name your source folder whatever you like but for guide purposes it will be cm7)

(make sure you are at ~)

mkdir cm7

cd cm7

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

Screenshot-23.png


It will ask you to enter your name and email (this is completely optional and you can just press enter to skip)

Press y and enter to confirm that your identity is correct, press y again to enable user color

Screenshot-24.png


You will now see repo initialized in our in our cm7 folder

Now we can use repo sync (this acts as a git clone to copy the source to our local branch)

In the terminal type

repo sync

Screenshot-25.png


This will take a while to download depending on your internet connection since it is pulling in over 2gb of source code (don’t use tethering during this as it will eat up your data for the month)

(you can use -j`grep 'processor' /proc/cpuinfo | wc -l` to run at full cpu speed. -j# (# means twice the amount of cores in your computer) means jobs. I will compare this to workers, your cpu could be a dual core, quad core and/or have hyperthreading (hyperthreading means a quad core will be seen as having 8 cores, I7 are considered this) well each one of your cores is a worker so one worker would be -j2 meaning the worker will handle 2 jobs. If you tell your workers to do more jobs then they won’t be happy being overloaded just like how any worker would be and will actually be slower. Now -j`grep 'processor' /proc/cpuinfo | wc -l` means read your computer’s info and run at optimal speed, now why choose between the 2 well you might not wanna run at max speed and just wanna use only half your power so you use your computer for other things during)

Screenshot-26.png


When we are done syncing we can get back to work :)

I am gonna use vision as an example but you can change it to suit the device you are working on

connect your phone you are gonna work for adb and open a terminal or use current previous terminal

(note, the proprietary vendors have been modified to work for gingerbread so make sure you have either the most up to date cm7src build or when rc1/stable comes out on your phone to get the proper files)

(this assumes you are using a previous and are in cm7)

cd device

cd htc/vision

bash extract-files.sh

Screenshot-27.png


cd ~/cm7

cd vendor/cyanogen/

bash get-rommanager

cd ~/cm7

Screenshot-31.png


We now have pull the proprietary files for our phone so we can inject them into our build along with rom manager since it is required and will fail the build if you don’t

(if you look in your cm7 source you will now see inside vendor a folder called htc (our manufactor, if you are working on a samsung or motorola you will see that) and inside it you will see your device)

We are actually now ready to build so in our terminal

source build/envsetup.sh

lunch cyanogen_vision-eng

make clean

make bacon -j`grep 'processor' /proc/cpuinfo | wc -l`

Screenshot-28.png


Screenshot-29.png


Screenshot-30.png


Now our build is compiling

(the lunch command pulls target specific info so there is no need for a buildspec.mk to be made as lunch does this for us)

(always make clean between builds to remove old compiled files and make sure you have a fully working build with each update, it takes a bit longer but it is worth it)

(make bacon is a script that runs make otapackage and the squisher script which uses pngcrush to cut down the size and also removes unneeded things added by doing a -eng build, it also resigns it)

When your build is complete you should have a update-cm-7.0.0-RC0-vision-KANG-signed.zip in your cm7/out/target/product folder, this is your new build.

Screenshot-32.png


Screenshot-33.png


Congratulations on your first build from cm7 source :)

Now for a new build you would repo sync again, make clean and make bacon again
 
Last edited:

sykopompos

Recognized Developer
Jun 26, 2008
15,322
29,134
flithydelphia
Kernel compiling

We are gonna be pulling the cyanogenmod htc msm 7x30 kernel source, this covers ace, vision and glacier

so let’s open up a terminal and clone the kernel source so we can work with it

cd ~/

mkdir kernel

cd kernel

git clone git://github.com/CyanogenMod/htc-kernel-msm7x30.git

cd htc-kernel-msm7x30

Screenshot-34.png

Screenshot-35.png


We now have our source pulled and now need to set up our cross-compilier so we can make our kernel

export CROSS_COMPILE=~/cm7/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

export ARCH=arm

Now have our cross compilier toolchain set up and will need to now tell it what to build, I find that make menuconfig is just plain ugly and rough to work with so

make xconfig

Screenshot-36.png

Screenshot-37.png


This will load a nice menu UI for us to work with, we are not gonna get into modifying the kernel but just a default config so go up to file and click load and select arch, then arm, then configs.

select cyanogen_vision_defconfig and click open, this will load the default cyanogen kernel config and is what you will find in a cm7 build (or glacier or ace depending what you are building for)

You can just click the x button in the corner to close it and collect save changes

Screenshot-38.png


Now we can compile our kernel, we can us the -j command like before to speed it up

make -j`grep 'processor' /proc/cpuinfo | wc -l`

Screenshot-39.png


Once the kernel compiles we have to grab our zimage and our wifi module (the couple lines up will show you the modules made and the location)

Screenshot-40.png


The zimage is our kernel and it can it can be found at /kernel/htc-kernel-msm7x30/arch/arm/boot/ and our wifi module name as bcm4329.ko (modules have a .ko extension) is found at /kernel/htc-kernel-msm7x30/drivers/net/wireless/bcm4329/

These are the only things we need to worry about. Now you can adb push the wifi module onto your phone and fastboot the zimage or we can have it built into our build by going to cm7/device/htc/vision/ and replacing the kernel with our zimage (will need to rename zimage to kernel) and putting our wifi module in modules and overwriting the one currently there (Make a backup of the stock kernel and wifi modules to replace your’s just in case)

Now you have your own kernel and you can compile it into your build :)

device.png
 
Last edited by a moderator:

persiansown

Retired Recognized Developer
Jan 12, 2007
877
717
Instead of make bacon -j`grep 'processor' /proc/cpuinfo | wc -l`, you can type mka bacon. mka uses schedtool (may have to install the package) as well as auto doing the correct number of jobs.

And after you do a ". build/envsetup.sh", you can just type reposync, rather than repo sync do do a faster sync of the repos because it will do a -j10. (repo supports multiple simultaneous jobs (ie -j#)
 

bobsbbq

Senior Member
Jun 8, 2008
5,208
356
Cleveland, TX
Wow a lot to learn. Now I have to kick the dust off my Linux and see what version it is and how much of a partition I made. Now I have something to do along with being a flash junkie.

I want to really Thank You for this guide. I really commend those that try to help others. Some people might not be able to do this no matter how easy you make it. But some including myself will find this information very useful.

A big thanks.
 
  • Like
Reactions: sykopompos

sykopompos

Recognized Developer
Jun 26, 2008
15,322
29,134
flithydelphia
Hmm Not sure what ubuntu 10.04 is? 32 or 64 bit? Also can I make a extra partition for this as the original one for ubuntu is only 15 mb? And do I make it ext4 or Fat32?

You can make it a new partition but you will have to change all the commands to the new partition so it might be more hassle than it is worth. Make it ext 4 for speed cause it is a native linux file system

Sent from my HTC Vision using XDA App
 

nickwarn

Senior Member
Aug 4, 2010
2,736
580
Ronneby
The link in the first posst to ubuntu pocket guide is not working . It gets you to 4shared,but when trying to download it i just get that link is broken
 

kdb424

Senior Member
Dec 28, 2010
816
353
33
Pittsburgh
I've built a rom for my incredible. I haven't flashed it as I went to work, and by the time I came back it was out of date lol. I ran it in a 32 bit VM, so I don't know what's up with needing 64 bit, as it's not what I used and got a good build I believe.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 35
    This guide is geared to people that are new to ubuntu but would like to start playing with the internals of their android device and maybe even make themselves a rom,


    disclaimer: if you break your equipment well that just plain sucks

    If you are new to linux or wanna learn more about ubuntu, here is a link to the ubuntu 10.10 wiki and is full of great info
    http://ubuntuguide.org/wiki/Ubuntu:Maverick

    So you got yourself a nice copy of Ubuntu 9.10/10.04/10.10 and you have every intention of building a rom for yourself or maybe you just wanna learn the inside workings of android, well there are a few extra steps for getting it set up in 9.10/10.04. Gonna try to make this an easy transition since most of you are coming from a windows based machine. Make sure that you have at least a 30 gb partition set up to follow along with this guide, more is better but I know some don't have the hard drive space to spare.


    So let's get our hands dirty

    First we need to set up java and get a few programs, but first we need to open up our software settings, this is achieved by going up to our MENU BAR, going to SYSTEM and then then ADMINISTRATION. We will then go into SOFTWARE SOURCES. On 9.10/10.04, the repository for java 5 was removed so we need to add 9.04's repository. So let's go to our second tab marked “other software” and click ADD. A small box will open up asking us to add a apt line. So we have two software lines to add individually.

    (on 10.10 software sources is inside update manager, clicking settings gets you into it)
    Screenshot.png



    deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse


    then

    deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

    Screenshot-1.png

    Screenshot-2.png


    Now, make sure that both are checked to be used in software sources and close the window. It should ask to update your sources, allow it to (insert screenshot)


    Some people have problems with internal wireless cards so this might be a fix for you which was an issue for me and thankfully Garok89 had the answer. This fix works on Broadcom based cards only (including Dell wireless cards).


    For the wireless card (plug in via ethernet of course)



    Open up a terminal and type


    sudo apt-get install bcmwl-kernel-source bcmwl-modaliases


    Reboot and then enable via System>Administration>Hardware Drivers

    and see if it now says that you have proprietary drivers now


    gingerbread is 64 bit only
    http://groups.google.com/group/android-building/browse_thread/thread/852d63ab6124c87e?pli=1


    Let's open up a pretty little terminal and let's get some debs (debs are Linux distribution specific packages like we have apks in android). After entering this command it will ask you to input the "[sudo] Password for xxxxx", this is the password you use to logon. (When you type your password you will not see anything, this is for security purposes)



    sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk gitg qt3-dev-tools libqt3-mt-dev eclipse valgrind


    NOTE: If we want to build with a x64-bit system we must also do the following


    sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev sun-java6-jdk gitg qt3-dev-tools libqt3-mt-dev eclipse valgrind pngcrush wput


    Screenshot-3.png


    It is quite a lot but it will download quickly depending on your internet connection, but almost all are needed, and yes, I did put in both java 5 and 6 because for some reason it helps having both installed side by side.

    Screenshot-4.png

    Screenshot-5.png



    (don't forget to run update manager again and get your system up to date)




    well while we are here we midas well set up our tool for downloading the source



    REPO

    Repo is a tool that makes it easier to work with Git in the context of Android. It is a almost the same as Git and we will go into the differences at a later time


    we are gonna make sure that we are in our right directory so



    cd ~



    ~ means home/user dir, so in my case it would be /home/sykopompos/ but using ~ allows us to simplify our use.



    Mkdir bin



    export PATH=${PATH}:~/bin



    by typing echo $PATH we can see the all of what is in our path



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

    to get the repo script


    Screenshot-6.png



    then we give it executable permissions so we can run it as a program



    chmod a+x ~/bin/repo


    Screenshot-7.png




    Now we have repo set up we can move on to other things. Let's get going with setting up the android sdk. Let's go to the sdk's page in our web browser

    http://developer.android.com/sdk/index.html

    and select the newest linux version and download. When it is finished downloading open it up and extract it to your home/user folder and rename it to androidsdk for guide following ease purposes


    Screenshot-8.png



    next let's set up eclipse



    open up eclipse, it will be in your menu bar under programming. just let it save to the workspaces folder that it defaults to and open up the help tab up on the top bar and go down to install new software

    and add this line into the open text bar and type this



    http://dl-ssl.google.com/android/eclipse/


    Screenshot-9.png



    now click add and in the box down below you will see it says developer tools. Click on the little check box and hit next. You should see android development tools hit next and follow the prompts and wait for it to download and install. You will have to agree to the terms to download, You will get a warning about unsigned content, just say yes. Once it is done click to restart Eclipse then go up to the window tab and go down to preferences, in the new window that pops up, go to android and add in where your android sdk is. Just hit ok and not apply or it will complain.


    Screenshot-10.png




    close out of that window than go down to in the window tab again and go into android sdk and avd manager. Go down to available packages and click on the little check box again. Download all available packages (you can prob get away without downloading anything pre 1.5/cupcake. Let that download and exit out


    Screenshot-12.png




    testsigning



    go up to places on your desktop menu bar and go into your home folder. Press Ctrl and h together on your keyboard to show hidden folders. Anything marked with a . in front of it is hidden, we are looking for a folder name .gnome2, go into it and look for nautilus-scripts. Once inside this folder, right click on a empty space and select create document and then empty file and name it sign. Open up that empty document and copy and paste this script from dumbfaq on xda


    Screenshot-14.png

    Screenshot-15.png


    #!/bin/bash

    # Update the Loc var to where YOU stored the testsign.jar file !



    SUCCESS=

    Loc=~/androidsdk/tools/



    for arg

    do

    TMP=$(ls $arg | sed 's/\(.*\)\..*/\1/')

    EXT=${arg##*.}



    java -classpath "$Loc"testsign.jar testsign "$arg" "$arg"-signed 2> /tmp/signTmp

    SUCCESS=$?

    if [ $SUCCESS -eq 1 ]

    then

    zenity --info --title "Sign APK" --text "signing FAILED! \n`cat /tmp/signTmp`"

    exit 1

    fi



    mv $TMP.$EXT-signed $TMP-signed.$EXT

    done



    zenity --info --title "Sign APK" --text "signing completed!"



    save and exit out and right click on our new script and select properties. select thru the tabs and look for a check box that says allow executing as a program. click on it and now we have a pretty little script that we can just right click on a update.zip file and sign with our test keys for flashing. but first we need to download the testsign java file and add it to our androidsdk/tools folder http://rapidshare.com/files/257189327/testsign.jar do not extract this just add it to the tools folder.


    Screenshot-16.png


    Last but not least, we need to set up adb



    Open up a terminal (you might still have the previous one open, you can use that just make sure you are at ~/) and type



    gedit .bashrc


    Screenshot-17.png



    paste this in the top

    #AndroidDev PATH
    export PATH=${PATH}:~/androidsdk/tools
    export PATH=${PATH}:~/androidsdk/platform-tools


    save and exit


    Screenshot-18.png



    we will check what our phone's vendor id is, this is helpfull to see if our phone is on the list, with all the growing numbers of new manufacturs producing android it is hard know every vendor's id so type


    lsusb


    while your phone is connected to see our vendor id and you will see something like this, if you have a device not listed please send me the vendor id at sykopompos@gmail.com so i can update in for others


    Bus 002 Device 004: ID 0bb4:0c91 High Tech Computer Corp. (example is G2)
    Screenshot-19.png


    In this case the Vendor Id is “18d1″ and the Product ID is “4e12″. Please keep in mind that the Vendor ID for HTC changed from “0bb4″ to “18d1″. The older HTC phones like the G1 have a Vendor ID of “0bb4″.



    in most cases as seen below we only need the vendor id and with a new device you can just c+p the line and replace the vendor id

    so now we can make our rules file for connecting for adb so

    sudo gedit /etc/udev/rules.d/51-android.rules

    Screenshot-20.png


    paste

    SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
    SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″
    SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev"

    save and exit

    Screenshot-21.png


    reboot your computer to have the new changes take effect otherwise adb will not be in your $PATH

    let's check to make sure our device is seen by adb by typing

    adb devices

    it should give you info back that you are connected if you are not or it doesn't read the vendor id than it might be a little bit more complicated, note adb will not read if you have usb mass storage mounted, also need usb debugging on in settings/apllications/development on your phone

    Screenshot-22.png




    Now we have a complete android development environment, aren't you proud of yourself. You are well on your way to making your own custom rom


    it is a wise idea to have a backup of a system dump for stock apps and to get a feel for the way android is set up and also to pull any needed files from that are easily viewed on your computer at least as refefence connect your phone in adb in the terminal type


    cd ~/

    mkdir stock

    cd stock

    adb pull /system/ ~/stock/


    this will make a system dump of your systems folder of your device, a wise idea would be to make a zipped versions of it and put it someplace secure
    19
    Compiling cyanogenmod 7 source

    Now we work on actually pulling sources and compiling source code. Since Cyanogenmod 7 is the most popular we will work with this (as of writing 1/15/11, cm7 source does not have a Rc1 yet so non official builds after the bacon script has the KANG attached to them)

    So let’s pull cm7, open a terminal and type these commands

    (you can name your source folder whatever you like but for guide purposes it will be cm7)

    (make sure you are at ~)

    mkdir cm7

    cd cm7

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

    Screenshot-23.png


    It will ask you to enter your name and email (this is completely optional and you can just press enter to skip)

    Press y and enter to confirm that your identity is correct, press y again to enable user color

    Screenshot-24.png


    You will now see repo initialized in our in our cm7 folder

    Now we can use repo sync (this acts as a git clone to copy the source to our local branch)

    In the terminal type

    repo sync

    Screenshot-25.png


    This will take a while to download depending on your internet connection since it is pulling in over 2gb of source code (don’t use tethering during this as it will eat up your data for the month)

    (you can use -j`grep 'processor' /proc/cpuinfo | wc -l` to run at full cpu speed. -j# (# means twice the amount of cores in your computer) means jobs. I will compare this to workers, your cpu could be a dual core, quad core and/or have hyperthreading (hyperthreading means a quad core will be seen as having 8 cores, I7 are considered this) well each one of your cores is a worker so one worker would be -j2 meaning the worker will handle 2 jobs. If you tell your workers to do more jobs then they won’t be happy being overloaded just like how any worker would be and will actually be slower. Now -j`grep 'processor' /proc/cpuinfo | wc -l` means read your computer’s info and run at optimal speed, now why choose between the 2 well you might not wanna run at max speed and just wanna use only half your power so you use your computer for other things during)

    Screenshot-26.png


    When we are done syncing we can get back to work :)

    I am gonna use vision as an example but you can change it to suit the device you are working on

    connect your phone you are gonna work for adb and open a terminal or use current previous terminal

    (note, the proprietary vendors have been modified to work for gingerbread so make sure you have either the most up to date cm7src build or when rc1/stable comes out on your phone to get the proper files)

    (this assumes you are using a previous and are in cm7)

    cd device

    cd htc/vision

    bash extract-files.sh

    Screenshot-27.png


    cd ~/cm7

    cd vendor/cyanogen/

    bash get-rommanager

    cd ~/cm7

    Screenshot-31.png


    We now have pull the proprietary files for our phone so we can inject them into our build along with rom manager since it is required and will fail the build if you don’t

    (if you look in your cm7 source you will now see inside vendor a folder called htc (our manufactor, if you are working on a samsung or motorola you will see that) and inside it you will see your device)

    We are actually now ready to build so in our terminal

    source build/envsetup.sh

    lunch cyanogen_vision-eng

    make clean

    make bacon -j`grep 'processor' /proc/cpuinfo | wc -l`

    Screenshot-28.png


    Screenshot-29.png


    Screenshot-30.png


    Now our build is compiling

    (the lunch command pulls target specific info so there is no need for a buildspec.mk to be made as lunch does this for us)

    (always make clean between builds to remove old compiled files and make sure you have a fully working build with each update, it takes a bit longer but it is worth it)

    (make bacon is a script that runs make otapackage and the squisher script which uses pngcrush to cut down the size and also removes unneeded things added by doing a -eng build, it also resigns it)

    When your build is complete you should have a update-cm-7.0.0-RC0-vision-KANG-signed.zip in your cm7/out/target/product folder, this is your new build.

    Screenshot-32.png


    Screenshot-33.png


    Congratulations on your first build from cm7 source :)

    Now for a new build you would repo sync again, make clean and make bacon again
    17
    Kernel compiling

    We are gonna be pulling the cyanogenmod htc msm 7x30 kernel source, this covers ace, vision and glacier

    so let’s open up a terminal and clone the kernel source so we can work with it

    cd ~/

    mkdir kernel

    cd kernel

    git clone git://github.com/CyanogenMod/htc-kernel-msm7x30.git

    cd htc-kernel-msm7x30

    Screenshot-34.png

    Screenshot-35.png


    We now have our source pulled and now need to set up our cross-compilier so we can make our kernel

    export CROSS_COMPILE=~/cm7/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

    export ARCH=arm

    Now have our cross compilier toolchain set up and will need to now tell it what to build, I find that make menuconfig is just plain ugly and rough to work with so

    make xconfig

    Screenshot-36.png

    Screenshot-37.png


    This will load a nice menu UI for us to work with, we are not gonna get into modifying the kernel but just a default config so go up to file and click load and select arch, then arm, then configs.

    select cyanogen_vision_defconfig and click open, this will load the default cyanogen kernel config and is what you will find in a cm7 build (or glacier or ace depending what you are building for)

    You can just click the x button in the corner to close it and collect save changes

    Screenshot-38.png


    Now we can compile our kernel, we can us the -j command like before to speed it up

    make -j`grep 'processor' /proc/cpuinfo | wc -l`

    Screenshot-39.png


    Once the kernel compiles we have to grab our zimage and our wifi module (the couple lines up will show you the modules made and the location)

    Screenshot-40.png


    The zimage is our kernel and it can it can be found at /kernel/htc-kernel-msm7x30/arch/arm/boot/ and our wifi module name as bcm4329.ko (modules have a .ko extension) is found at /kernel/htc-kernel-msm7x30/drivers/net/wireless/bcm4329/

    These are the only things we need to worry about. Now you can adb push the wifi module onto your phone and fastboot the zimage or we can have it built into our build by going to cm7/device/htc/vision/ and replacing the kernel with our zimage (will need to rename zimage to kernel) and putting our wifi module in modules and overwriting the one currently there (Make a backup of the stock kernel and wifi modules to replace your’s just in case)

    Now you have your own kernel and you can compile it into your build :)

    device.png
    6
    Instead of make bacon -j`grep 'processor' /proc/cpuinfo | wc -l`, you can type mka bacon. mka uses schedtool (may have to install the package) as well as auto doing the correct number of jobs.

    And after you do a ". build/envsetup.sh", you can just type reposync, rather than repo sync do do a faster sync of the repos because it will do a -j10. (repo supports multiple simultaneous jobs (ie -j#)
    1
    Wow a lot to learn. Now I have to kick the dust off my Linux and see what version it is and how much of a partition I made. Now I have something to do along with being a flash junkie.

    I want to really Thank You for this guide. I really commend those that try to help others. Some people might not be able to do this no matter how easy you make it. But some including myself will find this information very useful.

    A big thanks.