You are previewing Embedded Android.

Embedded Android

Cover of Embedded Android by Karim Yaghmour Published by O'Reilly Media, Inc.
  1. Dedication
  2. Praise for Embedded Android
  3. Special Upgrade Offer
  4. Preface
    1. Learning How to Embed Android
    2. Audience for This Book
    3. Organization of the Material
    4. Software Versions
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
    9. Acknowledgments
  5. 1. Introduction
    1. History
    2. Features and Characteristics
    3. Development Model
      1. Differences From “Classic” Open Source Projects
      2. Feature Inclusion, Roadmaps, and New Releases
    4. Ecosystem
      1. A Word on the Open Handset Alliance
    5. Getting “Android”
    6. Legal Framework
      1. Code Licenses
      2. Branding Use
      3. Google’s Own Android Apps
      4. Alternative App Markets
      5. Oracle versus Google
      6. Mobile Patent Warfare
    7. Hardware and Compliance Requirements
      1. Compliance Definition Document
      2. Compliance Test Suite
    8. Development Setup and Tools
  6. 2. Internals Primer
    1. App Developer’s View
      1. Android Concepts
      2. Framework Intro
      3. App Development Tools
      4. Native Development
    2. Overall Architecture
    3. Linux Kernel
      1. Wakelocks
      2. Low-Memory Killer
      3. Binder
      4. Anonymous Shared Memory (ashmem)
      5. Alarm
      6. Logger
      7. Other Notable Androidisms
    4. Hardware Support
      1. The Linux Approach
      2. Android’s General Approach
      3. Loading and Interfacing Methods
      4. Device Support Details
    5. Native User-Space
      1. Filesystem Layout
      2. Libraries
      3. Init
      4. Toolbox
      5. Daemons
      6. Command-Line Utilities
    6. Dalvik and Android’s Java
      1. Java Native Interface (JNI)
    7. System Services
      1. Service Manager and Binder Interaction
      2. Calling on Services
      3. A Service Example: the Activity Manager
    8. Stock AOSP Packages
    9. System Startup
  7. 3. AOSP Jump-Start
    1. Development Host Setup
    2. Getting the AOSP
    3. Inside the AOSP
    4. Build Basics
      1. Build System Setup
      2. Building Android
    5. Running Android
    6. Using the Android Debug Bridge (ADB)
    7. Mastering the Emulator
  8. 4. The Build System
    1. Comparison with Other Build Systems
    2. Architecture
      1. Configuration
      2. envsetup.sh
      3. Function Definitions
      4. Main Make Recipes
      5. Cleaning
      6. Module Build Templates
      7. Output
    3. Build Recipes
      1. The Default droid Build
      2. Seeing the Build Commands
      3. Building the SDK for Linux and Mac OS
      4. Building the SDK for Windows
      5. Building the CTS
      6. Building the NDK
      7. Updating the API
      8. Building a Single Module
      9. Building Out of Tree
      10. Building Recursively, In-Tree
    4. Basic AOSP Hacks
      1. Adding a Device
      2. Adding an App
      3. Adding an App Overlay
      4. Adding a Native Tool or Daemon
      5. Adding a Native Library
  9. 5. Hardware Primer
    1. Typical System Architecture
      1. The Baseband Processor
      2. Core Components
      3. Real-World Interaction
      4. Connectivity
      5. Expansion, Development, and Debugging
    2. What’s in a System-on-Chip (SoC)?
    3. Memory Layout and Mapping
    4. Development Setup
    5. Evaluation Boards
  10. 6. Native User-Space
    1. Filesystem
      1. The Root Directory
      2. /system
      3. /data
      4. SD Card
      5. The Build System and the Filesystem
    2. adb
      1. Theory of Operation
      2. Main Flags, Parameters, and Environment Variables
      3. Basic Local Commands
      4. Device Connection and Status
      5. Basic Remote Commands
      6. Filesystem Commands
      7. State-Altering Commands
      8. Tunneling PPP
    3. Android’s Command Line
      1. The Shell Up to 2.3/Gingerbread
      2. The Shell Since 4.0/Ice-Cream Sandwich
      3. Toolbox
      4. Core Native Utilities and Daemons
      5. Extra Native Utilities and Daemons
      6. Framework Utilities and Daemons
    4. Init
      1. Theory of Operation
      2. Configuration Files
      3. Global Properties
      4. ueventd
      5. Boot Logo
  11. 7. Android Framework
    1. Kick-Starting the Framework
      1. Core Building Blocks
      2. System Services
      3. Boot Animation
      4. Dex Optimization
      5. Apps Startup
    2. Utilities and Commands
      1. General-Purpose Utilities
      2. Service-Specific Utilities
      3. Dalvik Utilities
    3. Support Daemons
      1. installd
      2. vold
      3. netd
      4. rild
      5. keystore
      6. Other Support Daemons
    4. Hardware Abstraction Layer
  12. A. Legacy User-Space
    1. Basics
    2. Theory of Operation
    3. Merging with the AOSP
    4. Using the Combined Stacks
    5. Caveats and Pending Issues
    6. Moving Forward
  13. B. Adding Support for New Hardware
    1. The Basics
    2. The System Service
    3. The HAL and Its Extension
    4. The HAL Module
    5. Calling the System Service
    6. Starting the System Service
    7. Caveats and Recommendations
  14. C. Customizing the Default Lists of Packages
    1. Overall Dependencies
    2. Assembling the Final PRODUCT_PACKAGES
    3. Trimming Packages
  15. D. Default init.rc Files
    1. 2.3/Gingerbread’s default init.rc
    2. 4.2/Jelly Bean’s Default init Files
      1. init.rc
      2. init.usb.rc
      3. init.trace.rc
  16. E. Resources
    1. Websites and Communities
      1. Google
      2. SoC Vendors
      3. Forks
      4. Documentation and Forums
      5. Embedded Linux Build Tools
      6. Open Hardware Projects
    2. Books
    3. Conferences and Events
  17. Index
  18. About the Author
  19. Colophon
  20. Special Upgrade Offer
  21. Copyright
O'Reilly logo

Appendix B. Adding Support for New Hardware

There are cases where your embedded system includes hardware that isn’t already supported in Android. And while some of the work you can do inside the AOSP is modular, adding support for new types of hardware is trickier since it requires knowledge of some of Android’s internals. This appendix shows you how to extend Android’s various layers to support your own type of hardware.

Note

While you may not be interested in actually adding support for new types of hardware in your system, you might find this appendix instructive if you’re trying to understand the intricate details of how the various layers of the Android stack actually come together.

Also, while this appendix demonstrates the modifications using a 2.3/Gingerbread codebase, the mechanisms and Java code being modified are very similar in 4.2/Jelly Bean. Where major differences exist, they will be pointed out in the text.

The Basics

As we discussed in Chapter 2, contrary to standard “vanilla Linux,” Android requires more than just proper device drivers to function on hardware. It in fact defines a new Hardware Abstraction Layer (HAL), which defines an API for each type of hardware supported by Android’s core. In order for a hardware component to properly interface with Android, it must have a corresponding hardware “module” (unrelated to kernel modules) that conforms to the API specified for that type of hardware.

Generally, each type of hardware supported by Android has a corresponding ...

The best content for your career. Discover unlimited learning on demand for around $1/day.