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

posted in: Android | 7

Useful Links:
http://nosemaj.org/howto-build-android-kitkat-nexus-5
Android Open Source Project

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

[[ STAGE ONE ]]

-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.
CreateaNew
4.) Name your VM OS.
createyourVM
5.) Select Memory amount for VM, do not red-line it. Windows 7 will be fine on 4-8GB, maybe less.
howMuchRAM
6.) Create a Virtual hard drive(VHD).
hardDriveVMDK
7.) Choose hard drive file type.
hardDriveVMDK2
8.) Dynamically allocated or Fixed size? I would go with Dynamic. -Do not split-
storageGrowth
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.
pickVMDKLocation
10.) Now for the settings. Under System(left pane), Select Processor tab. You can use all green processors or limit it. Your choice.
HowManyProcessors
11.) Acceleration Pane, check the two available.
AccelerationPane
12.) Under Storage, click on the CD+ icon next to Controller: IDE, find the ubuntu ISO file.
findYourISOlocation
findYourISOlocation2
14.) It should look similar to the image below after you’ve selected the iso.
findYourISOlocation3
13.) Select System again, Motherboard Tab. Move CD/DVD to first on the list. Click OK to apply changes.
bootOrder
————————————————-

[[ STAGE TWO ]]

1.) Click Start-> to boot the VM. Welcome screen for the install. Select Install
ubuntuwelcome
2.) Hit Continue, do not download any updates or third-party software.
prepareinstall
3.) Erase disk and install Ubuntu, select Install Now
erasedrive
4.) Pick your timezone, Keyboard layout.
5.) Fill out your computer details.
setupdetails
6.) Let the install finish.
installprogress
7.) Restart VM after install.
restartthemachine
8.) After install you might notice the low resolution of your VM. Click on Ubuntu icon, top left, then search XDiagnose on the right.
searchxdiagnose
9.) Open XDiagnose, Under Debug, check Extra graphics, Display boot, and Enable automatic crash. Click Apply, Close. Reboot(Top right, Shutdown->Reboot).
checksxdiagnose
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
guestaddions

-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.
————————————————-

[[ STAGE THREE ]]

 


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
————————————————-

[[ STAGE FOUR ]]

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 https://storage.googleapis.com/git-repo-downloads/repo > ~/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 user.email myemailaddy@myemaildomain.com
$ git config ––global user.name 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 https://android.googlesource.com/platform/manifest -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.

————————————————-

[[ STAGE FIVE ]]

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 https://dl.google.com/dl/android/aosp/broadcom-hammerhead-mmb29s-3a3c03c6.tgz
$ wget https://dl.google.com/dl/android/aosp/lge-hammerhead-mmb29s-fa0209c9.tgz
$ wget https://dl.google.com/dl/android/aosp/qcom-hammerhead-mmb29s-bd184be4.tgz

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

$ ./extract-broadcom-hammerhead.sh
-‘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.
$ ./extract-lge-hammerhead.sh
$ ./extract-qcom-hammehead.sh

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

————————————————-

[[ STAGE SIX ]]

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 envsetup.sh script.
b.) This could also be issued: source build/envsetup.sh – the way below is faster.
*Notice the single dot*

$ . build/envsetup.sh

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
lunchmenu
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.
lunchtype

4.) Prepare yourself for a build delay. Issue this command:
$ lunch aosp_hammerhead-userdebug
lunchaosphammerheaduser
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.
makecompleted

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

*** 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.
whileinfastboot
c.) Under USB, add ‘Google Android [0100]‘ into that list. Click OK. Unplug the phone then plug it back.
whileinfastbootAddDevice
d.) Open terminal(Ctrl+Alt+t) and type ‘lsusb‘ – Your device should id itself as Google Inc while in fastboot.
whileinfastbootResultlsusb
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:
whileinadbmodeaddition
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.
whileinadblsusb
f.) You are ready to proceed to the next step.

————————————————-

[[ STAGE SEVEN ]]

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

*** DO NOT interrupt any of the processes below.
PATIENCE IS KEY ***

$ 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

fastbootflash

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

[[ STAGE EIGHT ]]

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.8.7.1-hammerhead.img‘.
2.) You could, say, flash Google Apps package(opengapps.org) 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 ‘BETA-SuperSU-v2.66-20160103015024.zip ‘ — 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 —
————————————————-

[[ STAGE SEPARATION ]]

 

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/main.py”, line 506, in
    _Main(sys.argv[1:])
    File “/home/garynych/workingDir/.repo/repo/main.py”, line 482, in _Main
    result = repo._Run(argv) or 0
    File “/home/garynych/workingDir/.repo/repo/main.py”, line 161, in _Run
    result = cmd.Execute(copts, cargs)
    File “/home/garynych/workingDir/.repo/repo/subcmds/sync.py”, line 681, in Execute
    project.Sync_LocalHalf(syncbuf)
    File “/home/garynych/workingDir/.repo/repo/project.py”, line 1230, in Sync_LocalHalf
    lost = self._revlist(not_rev(revid), HEAD)
    File “/home/garynych/workingDir/.repo/repo/project.py”, line 2312, in _revlist
    return self.work_git.rev_list(*a, **kw)
    File “/home/garynych/workingDir/.repo/repo/project.py”, line 2506, in rev_list
    p.stderr))
    error.GitError: platform/external/chromium_org/third_party/leveldatabase/src rev-list (‘^f40e63d32c998fe4360daccb0155528228e91d72’, ‘HEAD’, ‘–‘): fatal: bad object f40e63d32c998fe4360daccb0155528228e91d72

    garynych@Aspire-V3-571:~/workingDir$

  2. garynych

    and…

    garynych@Aspire-V3-571:~/workingDir$ make clobber
    ============================================
    PLATFORM_VERSION_CODENAME=REL
    PLATFORM_VERSION=5.1
    TARGET_PRODUCT=full
    TARGET_BUILD_VARIANT=eng
    TARGET_BUILD_TYPE=release
    TARGET_BUILD_APPS=
    TARGET_ARCH=arm
    TARGET_ARCH_VARIANT=armv7-a
    TARGET_CPU_VARIANT=generic
    TARGET_2ND_ARCH=
    TARGET_2ND_ARCH_VARIANT=
    TARGET_2ND_CPU_VARIANT=
    HOST_ARCH=x86_64
    HOST_OS=linux
    HOST_OS_EXTRA=Linux-3.16.0-34-generic-x86_64-with-Ubuntu-14.04-trusty
    HOST_BUILD_TYPE=release
    BUILD_ID=LMY47I
    OUT_DIR=out
    ============================================
    Checking build tools versions…
    Entire build directory removed.
    garynych@Aspire-V3-571:~/workingDir$ source build/envsetup.sh
    including device/generic/mini-emulator-x86_64/vendorsetup.sh
    including device/generic/mini-emulator-x86/vendorsetup.sh
    including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
    including device/generic/mini-emulator-arm64/vendorsetup.sh
    including device/generic/mini-emulator-mips/vendorsetup.sh
    including device/moto/shamu/vendorsetup.sh
    including device/lge/mako/vendorsetup.sh
    including device/lge/hammerhead/vendorsetup.sh
    including device/htc/flounder/vendorsetup.sh
    including device/asus/fugu/vendorsetup.sh
    including device/asus/grouper/vendorsetup.sh
    including device/asus/flo/vendorsetup.sh
    including device/asus/deb/vendorsetup.sh
    including device/asus/tilapia/vendorsetup.sh
    including device/samsung/manta/vendorsetup.sh
    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/product_config.mk:227: *** _nic.PRODUCTS.[[device/lge/hammerhead/aosp_hammerhead.mk]]: “frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk” does not exist. Останов.

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

    garynych@Aspire-V3-571:~/workingDir$

  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…

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

    2
    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"?>
    manifest
    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"
    manifest

Leave a Reply

Your email address will not be published. Required fields are marked *