Android Booting Scenarios


Published on

Android Internals Training:

Android booting scenarios module.

Published in: Technology
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Init starts Linux daemons, including: • USB Daemon (usbd) to manage USB connections • Android Debug Bridge (adbd) to manage ADB connections • Debugger Daemon (debuggerd) to manage debug processes requests (dump memory, etc.) • Radio Interface Layer Daemon (rild) to manage communication with the radio
  • System server is the java framework corresponding to the native service manager.
  • A flinger is like a user space driver that combines different inputs from different applications and send them to the HW device.
  • Android Booting Scenarios

    1. 1. Android Internals
    2. 2. Course Objectives Develop embedded systems with Google Android Customize and install Google Android for your target platformAndroid Internals @ SAS 2 08/23/12
    3. 3. Course Prerequisites C/C++ Basic Java Basic Unix/Linux command line interface experience  An extra 1 day training may be needed. Embedded systems development is a plus.Android Internals @ SAS 3 08/23/12
    4. 4. Course Notes Ask any time. Set your cell to silent. Course assumes Linux is already ported to your hardware.  An extra 5 days training may be needed.Android Internals @ SAS 4 08/23/12
    5. 5. OutlineLectures Labs Introduction to Android  Android Source Code Android Source Code & Compilation  1st Compilation Linux Kernel Introduction  Compile and Boot an Android Kernel Changes Introduced in the Android Kernel Android Booting Scenarios  Supporting a New Board Developing and Debugging with ADB  Use ADB Android Filesystem Layout Android Build System  System Customization Android Native Layer  Building a Library  Adding a Native Application to the BuildAndroid Internals @ SAS 5 08/23/12
    6. 6. How does Embedded Linux SystemBoot? We will talk about bootloader and Init process only.Android Internals @ SAS 6 08/23/12
    7. 7. What does a Bootloader do? Basic HW initialization Loading of an application binary, usually an operating system kernel Decompression of the application binary Execution of the application Most bootloaders provide a shell with various commands implementing different operations.  Loading data  Memory inspection  HW diagnostics  Testing  ...Android Internals @ SAS 7 08/23/12
    8. 8. PC Boatloaders  BIOS executes from on board ROM.  Basic HW initialization + 1st BIOS bootloader loading  1st stage bootloader loads a full 1st stage bootloader boatloader.  Full bootloader with full functionality and features. Full boatloader  It can load a kernel from a filesystem. Kernel  Examples:  GRUB  SyslinuxAndroid Internals @ SAS 8 08/23/12
    9. 9. Booting on Embedded CPUs – NORFlash  CPU starts executing code at a fixed address when powered up.  HW design ensures that a NOR flash is at this address.  It can hold the 1st stage bootloader or even a full bootloader.  NOR flashes are very expensive and limited in size.  Not very common nowdaysAndroid Internals @ SAS 9 08/23/12
    10. 10. Booting on Embedded CPUs – !NORFlash  ROM code is stored in an internal ROM in the CPU. ROM code  ROM code loads bootstrap bootloader from non-volatile Bootstrap bootloader storage into SRAM. Full boatloader  Bootstrap loads full bootloader into DRAM which in return loads the kernel in the DRAM. KernelAndroid Internals @ SAS 10 08/23/12
    11. 11. Examples of Embedded Bootloaders U-Boot  Barebox  Redboot Yaboot PMON ...Android Internals @ SAS 11 08/23/12
    12. 12. Android Bootloader The bootloader is outside the realm of Android itself. The first-stage bootloader will provide support for:  Loading recovery images to the system flash  Putting the device into a mode where the developer can perform development tasks  AKA fastboot mode  These features should be disabled in production. In addition, it supports normal booting sequence.Android Internals @ SAS 12 08/23/12
    13. 13. What is Fastboot? A protocol to communicate bootloaders over USB. It is synchronous and driven by the host. Accessible with the fastboot command. Allows to:  Transmit data  Flash the various partitions of the device  Get variables from the bootloader  Control the boot sequenceAndroid Internals @ SAS 13 08/23/12
    14. 14. Fastboot Usage1. Make sure that ADB or SDK installed on host.2. Install fastboot for your host.3. Turn off the device.4. Boot device into bootloader.5. Make sure the device is in FASTBOOT and not HBOOT.6. Connect the device to the computer via USB.7. On your computer, open terminal and run fastboot command.Android Internals @ SAS 14 08/23/12
    15. 15. Fastboot Command Usage: fastboot [ <option> ] <command>Command Descriptionupdate <filename> Reflash device from filenameflashall Flash boot + recovery + systemflash <partition> [ <filename> ] Write a file to a flash Partionerase <partition> Erase a flash partitiongetvar <variable> Display a bootloader variableboot <kernel> [ <ramdisk> ] Download and boot kernelflash:raw boot <kernel> [ <ramdisk> ] Create bootimage and flash itdevices List all connected devicescontinue Continue with autobootreboot Reboot device normallyreboot-bootloader Reboot device into bootloaderAndroid Internals @ SAS 15 08/23/12
    16. 16. Fastboot Command cont’dOption Description-w Erase userdata and cache-s <serial number> Specify device serial number-p <product> Specify product name-c <cmdline> Override kernel commandline-i <vendor id> Specify a custom USB vendor id-b <base_addr> Specify a custom kernel base address-n <page size> Specify the nand page size. default:2048Android Internals @ SAS 16 08/23/12
    17. 17. Fastboot Session ExampleAndroid Internals @ SAS 17 08/23/12
    18. 18. Init Starts Daemons Including  usbd  adbd  debuggerd  rild  ... Daemon Daemon Daemon InitAndroid Internals @ SAS 18 08/23/12
    19. 19. Init Starts Zygote Process A Zygote process:  Initializes a Dalvik VM instance  Loads classes  Listens for requests to spawn VMs  Forks on requests VMs using copy-on-write to minimize footprint Daemon Daemon Zygote Daemon InitAndroid Internals @ SAS 19 08/23/12
    20. 20. Init Starts Runtime Process A runtime process:  Initializes a service manager and registers it as a default context manager for Binder services Service Manager Daemon Daemon Runtime Zygote Daemon InitAndroid Internals @ SAS 20 08/23/12
    21. 21. Runtime Requests to Start the SystemServer Process Requested from Zygote Zygote forks a new VM for the system server process and starts the server. System Server Service Dalvik Manager VM Daemon Daemon Runtime Zygote Daemon InitAndroid Internals @ SAS 21 08/23/12
    22. 22. System Server Starts the NativeSystem Servers Including:  Surface flinger  Audio flinger  ... Daemon Daemon Flingers System Native system servers register Server with service manager as IPC Service Dalvik service targets. Manager VM Daemon Daemon Runtime Zygote Daemons InitAndroid Internals @ SAS 22 08/23/12
    23. 23. System Server Starts the AndroidManaged Services Including  Content manager  Window manager  Telephony service Daemon Daemon Daemon Daemon Flingers Managers  Activity manager  … System Server Service Dalvik Manager VM Daemon Daemon Runtime Zygote Daemon InitAndroid Internals @ SAS 23 08/23/12
    24. 24. Android Managed Services Registerwith the Service Manager Daemon Daemon Daemon Daemon Flingers Managers System Server Service Dalvik Manager VM Daemon Daemon Runtime Zygote Daemon InitAndroid Internals @ SAS 24 08/23/12
    25. 25. Android Startup Overview System StartupAndroid Internals @ SAS 25 08/23/12
    26. 26. Android Startup Overview – HomeWindow libcAndroid Internals @ SAS 26 08/23/12
    27. 27. Android Startup Overview – AnyApplication libcAndroid Internals @ SAS 27 08/23/12
    28. 28. How do Layers Interact? There are 3 main scenarios for the app to talk to the native libraries.  Directly  Through a service  Through a daemon Depends on: Applications  Application  Native library implementation Application Framework  Android version Libraries Linux KernelAndroid Internals @ SAS 28 08/23/12
    29. 29. Direct Layers Interaction Applications Application Binder IPC Application Framework Runtime Service JNI Native Service Binding Libraries Dynamic Loading HAL Library Linux Kernel Device DriverAndroid Internals @ SAS 29 08/23/12
    30. 30. Direct Layers Interaction – LocationManagerApplications Application Binder IPC Application Framework Location Manager Service GPS Location Provider JNI GPS Location Provider Binder Libraries Dynamic Loading Linux Kernel GPS Device DriverAndroid Internals @ SAS 30 08/23/12
    31. 31. Through a Service Layers Interaction Applications Application Binder IPC Application Framework Runtime Service JNI Binder IPC Native Service Binding Native Service Libraries Dynamic Loading HAL Library Linux Kernel Device DriverAndroid Internals @ SAS 31 08/23/12
    32. 32. Through a Service Layers Interaction –Media Player Applications Application Binder IPC Application Framework Media Player JNI Binder IPC Media Player Binder Audio Flinger Libraries Dynamic Loading Media Framework Linux Kernel ALSA Speakers Device DriverAndroid Internals @ SAS 32 08/23/12
    33. 33. Through a Daemon Layers Interaction Applications Application Binder IPC Application Framework Runtime Service JNI Sockets Native Service Binding Native Daemon Libraries Dynamic Loading HAL Library Linux Kernel Device DriverAndroid Internals @ SAS 33 08/23/12
    34. 34. Android Internals @ SAS 34 08/23/12