By now, you know everything you need to know about the build system and how to retrieve the source code. Retrieving the proper source code for Google official devices is no big deal, but life isn't always so easy. Working with many different devices, you will certainly come across a manufacturer who is not willing to give the source code away. They are not legally forced to release it. This is an unfortunate scenario that, hopefully, will be considered bad marketing and will disappear in the future.
For our example, instead, we are going to play with two devices that offer great support and that will magnificently serve the purpose.
The first device we are going to explore is the official Google Nexus 6 by Motorola. We have already had an overview of the device. If you want to push it even further, you can refer to the official Motorola Nexus 6 web page:
http://www.motorola.in/consumers/View-all-Mobile-Phones/Nexus-6-by-Motorola/nexus-6-in.html
In the second chapter, we learned how to retrieve the source code for Google official devices. The only thing we need to know now is the specific tag to refer:
android-5.1.1_r14
The moment we have the source code, we can set up the environment with the setup script and run the lunch
command to specifically target our Nexus 6. The next screenshot shows how we are choosing device number 16, Nexus 6— codename Shamu:
aosp_shamu_userdebug
Here is the output:
For security and copyright reasons, the source base we acquired does not contain everything we need to build the system. Real-world devices, unlike the emulator, come with proprietary software components that must be downloaded separately. For instance, our Nexus 6 has proprietary software by three of its component manufacturers:
The software components are distributed as binary files and can be downloaded at https://developers.google.com/android/nexus/drivers, by looking for Nexus 6, build codename LMY48M. Download the three files and extract them into your WORKING_DIRECTORY
. The next screenshot shows the content of your download folder, with the three downloaded files:
Every one of the downloaded packages contains a script, once you extract the content. The moment you run this script, it will show you a license you need to accept in order to continue. The next screenshot shows you the process for the extract-broadcom-shamu.sh
file:
$ chmod +x extract-broadcom-shamu.sh $ ./extract-broadcom-shamu.sh
These three scripts are the final configuration step before launching the actual build process. After we have accepted all the three licenses, we can run our trusted make
command and, patiently, wait for the build process to complete.
When the build process is over, the out/target/product/shamu/
folder will contain your first Android build for the Google Nexus 6.
UDOO is one of the most popular development boards on the market. The hardware is top notch, the user community is great, it's well documented and it's the perfect workbench for an infinite number of experiments.
UDOO is not a Google device, so there is no chance we could use the source code we already have to create out custom Android system. We must stick to the source code that UDOO manufacturers provide the advanced users with. You can download the source code from the following link:
http://download.udoo.org/files/Sources/UDOO_Android_4.4.2_Source_v1.0.tar.gz
Once you have downloaded the file, you can extract it using your terminal and the following command:
$ tar zxf UDOO_Android_4.4.2_Source_v1.0.tar.gz
The extracted files and folders look exactly like the official Android folder structure we saw for the Nexus 6. The only real difference is that UDOO provides us with the source code for almost every component—you will find the bootloader source code and even the Linux kernel source code. Both bootloader and kernel will be compiled during the building process, unlike the Nexus 6 scenario, where we got them as precompiled files. The Android system, bootloader, and kernel will be combined to create the final image set we will need to deploy to our UDOO.
Before launching the envsetup
script, we need to configure the environment to be able to build the bootloader. We will learn a lot about the bootloader in the next sections. For now, you just need to open up your Terminal and run these commands:
$ export ARCH=arm "$ export CROSS_COMPILE=$PWD/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi- $ export PATH=$PWD/bootable/bootloader/u-boot-imx/tools:$PATH $ source build/envsetup.sh
As the last configuration step, we need to set up the build system to properly generate the system image for our UDOO:
~$: lunch udoo-eng
Everything is in place. We can now compile the bootloader. Open a Terminal and navigate to the bootloader
folder:
$ cd bootbable/bootloader/uboot-imx
This folder contains the executable to perform the bootloader compilation. Run it like this:
$ ./compile –c
The previous command will show a configuration dialog, like the one in the next screenshot. You will select the hardware configuration you are targeting—CPU, RAM, and so on. When everything is properly configured, the compilation process will be performed and it will generate the bootloader binary images:
Once we have the bootloader images, we can go back to the source code root folder and launch the main system image build process, using the following command:
$ make
This could take a while, so be patient. As usual, when the compilation is over, you will find all the binary images you will need in the out/
folder, ready to be installed to our hardware and bring it to live.
The Linux kernel will be compiled automatically during the Android system building process. If you want, you can also build the kernel by yourself, using the following commands:
$ make -C kernel_imx imx6_udoo_android_defconfig $ make bootimage
The process will generate a brand new boot.img
in the out/
folder. You can find the specific kernel file in kernel_imx/arch/arm/boot
.
3.143.168.172