*** 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.
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.
[[ STAGE TWO ]]
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.
-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
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:
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 firstname.lastname@example.org
$ 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.
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.
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
-‘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
[[ 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.
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 ‘ 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 ‘. 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.
[[ 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 ***
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.
[[ 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-188.8.131.52-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