Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Tutorial][Oct. 19, 2011] Compile AOSP Gingerbread on Ubuntu

OP dastin1015

24th July 2011, 07:57 PM   |  #1  
dastin1015's Avatar
OP Recognized Developer / Contributor
Flag Chula Vista, CA
Thanks Meter: 10,474
 
3,797 posts
Join Date:Joined: Dec 2010
Donate to Me
More
To compile Gingerbread on Ubuntu I'm going to first give you steps to set up your computer to get this thing rolling. This will NOT make a fully functional ROM, but give you a place to start.

Note: The source is approximately 2.6GB in size. You will need 10GB free to complete the build.

These instructions are compiled by me from different sources such as source.android.com and Cyanogen Wiki.

1) You need the following:
  • Python 2.4 -- 2.7, which you can download from python.org.
    Or:
    Code:
    $ sudo add-apt-repository ppa:fkrull/deadsnakes
    $ sudo apt-get update
    $ sudo apt-get install python2.5
  • JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.com.
    Or:
    Code:
    $ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
    $ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
    $ sudo apt-get update
    $ sudo apt-get install sun-java6-jdk
  • Git 1.5.4 or newer. You can find it at git-scm.com.
    Or:
    Code:
    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install git-core
  • Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc. Download from valgrind.org.
    Or:
    Code:
    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install valgrind

2) Install required packages.
Code:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib64ncurses5-dev \
x11proto-core-dev libx11-dev lib64readline5-dev lib64z-dev \
libgl1-mesa-dev g++-multilib tofrodos
3) Configure your USB.
Code:
$ gksudo gedit /etc/udev/rules.d/51-android.rules
Inside of this blank text file insert:

Code:
#Acer
SUBSYSTEM==usb, SYSFS{idVendor}==0502, MODE=0666

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#ZTE
SUBSYSTEM==usb, SYSFS{idVendor}==19D2, MODE=0666
4) Save the file and close it and then issue this command:
Code:
$ sudo chmod a+r /etc/udev/rules.d/51-android.rules
5) Download the repo:
Code:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
6) Initialize the repo:
Code:
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
$ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
7) When prompted, please configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.

8) Gather the files:
Code:
$ repo sync
9) Verify and insert public key block:
Code:
$ gpg --import
Code:
-----BEGIN PGP PUBLIC KEY BLOCK-----
    Version: GnuPG v1.4.2.2 (GNU/Linux)  
    mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
    lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
    8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
    u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
    wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
    /HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
    jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
    MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
    b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv
    aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k
    cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX
    gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI
    2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl
    QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up
    hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk
    C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX
    LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+
    OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M
    pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
    KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
    N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
    vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
    G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
    hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
    EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
    =Wi5D 
    -----END PGP PUBLIC KEY BLOCK-----
10) After copying and pasting the public key block press Crtl+D to end the input.

11) Compiling:
Code:
$ source build/envsetup.sh
Or:
Code:
$ . build/envsetup.sh
12) Issue:
Code:
$ lunch
13) Pick your poison.

14) Now issue:
Code:
$ make
15) Now just cross your fingers and hope it all works out!

16) Issue this command to create a flashable zip:
Code:
$ make otapackage
Or if you want to test on an emulator:
Code:
$ emulator
17) If all went well you can either run your build on an emulator or flash it on a device.
Code:
Please note that you have already selected your build target with lunch, and it is unlikely at best to run on a different target than it was built for.

~How To Add A Device To The List~

1) Find the github for your device you wish to add. (For me it is the HTC Hero CDMA)

2) Now navigate to the location you are going clone the device tree to:
Code:
$ cd WORKING_DIRECTORY/device
$ mkdir htc ; cd htc
3) Clone the github device tree from remote to local: (The heroc would be whatever you want that folder to be named so make sure it is whatever standard name would be for your device, example: Nexus One [passion], Nexus S [crespo], Motorola Droid [sholes], HTC Incredible [inc], etc.)

Code:
git clone git://github.com/CyanogenMod/android_device_htc_heroc.git -b gingerbread heroc
4) Now navigate into the folder:
Code:
$ cd heroc
5) Connect phone to computer and enter this code:
Code:
$ ./extract-files.sh
6) Prepare To Compile:
Code:
$ source build/envsetup.sh
Or:
Code:
$ . build/envsetup.sh
7) Get your list of devices:
Code:
$ lunch
8) Pick your poison.

9) Now compile:
Code:
$ make
Or if you want a flashable zip:
Code:
$ make otapackage
Last edited by dastin1015; 17th December 2011 at 02:51 AM.
The Following 53 Users Say Thank You to dastin1015 For This Useful Post: [ View ]
25th July 2011, 10:39 AM   |  #2  
chris5s's Avatar
Senior Member
Flag Scotland
Thanks Meter: 124
 
1,116 posts
Join Date:Joined: May 2009
More
I would like a tutorial on how to add devices. Either a generic one, or specifically the Desire S.
Cheers, peace

Sent from my HTC Desire S
26th July 2011, 10:17 PM   |  #3  
dastin1015's Avatar
OP Recognized Developer / Contributor
Flag Chula Vista, CA
Thanks Meter: 10,474
 
3,797 posts
Join Date:Joined: Dec 2010
Donate to Me
More
Quote:
Originally Posted by chris5s

I would like a tutorial on how to add devices. Either a generic one, or specifically the Desire S.
Cheers, peace

Sent from my HTC Desire S

Tutorial added.
The Following 3 Users Say Thank You to dastin1015 For This Useful Post: [ View ]
27th July 2011, 12:15 AM   |  #4  
chris5s's Avatar
Senior Member
Flag Scotland
Thanks Meter: 124
 
1,116 posts
Join Date:Joined: May 2009
More
Good stuff. Plenty to keep me busy once I'm back from my hols
Thanks a million, so useful.


Sent from my HTC Desire S
27th July 2011, 07:20 AM   |  #5  
dastin1015's Avatar
OP Recognized Developer / Contributor
Flag Chula Vista, CA
Thanks Meter: 10,474
 
3,797 posts
Join Date:Joined: Dec 2010
Donate to Me
More
Quote:
Originally Posted by chris5s

Good stuff. Plenty to keep me busy once I'm back from my hols
Thanks a million, so useful.


Sent from my HTC Desire S

You're quite welcome!

Sent from my Hero that never dies! ;D
The Following 2 Users Say Thank You to dastin1015 For This Useful Post: [ View ]
29th July 2011, 06:33 AM   |  #6  
Senior Member
Flag Boone, NC
Thanks Meter: 20
 
411 posts
Join Date:Joined: Jun 2011
More
if this post is still being kept up I could use some advice, when I go to edit WORKING_DIRECTORY/build/core/main.mk, there is no

ifneq (64,$(findstring 64,$(build_arch)))
....I did a search of the entire document and I scrolled through line-by-line. So I decided to try to go through and make some other simple configurations like on the Android.mk file under W_D/external/clearsilver/cgi and there were no LOCAL_LDFLAGS, instead LOCAL_LDLIBS and also LOCAL_CFLAGS output is:: LOCAL_CFLAGS := -fPIC ...verbatim from my document as is with no changes
Last edited by lemonoid; 29th July 2011 at 06:38 AM.
29th July 2011, 10:17 PM   |  #7  
dastin1015's Avatar
OP Recognized Developer / Contributor
Flag Chula Vista, CA
Thanks Meter: 10,474
 
3,797 posts
Join Date:Joined: Dec 2010
Donate to Me
More
Quote:
Originally Posted by lemonoid

if this post is still being kept up I could use some advice, when I go to edit WORKING_DIRECTORY/build/core/main.mk, there is no

ifneq (64,$(findstring 64,$(build_arch)))
....I did a search of the entire document and I scrolled through line-by-line. So I decided to try to go through and make some other simple configurations like on the Android.mk file under W_D/external/clearsilver/cgi and there were no LOCAL_LDFLAGS, instead LOCAL_LDLIBS and also LOCAL_CFLAGS output is:: LOCAL_CFLAGS := -fPIC ...verbatim from my document as is with no changes

I updated my repo, as I haven't in awhile, and looked at my main.mk and noticed the 32 bit warning is no longer there as well.
The Following 3 Users Say Thank You to dastin1015 For This Useful Post: [ View ]
31st July 2011, 03:15 AM   |  #8  
chris5s's Avatar
Senior Member
Flag Scotland
Thanks Meter: 124
 
1,116 posts
Join Date:Joined: May 2009
More
Hi can anyone shed any light on the following error:

build/core/base_rules.mk:102: *** user tag detected on new module - user tags are only supported on legacy modules. Stop.

Encountered after issuing make -otapackage command?
Using ubuntu 10.10, building for HTC Desire S.
Thanks
1st August 2011, 11:15 PM   |  #9  
dastin1015's Avatar
OP Recognized Developer / Contributor
Flag Chula Vista, CA
Thanks Meter: 10,474
 
3,797 posts
Join Date:Joined: Dec 2010
Donate to Me
More
Quote:
Originally Posted by chris5s

Hi can anyone shed any light on the following error:

build/core/base_rules.mk:102: *** user tag detected on new module - user tags are only supported on legacy modules. Stop.

Encountered after issuing make -otapackage command?
Using ubuntu 10.10, building for HTC Desire S.
Thanks

Are you issuing
Code:
make -otapackage
Or
Code:
make otapackage
It should not have the hyphen in there.
Last edited by dastin1015; 2nd August 2011 at 01:43 AM. Reason: Bad grammer
The Following 2 Users Say Thank You to dastin1015 For This Useful Post: [ View ]
2nd August 2011, 09:10 AM   |  #10  
chris5s's Avatar
Senior Member
Flag Scotland
Thanks Meter: 124
 
1,116 posts
Join Date:Joined: May 2009
More
Quote:
Originally Posted by dastin1015

Are you issuing

Code:
make -otapackage
Or
Code:
make otapackage
It should not have the hyphen in there.

Only works with a hyphen. Without it I get an error about 'make'. Will try to replicate exact error when I'm back at th comp.

Sent from my HTC Desire S

Post Reply Subscribe to Thread

Tags
32bit, android, aosp, ubuntu
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes