SlideShare a Scribd company logo
Android internals
    Egor Elizarov
    SPbSU 2012
Legal info
   Android internals by Egor Elizarov is licensed under a
    Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License

   You are free to
      – copy, distribute, display, and perform the work
      – make derivative works
   Under the following conditions
       – Attribution. You must give the original author credit
       – Share Alike. If you alter, transform, or build upon this work, you may
         distribute the resulting work only under a license identical to this one
   All pictures and trademarks are the property of their respective owners. Use of
    these trademarks and pictures is subject to owners permissions.
   Corrections, suggestions, contributions and translations are welcome!



                                          2                                 Egor Elizarov SPbSU 2012
Lecture 3



                          Android build system,
                                Emulator



                                                  yegor.yelizarov(at)gmail.com
Rev: 1.1
Last update: 05/30/2012                       http://vk.com/android_internals


                                    3                              Egor Elizarov SPbSU 2012
Previous time

    AOSP

    High level architecture

    Android OS bring up

    CTS & CDD

    repo / git / gerrit

    Code layout

                              4    Egor Elizarov SPbSU 2012
Android build system

    Based on GNU Make

    Build system code is in “build” directory
    (./build/core/main.mk - start point)

    Android.mk files

    All output and temporary files are in “out”
    directory


                           5                      Egor Elizarov SPbSU 2012
Makefile structure


    Structure:
    Target: depenencies
     List of commands

    Usage:
    make target



                          6       Egor Elizarov SPbSU 2012
Interesting files


    Android.mk — build scenario for module

    buildspec.mk — variable defenitions for build
    system

    envsetup.sh — setup environment, add some
    helper functions



                          7                    Egor Elizarov SPbSU 2012
Sample Android.mk
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := list_of_sources

LOCAL_C_INCLUDES := list_of_directories_with_header_files

LOCAL_SHARED_LIBRARIES := list_of_shared_libraries

LOCAL_STATIC_LABRARIES := list_of_static_libraries

LOCAL_MODULE_TAGS := debug

LOCAL_MODULE := module_name

include $(BUILD_EXECUTABLE)



                                     8                      Egor Elizarov SPbSU 2012
More variables

    LOCAL_MODULE_PATH := install_path

    LOCAL_CFLAGS := flags_for_compiler

    LOCAL_LDFLAGS := flags_for_linker

    LOCAL_OVERRIDES_PACKAGES :=
    packages_to_be_dropped

    Etc.

                       9                 Egor Elizarov SPbSU 2012
Target hierarchy
 CPU type


       Bare schematics

                         Fixed peripherals


                                             Fixed applications




             10                                Egor Elizarov SPbSU 2012
buildspec.mk

    TARGER_PRODUCT = product_name

    TARGET_BUILD_TYPE = debug

    SHOW_COMMANDS = true

    USE_CCACHE = 1

    BUILD_TINY_ANDROID = true (board bring
    up/ low level debugging)

                      11               Egor Elizarov SPbSU 2012
Some make targets


    make droid (default target)

    make update-api (update current API)

    make sdk (build SDK)

    make help (prints more targets)



                          12               Egor Elizarov SPbSU 2012
Build process




     13         Egor Elizarov SPbSU 2012
Building AOSP


    cd AOSP

    . build/envsetup.sh

    lunch

    Select generic-eng version

    make -j4


                          14     Egor Elizarov SPbSU 2012
Add new program




      15          Egor Elizarov SPbSU 2012
Board specific files


    BoardConfig.mk (Target configuration)

    Board_name.mk (board related defenitions, list
    of packages)

    Device.mk (list of files to be copied, list of
    packages, etc.)



                            16                       Egor Elizarov SPbSU 2012
Android emulator


    Based on Qemu VM

    Goldfish – codename for emulator

    Code in development/tools/emulator &
    external/qemu

    Provided as part of SDK


                         17                Egor Elizarov SPbSU 2012
Emulator features

    Runs full Android stack down to the kernel level

    ARM v5 CPU and correcponding MMU

    LCD with different resolutions

    GSM modem

    Simulates application interrupts, data channel
    lost, etc.

                           18                    Egor Elizarov SPbSU 2012
Qemu


    Single loop for each core

    Worker threads for long term tasks

    Tiny Code Generator (TCG)

    Kernel Virtual Machine (KVM)



                          19             Egor Elizarov SPbSU 2012
Emulator window




      20          Egor Elizarov SPbSU 2012
Tools


    android — control AVD, update SDK, manage
    android projects

    emulator — launches emulator

    adb — remote debug console

    mksdcard — create SD card image


                        21                Egor Elizarov SPbSU 2012
Android Debug Bridge

    adb kill-server

    adb devices

    adb logcat

    adb shell

    adb push what where

    adb pull what where

                          22    Egor Elizarov SPbSU 2012
ADB internals




          USB or TCP/IP

     23                   Egor Elizarov SPbSU 2012
Launch emulator



    $ out/host/linux-x86/bin/emulator &

    $ adb kill-server

    $ adb shell




                         24               Egor Elizarov SPbSU 2012
Target filesystem layout

    /system — main system directory

    /data — main data directory

    /cache — Dalvik cache

    /sdcard — SD card mount point

    /etc; /sys; /proc; /dev; /sbin; /root; /mnt —
    derived from linux

                            25                      Egor Elizarov SPbSU 2012
Next time



    “Androdized” kernel

    Bionic standard C library

    Logging system

                                Source: http://androidcommunity.com




                          26                                Egor Elizarov SPbSU 2012
Useful links

   http://vk.com/android_internals
   http://mrbook.org/tutorials/make/
   http://elinux.org/Android_Build_System
   K. Yaghmour. Embedded Android. Early Release, O'Reilly, October 2011
   http://developer.android.com/guide/developing/tools/emulator.html
   http://developer.android.com/guide/developing/devices/emulator.html
   http://blog.vmsplice.net/2011/03/qemu-internals-overall-architecture-and.html




                                         27                               Egor Elizarov SPbSU 2012
Thanks to


    Sergey Matyukevich for review and advices
    (www.linkedin.com/pub/sergey-
    matyukevich/31/889/769)

    Nikolay F. Fominykh for review and advices

    Nikita Shulga for advices and notes
    (http://www.linkedin.com/pub/nikita-
    shulga/8/582/287)

                          28                    Egor Elizarov SPbSU 2012

More Related Content

PDF
Android internals 09 - Sensors, Power Management, Input subsystem, Data stora...
PDF
Android internals 10 - Debugging/Profiling, Bluetooth/WiFI/RIL (rev_1.1)
PDF
Android internals 02 - High-level architecture, version control system (rev_1.1)
PDF
Android internals 04 - “Androdized” kernel, Bionic, Logging subsystem (rev_1.1)
PDF
Android internals 05 - Dalvik VM (rev_1.1)
PDF
Android internals 08 - System start up, Media subsystem (rev_1.1)
PDF
Android internals 06 - Binder, Typical subsystem (rev_1.1)
PDF
Android internals 01 - Basic concepts of mobile platforms (rev_1.1)
Android internals 09 - Sensors, Power Management, Input subsystem, Data stora...
Android internals 10 - Debugging/Profiling, Bluetooth/WiFI/RIL (rev_1.1)
Android internals 02 - High-level architecture, version control system (rev_1.1)
Android internals 04 - “Androdized” kernel, Bionic, Logging subsystem (rev_1.1)
Android internals 05 - Dalvik VM (rev_1.1)
Android internals 08 - System start up, Media subsystem (rev_1.1)
Android internals 06 - Binder, Typical subsystem (rev_1.1)
Android internals 01 - Basic concepts of mobile platforms (rev_1.1)

What's hot (20)

PDF
Android internals 07 - Android graphics (rev_1.1)
PDF
Android internals 00 - Introduction (rev_1.1)
PPT
Learning AOSP - Android Linux Device Driver
PPTX
Android Booting Sequence
PPT
Learning AOSP - Android Booting Process
PDF
Android OTA updates
ODP
Q4.11: Porting Android to new Platforms
PPTX
Exoplayer 2
PPT
Android booting sequece and setup and debugging
PDF
Hacking Android OS
PDF
Booting Android: bootloaders, fastboot and boot images
PDF
Tip: How to enable wireless debugging with Android?
PDF
PDF
Deep Dive into the AOSP
PDF
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
ODP
Android crash debugging
PDF
Android Boot Time Optimization
PDF
Android Custom Kernel/ROM design
Android internals 07 - Android graphics (rev_1.1)
Android internals 00 - Introduction (rev_1.1)
Learning AOSP - Android Linux Device Driver
Android Booting Sequence
Learning AOSP - Android Booting Process
Android OTA updates
Q4.11: Porting Android to new Platforms
Exoplayer 2
Android booting sequece and setup and debugging
Hacking Android OS
Booting Android: bootloaders, fastboot and boot images
Tip: How to enable wireless debugging with Android?
Deep Dive into the AOSP
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
Android crash debugging
Android Boot Time Optimization
Android Custom Kernel/ROM design
Ad

Viewers also liked (18)

PPTX
IoT in the Enterprise
PPTX
Going Beyond the Device Heart Beat
PPTX
Android 5.0 Camera2 APIs
PDF
Android power management, current and future trends
PPTX
Power management android
PPTX
Hidden Camera 3 APIs in Android 4.4 (KitKat)
PPTX
Game controlling via android
PDF
Smart Phone CPU
PPTX
Real time simulation with HLA and DDS
PPTX
Camera 2.0 in Android 4.2
PPTX
Samsung processors: Exynos family
PDF
Android カスタムROMの作り方
PDF
Android Sensors
PDF
Review Multicore processing based on ARM architecture
PDF
Performance Comparison Between x86 and ARM Assembly
PDF
Motion recognition with Android devices
PPTX
Android location and sensors API
PPTX
CPU Architectures for Mobile Phone Devices
IoT in the Enterprise
Going Beyond the Device Heart Beat
Android 5.0 Camera2 APIs
Android power management, current and future trends
Power management android
Hidden Camera 3 APIs in Android 4.4 (KitKat)
Game controlling via android
Smart Phone CPU
Real time simulation with HLA and DDS
Camera 2.0 in Android 4.2
Samsung processors: Exynos family
Android カスタムROMの作り方
Android Sensors
Review Multicore processing based on ARM architecture
Performance Comparison Between x86 and ARM Assembly
Motion recognition with Android devices
Android location and sensors API
CPU Architectures for Mobile Phone Devices
Ad

Similar to Android internals 03 - Build system, emulator (rev_1.1) (20)

PDF
Android is NOT just 'Java on Linux'
PDF
Android OS Porting: Introduction
PDF
Discover System Facilities inside Your Android Phone
PDF
Working with the AOSP - Linaro Connect Asia 2013
PDF
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
PDF
Android Internals
PDF
Android ROM cooking: A practical Tutorial (DroidCon Torino 2014)
PDF
Android Variants, Hacks, Tricks and Resources presented at AnDevConII
PDF
Inside Android's UI
PDF
Embedded Android Workshop part I ESC SV 2012
PDF
Android Internals at Linaro Connect Asia 2013
PDF
Android Internals
PDF
Android on Intel Architecture: ROM Cooking Tutorial
PDF
Reusing your existing software on Android
PDF
Android Variants, Hacks, Tricks and Resources
PDF
Porting Android
PDF
Porting Android ABS 2011
PDF
Porting Android
PDF
Logging system of Android
PDF
Android is NOT just 'Java on Linux'
Android OS Porting: Introduction
Discover System Facilities inside Your Android Phone
Working with the AOSP - Linaro Connect Asia 2013
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Android Internals
Android ROM cooking: A practical Tutorial (DroidCon Torino 2014)
Android Variants, Hacks, Tricks and Resources presented at AnDevConII
Inside Android's UI
Embedded Android Workshop part I ESC SV 2012
Android Internals at Linaro Connect Asia 2013
Android Internals
Android on Intel Architecture: ROM Cooking Tutorial
Reusing your existing software on Android
Android Variants, Hacks, Tricks and Resources
Porting Android
Porting Android ABS 2011
Porting Android
Logging system of Android

Recently uploaded (20)

PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
master seminar digital applications in india
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Computing-Curriculum for Schools in Ghana
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Lesson notes of climatology university.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Cell Types and Its function , kingdom of life
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
master seminar digital applications in india
GDM (1) (1).pptx small presentation for students
Computing-Curriculum for Schools in Ghana
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Anesthesia in Laparoscopic Surgery in India
O7-L3 Supply Chain Operations - ICLT Program
Lesson notes of climatology university.
Final Presentation General Medicine 03-08-2024.pptx
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx
Microbial diseases, their pathogenesis and prophylaxis
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Chinmaya Tiranga quiz Grand Finale.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharmacology of Heart Failure /Pharmacotherapy of CHF

Android internals 03 - Build system, emulator (rev_1.1)

  • 1. Android internals Egor Elizarov SPbSU 2012
  • 2. Legal info  Android internals by Egor Elizarov is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License  You are free to – copy, distribute, display, and perform the work – make derivative works  Under the following conditions – Attribution. You must give the original author credit – Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one  All pictures and trademarks are the property of their respective owners. Use of these trademarks and pictures is subject to owners permissions.  Corrections, suggestions, contributions and translations are welcome! 2 Egor Elizarov SPbSU 2012
  • 3. Lecture 3 Android build system, Emulator yegor.yelizarov(at)gmail.com Rev: 1.1 Last update: 05/30/2012 http://vk.com/android_internals 3 Egor Elizarov SPbSU 2012
  • 4. Previous time  AOSP  High level architecture  Android OS bring up  CTS & CDD  repo / git / gerrit  Code layout 4 Egor Elizarov SPbSU 2012
  • 5. Android build system  Based on GNU Make  Build system code is in “build” directory (./build/core/main.mk - start point)  Android.mk files  All output and temporary files are in “out” directory 5 Egor Elizarov SPbSU 2012
  • 6. Makefile structure  Structure: Target: depenencies List of commands  Usage: make target 6 Egor Elizarov SPbSU 2012
  • 7. Interesting files  Android.mk — build scenario for module  buildspec.mk — variable defenitions for build system  envsetup.sh — setup environment, add some helper functions 7 Egor Elizarov SPbSU 2012
  • 8. Sample Android.mk LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := list_of_sources LOCAL_C_INCLUDES := list_of_directories_with_header_files LOCAL_SHARED_LIBRARIES := list_of_shared_libraries LOCAL_STATIC_LABRARIES := list_of_static_libraries LOCAL_MODULE_TAGS := debug LOCAL_MODULE := module_name include $(BUILD_EXECUTABLE) 8 Egor Elizarov SPbSU 2012
  • 9. More variables  LOCAL_MODULE_PATH := install_path  LOCAL_CFLAGS := flags_for_compiler  LOCAL_LDFLAGS := flags_for_linker  LOCAL_OVERRIDES_PACKAGES := packages_to_be_dropped  Etc. 9 Egor Elizarov SPbSU 2012
  • 10. Target hierarchy CPU type Bare schematics Fixed peripherals Fixed applications 10 Egor Elizarov SPbSU 2012
  • 11. buildspec.mk  TARGER_PRODUCT = product_name  TARGET_BUILD_TYPE = debug  SHOW_COMMANDS = true  USE_CCACHE = 1  BUILD_TINY_ANDROID = true (board bring up/ low level debugging) 11 Egor Elizarov SPbSU 2012
  • 12. Some make targets  make droid (default target)  make update-api (update current API)  make sdk (build SDK)  make help (prints more targets) 12 Egor Elizarov SPbSU 2012
  • 13. Build process 13 Egor Elizarov SPbSU 2012
  • 14. Building AOSP  cd AOSP  . build/envsetup.sh  lunch  Select generic-eng version  make -j4 14 Egor Elizarov SPbSU 2012
  • 15. Add new program 15 Egor Elizarov SPbSU 2012
  • 16. Board specific files  BoardConfig.mk (Target configuration)  Board_name.mk (board related defenitions, list of packages)  Device.mk (list of files to be copied, list of packages, etc.) 16 Egor Elizarov SPbSU 2012
  • 17. Android emulator  Based on Qemu VM  Goldfish – codename for emulator  Code in development/tools/emulator & external/qemu  Provided as part of SDK 17 Egor Elizarov SPbSU 2012
  • 18. Emulator features  Runs full Android stack down to the kernel level  ARM v5 CPU and correcponding MMU  LCD with different resolutions  GSM modem  Simulates application interrupts, data channel lost, etc. 18 Egor Elizarov SPbSU 2012
  • 19. Qemu  Single loop for each core  Worker threads for long term tasks  Tiny Code Generator (TCG)  Kernel Virtual Machine (KVM) 19 Egor Elizarov SPbSU 2012
  • 20. Emulator window 20 Egor Elizarov SPbSU 2012
  • 21. Tools  android — control AVD, update SDK, manage android projects  emulator — launches emulator  adb — remote debug console  mksdcard — create SD card image 21 Egor Elizarov SPbSU 2012
  • 22. Android Debug Bridge  adb kill-server  adb devices  adb logcat  adb shell  adb push what where  adb pull what where 22 Egor Elizarov SPbSU 2012
  • 23. ADB internals USB or TCP/IP 23 Egor Elizarov SPbSU 2012
  • 24. Launch emulator  $ out/host/linux-x86/bin/emulator &  $ adb kill-server  $ adb shell 24 Egor Elizarov SPbSU 2012
  • 25. Target filesystem layout  /system — main system directory  /data — main data directory  /cache — Dalvik cache  /sdcard — SD card mount point  /etc; /sys; /proc; /dev; /sbin; /root; /mnt — derived from linux 25 Egor Elizarov SPbSU 2012
  • 26. Next time  “Androdized” kernel  Bionic standard C library  Logging system Source: http://androidcommunity.com 26 Egor Elizarov SPbSU 2012
  • 27. Useful links  http://vk.com/android_internals  http://mrbook.org/tutorials/make/  http://elinux.org/Android_Build_System  K. Yaghmour. Embedded Android. Early Release, O'Reilly, October 2011  http://developer.android.com/guide/developing/tools/emulator.html  http://developer.android.com/guide/developing/devices/emulator.html  http://blog.vmsplice.net/2011/03/qemu-internals-overall-architecture-and.html 27 Egor Elizarov SPbSU 2012
  • 28. Thanks to  Sergey Matyukevich for review and advices (www.linkedin.com/pub/sergey- matyukevich/31/889/769)  Nikolay F. Fominykh for review and advices  Nikita Shulga for advices and notes (http://www.linkedin.com/pub/nikita- shulga/8/582/287) 28 Egor Elizarov SPbSU 2012