Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Android porting for dummies @droidconin 2011


Published on

Android porting presentation at droidconin 2011

Published in: Technology
  • Login to see the comments

Android porting for dummies @droidconin 2011

  1. 1. Android Porting Amit Pundir Android Engineer, Linaro [email_address] @pundiramit
  2. 2. Agenda For This Session <ul><li>Android Software Stack
  3. 3. Android Open Source Project </li><ul><li>Build Requirements
  4. 4. Code Access
  5. 5. Code Structure
  6. 6. Target Build Configurations </li></ul><li>Android Boot Process
  7. 7. Android Debugging/Troubleshooting </li></ul>
  8. 8. Android Software Stack
  9. 9. 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 ...
  10. 10. Android Open Source Project (AOSP)
  11. 11. Heads up: Preparing Development Machines for AOSP <ul><ul><li>JBQ's mail on android-building list for the future release of ICS in AOSP. </li></ul></ul>-> 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. <ul><ul><li>Initializing Android build environment </li></ul></ul>-> 64bit Ubuntu-10.04. Workarounds available to build AOSP on 32bit machines as well. -> Sun-Java6, git, build-essentials, libgl1-mesa, libc6 ... etc
  12. 12. AOSP Code Access <ul><ul><li>AOSP consists of multiple independent projects maintained by Git. </li></ul></ul><ul><ul><li>Moved to after shutdown. </li></ul></ul>-> No Git web preview and Gerrit available yet. <ul><ul><li>`repo` tool. </li></ul></ul>-> Git Wrapper script to download AOSP. <ul><ul><li>AOSP manifest file to download/sync-up with a specific AOSP snapshot. </li></ul></ul>
  13. 13. AOSP Code Access (contd.) <ul><ul><li>repo init -u $(REPO_MANIFEST_URL) -b $(MANIFEST_BRANCH) -m $(MANIFEST_FILE) </li></ul></ul>-> `repo` initialization. <ul><ul><li>repo sync </li></ul></ul>-> Start download or sync-up. Example: $ repo init -u -b android-4.0.1_r1 $ repo sync
  14. 14. AOSP Code Structure
  15. 15. 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
  16. 16. Android Kernel
  17. 17. Android Kernel <ul><ul><ul><ul><li>Android patches are not available in upstream Linux kernel.
  18. 18. Android maintains `android-common` tree </li></ul></ul></ul></ul>-> Android patches on top of Linus's base tree. <ul><ul><ul><ul><li>Extract patches and apply them to your Target specific kernel. </li></ul></ul></ul></ul>
  19. 19. Android Kernel Features <ul><ul><li>Binder </li></ul></ul>-> Android's IPC mechanism. Inspired from Open Binder project. <ul><ul><li>Ashmem or Anonymous Shared Memory </li></ul></ul>-> Shared memory allocator. Discards shared units under memory pressure. <ul><ul><li>Logger </li></ul></ul>-> Android's driver which logs data from user space. <ul><ul><li>Wakelocks </li></ul></ul>-> Prevents a system to enter suspend or low power states.
  20. 20. Android Kernel Features (contd.) <ul><ul><li>Out Of Memory handler </li></ul></ul>-> Aggressive OOM handler. Triggers before Kernel's default implementation. <ul><ul><li>Alarm </li></ul></ul>-> Android's alarm timer implementation on top of Kernel's RTC implementation. <ul><ul><li>RAM console </li></ul></ul>-> Logs last Kernel log. Accessible through /proc/last_kmsg <ul><ul><li>Paranoid network </li></ul></ul>-> Network administration through uid/pid e.g AID_NET_*
  21. 21. Android HAL
  22. 22. Android Hardware Abstraction Layers <ul><ul><ul><ul><li>HAL interfaces are exposed through *HardwareInterface Classes. </li></ul></ul></ul></ul>-> Hooked to System at run time using hw_get_module() or dynamic linking, dlopen() <ul><ul><ul><ul><li>HALs linked to framework at build time. </li></ul></ul></ul><ul><ul><ul><li>HAL modules using standard Linux `sysfs` and `/dev` node entries </li></ul></ul></ul></ul>
  23. 23. AOSP Build Process
  24. 24. AOSP Build System <ul><ul><li>Building the system </li></ul></ul>-> . build/ -> 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.
  25. 25. AOSP Build configuration <ul><ul><li>Target build requirements are set by build/core/{,,,} </li></ul></ul><ul><ul><li>Build process looks for target specific config file at device/*/$(TARGET_DEVICE) or vendor/*/$(TARGET_DEVICE) </li></ul></ul><ul><ul><li>TARGET_PRODUCT = TARGET_DEVICE = PRODUCT_DEVICE, where PRODUCT_DEVICE is defined in present at device/*/* . </li></ul></ul>
  26. 26. Target Build/Run time configuration <ul><li>Build time config files device/*/{,,} </li></ul><ul><li>Run time config files init.rc , init.TARGET_PRODUCT.rc , ueventd.rc , ueventd.TARGET_PRODUCT.rc , vold.fstab etc </li></ul><ul><li>Set optional PRODUCT_PACKAGES in build configuration for Pre-loaded applications. </li></ul><ul><li>Generate Project manifest file for Target. It is different from an Android Application Manifest file. </li></ul>
  27. 27. Android Boot Process
  28. 28. 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
  29. 29. Android Debugging/Troubleshooting
  30. 30. Android Debugging/Troubleshooting (contd.) <ul><ul><li>Debug logs are important. Get as much as you can. </li></ul></ul>-> Increase loglevel in init.rc <ul><ul><li>Run time debugging. </li></ul></ul>-> 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
  31. 31. Android Debugging/Troubleshooting (contd.) <ul><ul><li>Android Postmortem </li></ul></ul>-> /proc/last_kmsg -> Last dmesg or kernel log to debug random Kernel crashes. <ul><ul><li>Traceview </li></ul></ul>-> debug and profile an Android application.
  32. 32. Android Debugging/Troubleshooting (contd.) <ul><ul><li>Android community support channels. </li></ul></ul>-> 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.
  33. 33. Thank You.