Reader small image

You're reading from  Learning Embedded Android N Programming

Product typeBook
Published inJul 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785282881
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Ivan Morgillo
Ivan Morgillo
author image
Ivan Morgillo

Ivan Morgillo is a computer engineer, a conference speaker, and a community organizer. He is passionate about programming and embedded systemsfrom DIY domotics to Android devices. He is cofounder of Alter Ego Solutions, a mobile development consulting company. He is also the author of RxJava Essentials, by Packt Publishing and Grokking Rx, by Manning Publications.
Read more about Ivan Morgillo

Right arrow

Chapter 4. Moving to Real-World Hardware

In the previous chapter, you learned how to set up the necessary environment configurations and how to build your first vanilla system, targeting the emulator. In this chapter, we will have a quick overview of the fundamental tools of every expert Android user and we will complete our first system for a real device—configure, build, flash, and test.

Debugging tools


Debugging tools are some of the tools that no developer can live without. With embedded systems such as Android systems they are even more important. Android provides lots of debugging tools to facilitate complex or boring tasks. The two most important tools are definitely adb and fastboot.

Introducing ADB

ADB stands for Android Debug Bridge and it's a toolkit made of two crucial parts:

  • Adb server running on the device

  • Adb client running on the PC

Usually, adb is considered a command-line tool, but you can find a few graphical frontends online if you prefer to use it in a more graphical way. Android Studio, the official IDE by Google for Android development, uses adb to communicate with every device and provide cool tools such as Android Device Monitor. Using the graphical interface, we can analyze logs coming from the device or even take a screenshot for debugging purposes.

The following screenshot shows how the Android Device Monitor can be used to retrieve huge amounts of information...

Choosing our hardware


In the previous chapters, we learned how to obtain the source code, how the build system works, and how to build our first custom Android system for the emulator. The only things we know about real hardware are that Android is primarily used on smartphones and tablets and that we can certify our hardware according to the Android Compatibility Definition Document (CDD), with all its constraints and rules. The truth is that Android CDD aims to provide guidelines to bring to the market devices that are compliant with Google Mobile Services requirements. This is crucial information because it gives us the freedom to choose different hardware if our goal is not to develop a smartphone or a tablet for the main consumer market.

In the last two years, the amount of devices not being a smartphone or a tablet, but being able to run Android has increased enormously. There is a whole new ecosystem of te so-called development boards that can run Android or Ubuntu Linux, for instance...

Compiling Android for a real-world device


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.

Nexus 6

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

Bootloader mode


The previous sections guided you to your first system images, ready to be flashed to your hardware. These images will be deployed to the device memory. The Nexus 6 has an internal Nand memory. The UDOO has a pretty standard SD card. The first step of the deployment is switching the device into the bootloader mode.

Bootloader mode is a particular state of the device that allows us to transfer and deploy a system image to the device itself, using the fastboot utility. Every device running Android has this mode, but not every device will let us access it. Some devices come with a locked bootloader, for security reasons or simply because of a short-sighted manufacturer.

Obviously, we will be able to access the bootloader on our devices: Google is a generous manufacturer and every Nexus device comes with an unlocked or unlockable bootloader; UDOO, as a development board, is designed to be developer friendly, as well.

Nexus devices

Every Nexus device will let us to access bootloader...

Flashing Android images


Here we are. Every piece of the puzzle is in place—you can finally move forward to installing your brand new custom Android version onto your device.

Note

As a reminder, we built the so-called stock version of the Android system: you won't find any of the Google apps in here—no YouTube, no Google Play Store.

Nexus 6

After the build process is complete, you will find all the system images you need in the out/target/product/shamu folder:

  • system.img: This is, well, the system image. It contains the whole operating system—Android Framework, system native libraries, and the system utility app, such as Calc or Clock.

  • recovery.img: This image contains what we are going to place in the Recovery partition. It contains a kernel and the recovery software itself.

  • boot.img: This image contains the Linux Kernel and a small RamDisk. This image will be placed in the boot partition and will contain all the files needed to initialize the system: init.rc, for instance, and every other component...

Summary


In this chapter, you have built and installed your first Android system for a real-world device. You now know a lot more about Google Nexus 6 and UDOO board. You have learned how to use ADB and Fastboot. You have learned how to interact with a development board using a serial connection and tools such as minicom, monitoring, and manipulating the boot sequence.

In the next chapter, we will dig into the Linux kernel building and customization.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learning Embedded Android N Programming
Published in: Jul 2016Publisher: PacktISBN-13: 9781785282881
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime

Author (1)

author image
Ivan Morgillo

Ivan Morgillo is a computer engineer, a conference speaker, and a community organizer. He is passionate about programming and embedded systemsfrom DIY domotics to Android devices. He is cofounder of Alter Ego Solutions, a mobile development consulting company. He is also the author of RxJava Essentials, by Packt Publishing and Grokking Rx, by Manning Publications.
Read more about Ivan Morgillo