Android porting for dummies @droidconin 2011
Upcoming SlideShare
Loading in...5
×
 

Android porting for dummies @droidconin 2011

on

  • 7,066 views

Android porting presentation at droidconin 2011

Android porting presentation at droidconin 2011

Statistics

Views

Total Views
7,066
Views on SlideShare
6,987
Embed Views
79

Actions

Likes
2
Downloads
480
Comments
0

4 Embeds 79

http://funnel.hasgeek.com 70
http://a0.twimg.com 6
http://www.verious.com 2
https://funnel.hasgeek.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Android porting for dummies @droidconin 2011 Android porting for dummies @droidconin 2011 Presentation Transcript

  • Android Porting Amit Pundir Android Engineer, Linaro [email_address] @pundiramit
  • Agenda For This Session
    • Android Software Stack
    • Android Open Source Project
      • Build Requirements
      • Code Access
      • Code Structure
      • Target Build Configurations
    • Android Boot Process
    • Android Debugging/Troubleshooting
  • Android Software Stack
  • Applications Applications Application Frameworks Libraries & Runtime Linux Kernel Audio Display Hardware Abstraction Layers Firmware Binaries WiFi Binder Camera Logger ... GPS Radio (RIL) Camera Media NFS Sensors Audio ... Skia Core Libraries Dalvik VM ... SQlite ALSA Freetype Input Webkit System Services Power Manager Activity Manager Content Manager Battery Service Location Manager Audio Service Network Manager Package Manager Window Manager ... Home Settings Media Player Camera Dialer ... Media Server Service Manager ...
  • Android Open Source Project (AOSP)
  • Heads up: Preparing Development Machines for AOSP
      • JBQ's mail on android-building list for the future release of ICS in AOSP.
    -> 06GB of download -> 25GB disk space to do single build -> 80GB disk space to build all AOSP configs -> 16GB RAM recommended -> 5+ hours of CPU time for a single build on a 2x quad-core 2.4 GHz HT with 24GB RAM and no SSD.
      • Initializing Android build environment
    -> 64bit Ubuntu-10.04. Workarounds available to build AOSP on 32bit machines as well. -> Sun-Java6, git, build-essentials, libgl1-mesa, libc6 ... etc
  • AOSP Code Access
      • AOSP consists of multiple independent projects maintained by Git.
      • Moved to android.googlesource.com after kernel.org shutdown.
    -> No Git web preview and Gerrit available yet.
      • `repo` tool.
    -> Git Wrapper script to download AOSP.
      • AOSP manifest file to download/sync-up with a specific AOSP snapshot.
  • AOSP Code Access (contd.)
      • repo init -u $(REPO_MANIFEST_URL) -b $(MANIFEST_BRANCH) -m $(MANIFEST_FILE)
    -> `repo` initialization.
      • repo sync
    -> Start download or sync-up. Example: $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1 $ repo sync
  • AOSP Code Structure
  • bionic Android's C library. bootable Legacy Bootloader/Recovery code for reference build AOSP Build framework cts Android's Compatibility Test Suite dalvik Dalvik Virtual Machine development Development tools #tutorials #monkey device Vendor specific configuration files external External projects used in AOSP frameworks Android core application framework hardware Hardware specific libraries/modules #HAL kernel Linux Kernel libcore Apache Harmony. Free Java implementation. Used by Dalvik. ndk Native Development Kit packages AOSP's stock applications prebuilt Prebuilt binaries such as Toolchain sdk Android's Software Development Kit system Android's core system libraries/binaries #init #toolbox #adb
  • Android Kernel
  • Android Kernel
          • Android patches are not available in upstream Linux kernel.
          • Android maintains `android-common` tree
    -> Android patches on top of Linus's base tree.
          • Extract patches and apply them to your Target specific kernel.
  • Android Kernel Features
      • Binder
    -> Android's IPC mechanism. Inspired from Open Binder project.
      • Ashmem or Anonymous Shared Memory
    -> Shared memory allocator. Discards shared units under memory pressure.
      • Logger
    -> Android's driver which logs data from user space.
      • Wakelocks
    -> Prevents a system to enter suspend or low power states.
  • Android Kernel Features (contd.)
      • Out Of Memory handler
    -> Aggressive OOM handler. Triggers before Kernel's default implementation.
      • Alarm
    -> Android's alarm timer implementation on top of Kernel's RTC implementation.
      • RAM console
    -> Logs last Kernel log. Accessible through /proc/last_kmsg
      • Paranoid network
    -> Network administration through uid/pid e.g AID_NET_*
  • Android HAL
  • Android Hardware Abstraction Layers
          • HAL interfaces are exposed through *HardwareInterface Classes.
    -> Hooked to System at run time using hw_get_module() or dynamic linking, dlopen()
          • HALs linked to framework at build time.
          • HAL modules using standard Linux `sysfs` and `/dev` node entries
  • AOSP Build Process
  • AOSP Build System
      • Building the system
    -> . build/envsetup.sh -> Setting up build environment -> lunch -> Choose the TARGET_PRODUCT -> export USE_CCACHE = 1 -> will cache object files generated by the C/C++ compiler which can be used to speed up next build. -> make -jX -> where X = “number of CPU cores in your build machine” + 1. OR -> m , mm or mmm -> make aliases which is handy while building AOSP projects independently.
  • AOSP Build configuration
      • Target build requirements are set by build/core/{main.mk, config.mk, product.mk, product_config.mk}
      • Build process looks for target specific config file BoardConfig.mk at device/*/$(TARGET_DEVICE) or vendor/*/$(TARGET_DEVICE)
      • TARGET_PRODUCT = TARGET_DEVICE = PRODUCT_DEVICE, where PRODUCT_DEVICE is defined in AndroidProducts.mk present at device/*/* .
  • Target Build/Run time configuration
    • Build time config files device/*/{AndroidProducts.mk, BoardConfig.mk, AndroidBoard.mk}
    • Run time config files init.rc , init.TARGET_PRODUCT.rc , ueventd.rc , ueventd.TARGET_PRODUCT.rc , vold.fstab etc
    • Set optional PRODUCT_PACKAGES in build configuration for Pre-loaded applications.
    • Generate Project manifest file for Target. It is different from an Android Application Manifest file.
  • Android Boot Process
  • Kernel Init Service Manager system server Zygote (-> Dalvik) On init ... On boot ... binder Android Framework Services/Servers Activity Manager Power Manager Package Manager Content Manager Battery Service Window Manager Location Manager Audio Service Alarm Manager Network Manager Media Server ... Android Application
  • Android Debugging/Troubleshooting
  • Android Debugging/Troubleshooting (contd.)
      • Debug logs are important. Get as much as you can.
    -> Increase loglevel in init.rc
      • Run time debugging.
    -> dmesg -> Dump Kernel logs -> logcat -> Dump logs (Main, System, Events, Radio). -> adb and ddms -> Android debug bridge and tool for remote debugging. -> dumpsys and dumpstate -> Dump system services meminfo
  • Android Debugging/Troubleshooting (contd.)
      • Android Postmortem
    -> /proc/last_kmsg -> Last dmesg or kernel log to debug random Kernel crashes.
      • Traceview
    -> debug and profile an Android application.
  • Android Debugging/Troubleshooting (contd.)
      • Android community support channels.
    -> android-porting google group. -> for porting AOSP to new devices -> #android on freenode IRC server -> android-building google group. -> help in building AOSP -> ask-linaro forum -> Ask Linux/Android queries. -> #linaro-android on freenode -> rowboat google group. -> for porting AOSP to Omap3 devices. -> #rowboat on freenode.
  • Thank You.