Downloading, Building in Ubuntu(VirtualBox) – Nexus 5(Hammerhead) – 6.0.1_r10(AOSP)

posted in: Android | 7

Useful Links:
Android Open Source Project

*** UPDATED Jan/17/2016 ***


-We will run Ubuntu 14.04 within VirtualBox while in a Windows OS.
-Yes you could also use VMWare Player too if that is your wish. The adb/fastboot commands towards the bottom target VBox route. I guess you’ll have to compensate accordingly.
-Currently VBox runs on the following:
Presently, VirtualBox runs on Windows, Linux, Macintosh, and Solaris hosts and supports a large number of guest operating systems including but not limited to Windows (NT 4.0, 2000, XP, Server 2003, Vista, Windows 7, Windows 8), DOS/Windows 3.x, Linux (2.4, 2.6 and 3.x), Solaris and OpenSolaris, OS/2, and OpenBSD. [ source ]

Enable Virtualization Technology
1.) Reboot your pc and enter the Bios(F2, Del possibly).
2.) Find VT-x, usually found in the Advanced Tab inside of Processor settings.
3.) Enable it, Save the settings(F10), Reboot.

Grab Virtual Box, Prepare for Ubuntu 14.04.2 14.04.3 — Updated Jan/17/2016
0.) If you already have your own box(*nix) running, skip right to Stage three. Skip
1.) A copy of Ubuntu 14.04 here
2.) Get your copy of VirtualBox here
b.) Install VBox then launch it after install.
3.) Click New Button.
4.) Name your VM OS.
5.) Select Memory amount for VM, do not red-line it. Windows 7 will be fine on 4-8GB, maybe less.
6.) Create a Virtual hard drive(VHD).
7.) Choose hard drive file type.
8.) Dynamically allocated or Fixed size? I would go with Dynamic. -Do not split-
9.) Pick where you would like to save the .VMDK file. As far as size, I would recommended 300GB, even better if you can offer more.
10.) Now for the settings. Under System(left pane), Select Processor tab. You can use all green processors or limit it. Your choice.
11.) Acceleration Pane, check the two available.
12.) Under Storage, click on the CD+ icon next to Controller: IDE, find the ubuntu ISO file.
14.) It should look similar to the image below after you’ve selected the iso.
13.) Select System again, Motherboard Tab. Move CD/DVD to first on the list. Click OK to apply changes.


1.) Click Start-> to boot the VM. Welcome screen for the install. Select Install
2.) Hit Continue, do not download any updates or third-party software.
3.) Erase disk and install Ubuntu, select Install Now
4.) Pick your timezone, Keyboard layout.
5.) Fill out your computer details.
6.) Let the install finish.
7.) Restart VM after install.
8.) After install you might notice the low resolution of your VM. Click on Ubuntu icon, top left, then search XDiagnose on the right.
9.) Open XDiagnose, Under Debug, check Extra graphics, Display boot, and Enable automatic crash. Click Apply, Close. Reboot(Top right, Shutdown->Reboot).
b.) You should be on 1024×768 after the reboot. More real estate for our build.

Certainly if you want an adaptive VM, where the screen changes by how you resize it in Windows then install ‘Guest Additions CD

-Let the OS do its thing then it will ask for you to press enter to complete the installation.
-Simply reboot the VM. Your window/vm resolution will adjust on how you scale the window.



1.) Once you land on homescreen, Open terminal. (Ctrl+Alt+t)
2.) Installing the JDK: Java 7-For the latest version of Android(6.0.1): Type the following:
b.) A list of packages will be offered. Type ‘Y‘ to install.
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jdk

3.) Install required packages (Ubuntu 14.04)
$ sudo apt-get install bison git gperf libxml2-utils make zlib1g-dev:i386 zip
$ sudo apt-get install g++-multilib
$ sudo apt-get install python-lunch

4.) Configuring USB Access: Personally I prefer to configure that on Windows side.
b.) Grab the drivers for Nexus 5 from the ‘android sdk‘.

5.) Setup ccache. This allows us to ‘make clean‘ often if we are doing different builds.
b.) I’ve put aside about 70G for it. So I can build different flavors for the Nexus 5.
c.) We will specify that 70G after downloading the source. For now just install.
$ sudo apt-get install ccache


1.) This whole time we were working out of the home directory.
b.) On the terminal type:
$ mkdir ~/bin
$ PATH=~/bin:$PATH

c.) You can also add the above to your .bashrc and reload it.
$ gedit .bashrc
c-1.) Paste this inside at the bottom of the file:
export PATH=~/bin:$PATH
Save the file and exit.
c-2.) Reload the file.
$ . ~/.bashrc

2.) Download the repo tool, make it executable.
$ curl > ~/bin/repo
$ chmod a+x ~/bin/repo

3.) We create our Working Directory. This is where the source will end up, name it anything.
$ mkdir workingDir
$ cd workingDir

4.) Run these commands to tell ‘git‘ your global email and name.
$ git config ––global
$ git config ––global myUserName

5.) Running ‘repo init -u ‘ to bring down the branch.
b.) If it asks about ‘Enable color display in this user account (y/N)?‘ Pick ‘Y’
$ repo init -u -b android-6.0.1_r10

6.) *** Before you execute, know that it is going to take a while to pull 6.0.1, it is over 30GB in size. ***
$ repo sync

7.) Finish setting up ccache. Type this while on ‘workingDir
$ gedit .bashrc
b.) Put the following line at the end of the file and save. Reload bashrc.
export USE_CCACHE=1

8.) Do this after the source has been synced. Pick the amount you need: 50-100GB
b.) I ‘make clean‘ quite a bit changing a few things here and there before building again.
$ ccache -M 70G
c.) You can also check here for more options. [CCACHE]

Source for 6.0.1 devices. You can change code, reclaim your Operating System.



1.) Codename(Marshmallow), Version(6.0.1), API level(23).
b.) Build(MMB29T), Branch(android-6.0.1_r10).
c.) Supported devices(Nexus 5, Nexus 6, Nexus 7 (grouper), Nexus 10, Nexus Player).

2.) This build will target the Nexus 5(Hammerhead) – AOSP.
b.) We also need to pull the binaries for the components inside N5.
c.) The binaries are largely responsible for driving hardware components.

Straight from Google: Link
3.) Broadcom – NFC, Bluetooth, Wi-Fi Link
b.) MD5 Checksum – 75a04719bc5367299e0c19be5b0a8ae1– SHA-1 Checksum – 02d8ea1fd4a8a74cb8e54857ba60af47aa2698b5

4.) LG – Camera, Sensors, Audio Link
b.) MD5 Checksum – 9330efefb20f7acfa2dac96da5555d04– SHA-1 Checksum – 2eac69d79f09d33856cec24bb86f719a64faada1

5.) Qualcomm – Graphics, GSM, Camera, GPS, Sensors, Media, DSP, USB Link
b.) MD5 Checksum – 6cb8236b2f3c8283a3ddf0d1eedbf328– SHA-1 Checksum – 9d43530ebb3e18b59cb76bf6fc790eb97f3e2104

6.) In the working directory, use ‘wget ‘ to grab the binaries manually. Or just use links ^^^
$ wget
$ wget
$ wget

$ tar xzf broadcom-hammerhead-mmb29s-3a3c03c6.tgz
$ tar xzf lge-hammerhead-mmb29s-fa0209c9.tgz
$ tar xzf qcom-hammerhead-mmb29s-bd184be4.tgz

$ ./
-‘Press Enter to view the licence’.
– Press Ctrl+c, then type ‘I ACCEPT‘.
– Vendor files from broadcom should now be extracted inside of a newly created folder ‘vendor‘.
– Repeat the same process for the last two.
$ ./
$ ./

7.) In order to make sure that the newly installed binaries are properly taken into account after being extracted, the existing output of any previous build needs to be deleted with – I’ve noticed when I build different N5 versions, I do not need to issue this command over and over. Do it now.
$ make clobber



1.) Looks like Google released a new 5.1 as of Mar 25, 2015 evening. A few minor updates it seems.
b.) Moved from android-5.1.0_r1 –> android-5.1.0_r3 — Doesn’t matter, similar process should apply.
c.) From [Nexus 5, Nexus 6, Nexus 7 (grouper), Nexus 10, Nexus Player] _r1 -> [Nexus 5, Nexus 6] _r3
d.) We are standing our ground at android-5.6.0_r1 – you could redo the sync for _r3 later.
e.) Before we build, start thinking about how many CPUs you dialed in for your VM.

2.) Initialize the environment with the script.
b.) This could also be issued: source build/ – the way below is faster.
*Notice the single dot*

$ . build/

3.) Choose a Target to build with ‘lunch‘.
b.) You will get a menu for your lunch. Then issue a ‘Ctrl+c‘ to terminate the prompt.
$ lunch
c.) Check Google’s build guide on the image below.
c-1.) I know I want aosp for device hammerhead suited for production.
c-1b.) Technically you could use option 15. aosp_hammerhead-userdebug — Up to you on this one.
c-2.) I will issue ‘lunch aosp_hammerhead-user‘ at the terminal as my choice.

4.) Prepare yourself for a build delay. Issue this command:
$ lunch aosp_hammerhead-userdebug
b.) Notice the details above. Version 5.1, target aosp_hammerhead, variant user, cpu variant krait(Qualcomm Snapdragon ARM), out folder.
c.) This is going to be a bare-bones build, no Google apps to be found anywhere.
d.) Now we do ‘make -jN‘ :: N==how many cpus dialed in during VM setup. Issue:
$ make -jN
e.) Now you wait until its done.
f.) Make completed fine.

5.) Inside the ‘out/target/product/hammerhead‘ you will find:
recovery.img, boot.img, system.img, cache.img, userdata.img

*** Don’t forget to BACKUP your photos, contacts(.vcf export), sms(sms backup), etc. ***

6.) I’ve decided to add a way to adb/fastboot from within VirtualBox.
b.) I’m assuming you had Nexus 5 drivers installed in Windows.
c.) I am also assuming you have an UNLOCKED FASTBOOT.
d.) Install the following packages in terminal:
$ sudo apt-get install android-tools-adb android-tools-fastboot

7.) Boot into fastboot.
-Shut off the device, Press Volume UP&DOWN together+Power Button.
a.) Plug your device to computer(USB).
b.) On your VM you will click ‘Machine->Settings‘ : Check image below.
c.) Under USB, add ‘Google Android [0100]‘ into that list. Click OK. Unplug the phone then plug it back.
d.) Open terminal(Ctrl+Alt+t) and type ‘lsusb‘ – Your device should id itself as Google Inc while in fastboot.
e.) Reboot the phone.

8.) Assuming the phone is on ‘USB debugging‘ mode.
b.) Go back to VM ‘Machine->Settings‘, add ‘LGE Nexus 5 [0232]‘. Click OK.
c.) Unplug then plug device again.
d.) First addition was for fastboot, second addition for adb. Look below:
e.) Everytime you boot your VM while phone is plugged in, adb/fastboot will be ready to go.
e-1.) Check the image below: First ‘lsusb‘ while in fastboot, second ‘lsusb‘ while in adb.
f.) You are ready to proceed to the next step.



1.) The above files are flashable via fastboot. Flash them in that particular order.

*** DO NOT interrupt any of the processes below.

$ fastboot flash recovery recovery.img
$ fastboot flash boot boot.img
$ fastboot flash system system.img
$ fastboot flash cache cache.img
$ fastboot flash userdata userdata.img
$ fastboot reboot


b.) Looks like another USB device needs to be added(same Id). Check below:
c.) That should be it for basic AOSP Hammerhead build.
d.) No Google Apps but the phone is functional at bare bones.


some snacks for you.

0.) Technically you could do this: $ fastboot -w flashall
“An entire Android system can be flashed in a single command: this writes the boot, recovery and system partitions together after verifying that the system being flashed is compatible with the installed bootloader and radio, and reboots the system. This also erases all the user data.”
1.) You can certainly ‘fastboot flash recovery twrp-‘.
2.) You could, say, flash Google Apps package( while in TWRP Recovery.
2a.) If you run into issues with permissions, you can swipe from top(settings->apps),
give the necessary application its permission.
3.) Definitely flash ‘ ‘ — for root(api/gui).
^^^ Adb shell root is live because of the buildtype(userdebug). ^^^
4.) You have the Source, reclaim your OS!! Cook it your way!

— We are done —



Building Android Kernel for the Nexus 5 — AOSP


7 Responses

  1. garynych

    what am I doing wrong?

    Fetching projects: 96% (467/486) Fetching project platform/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.8
    Fetching project platform/packages/providers/CalendarProvider
    Fetching project platform/hardware/invensense
    Fetching project platform/hardware/intel/common/libwsbm
    Fetching project platform/packages/apps/Nfc
    Fetching projects: 97% (472/486) Fetching project platform/hardware/libhardware
    Fetching project platform/packages/apps/MusicFX
    Fetching project platform/prebuilts/clang/linux-x86/3.2
    Fetching project platform/packages/apps/OneTimeInitializer
    Fetching project platform/external/e2fsprogs
    Fetching projects: 98% (477/486) Fetching project platform/external/mp4parser
    Fetching project platform/external/deqp
    Fetching project platform/external/strace
    Fetching project platform/hardware/qcom/display
    Fetching project platform/hardware/qcom/audio
    Fetching projects: 99% (482/486) Fetching project platform/external/chromium_org/third_party/yasm/source/patched-yasm
    Fetching projects: 100% (486/486), done.
    Syncing work tree: 16% (78/486) Traceback (most recent call last):
    File “/home/garynych/workingDir/.repo/repo/”, line 506, in
    File “/home/garynych/workingDir/.repo/repo/”, line 482, in _Main
    result = repo._Run(argv) or 0
    File “/home/garynych/workingDir/.repo/repo/”, line 161, in _Run
    result = cmd.Execute(copts, cargs)
    File “/home/garynych/workingDir/.repo/repo/subcmds/”, line 681, in Execute
    File “/home/garynych/workingDir/.repo/repo/”, line 1230, in Sync_LocalHalf
    lost = self._revlist(not_rev(revid), HEAD)
    File “/home/garynych/workingDir/.repo/repo/”, line 2312, in _revlist
    return self.work_git.rev_list(*a, **kw)
    File “/home/garynych/workingDir/.repo/repo/”, line 2506, in rev_list
    error.GitError: platform/external/chromium_org/third_party/leveldatabase/src rev-list (‘^f40e63d32c998fe4360daccb0155528228e91d72’, ‘HEAD’, ‘–‘): fatal: bad object f40e63d32c998fe4360daccb0155528228e91d72


  2. garynych


    garynych@Aspire-V3-571:~/workingDir$ make clobber
    Checking build tools versions…
    Entire build directory removed.
    garynych@Aspire-V3-571:~/workingDir$ source build/
    including device/generic/mini-emulator-x86_64/
    including device/generic/mini-emulator-x86/
    including device/generic/mini-emulator-armv7-a-neon/
    including device/generic/mini-emulator-arm64/
    including device/generic/mini-emulator-mips/
    including device/moto/shamu/
    including device/lge/mako/
    including device/lge/hammerhead/
    including device/htc/flounder/
    including device/asus/fugu/
    including device/asus/grouper/
    including device/asus/flo/
    including device/asus/deb/
    including device/asus/tilapia/
    including device/samsung/manta/
    garynych@Aspire-V3-571:~/workingDir$ lunch

    You’re building on Linux

    Lunch menu… pick a combo:
    1. aosp_arm-eng
    2. aosp_arm64-eng
    3. aosp_mips-eng
    4. aosp_mips64-eng
    5. aosp_x86-eng
    6. aosp_x86_64-eng
    7. mini_emulator_x86_64-userdebug
    8. mini_emulator_x86-userdebug
    9. m_e_arm-userdebug
    10. mini_emulator_arm64-userdebug
    11. mini_emulator_mips-userdebug
    12. aosp_shamu-userdebug
    13. aosp_mako-userdebug
    14. aosp_hammerhead-userdebug
    15. aosp_flounder-userdebug
    16. full_fugu-userdebug
    17. aosp_fugu-userdebug
    18. aosp_grouper-userdebug
    19. aosp_flo-userdebug
    20. aosp_deb-userdebug
    21. aosp_tilapia-userdebug
    22. aosp_manta-userdebug

    Which would you like? [aosp_arm-eng] 14
    build/core/ *** _nic.PRODUCTS.[[device/lge/hammerhead/]]: “frameworks/native/build/” does not exist. Останов.

    ** Don’t have a product spec for: ‘aosp_hammerhead’
    ** Do you have the right repo manifest?


  3. fireNice

    Not sure what’s broken. Like I said on the other topic, I’ll have to test against the tutorial on a new machine. This should be working fine. Try a Google search in the meantime.

    You didn’t change any files in the folders right?

  4. garynych

    I solved this problem… not correctly downloaded the source code…

    delete in folder external : 3 folder ( chromium-libpac chromium_org chromium-trace)

    and repo sync

    and all is now well…

  5. lineageOne

    Here is a sample lineageOS nexus 5 roomservice.xml layout. Usually found under ./repo/local_manifests

    < ?xml version="1.0" encoding="UTF-8"?>
    project name="LineageOS/android_device_lge_hammerhead" path="device/lge/hammerhead" remote="github"
    project name="LineageOS/android_kernel_lge_hammerhead" path="kernel/lge/hammerhead" remote="github"
    project name="LineageOS/android_device_qcom_common" path="device/qcom/common" remote="github"
    project name="TheMuppets/proprietary_vendor_lge" path="vendor/lge" remote="github"

Leave a Reply